首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

队列转求解

2012-09-08 
行列转求解set nocount ondeclare @tt table(Months varchar(10),Shop_Code varchar(500),sale_Amount var

行列转求解
set nocount on
declare @tt table
(
Months varchar(10),
Shop_Code varchar(500),
sale_Amount varchar(50)
)
insert into @tt select '[1月]','P000349','47950'
insert into @tt select '[2月]','P000055','54520'
insert into @tt select '[2月]','P000007','58020'
insert into @tt select '[2月]','P000349','58119'
insert into @tt select '[3月]','P000055','7045'
insert into @tt select '[3月]','P000039','0'
insert into @tt select '[3月]','P000348','34156'
insert into @tt select '[4月]','P000039','67030'
insert into @tt select '[5月]','P000039','53700'


select * from @tt

[解决办法]

SQL code
select     Shop_Code 产品代码,    max(case Months when '[1月]' then sale_Amount else 0 end) 一月,    max(case Months when '[2月]' then sale_Amount else 0 end) 二月,    max(case Months when '[3月]' then sale_Amount else 0 end) 三月,    max(case Months when '[4月]' then sale_Amount else 0 end) 四月,    max(case Months when '[5月]' then sale_Amount else 0 end) 五月from @tt group by Shop_Code
[解决办法]
探讨
SQL code


select
Shop_Code 产品代码,
max(case Months when '[1月]' then sale_Amount else 0 end) 一月,
max(case Months when '[2月]' then sale_Amount else 0 end) 二月,
max(case Months when……

[解决办法]
解决了及时结贴啊

热点排行