码迷,mamicode.com
首页 > 其他好文 > 详细

pivot列行转换,自动计算分组,解决groupby问题

时间:2015-08-06 12:37:13      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:


select top 20 * from
(
select PromotionRateAmount,(cast(year(ReserveDate) as varchar(4))+cast(month(ReserveDate) as varchar(2))) as MonthSum,OrderId
from [PAAmountAndDay] WITH(NOLOCK)
where orderid in (select distinct orderid from [FlMortgageDetailGroupByMortgageContractNoAndOrderID])
) as a
pivot(sum(PromotionRateAmount) for MonthSum in ([20151],[20152],[20153],[20154])) as b

pivot列行转换,自动计算分组,解决groupby问题

标签:

原文地址:http://www.cnblogs.com/liuchuanxu/p/4707510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!