)
输出格式二:
select convert(char(4),Years,120) as myear,
sum(case when IsFirstSixMonths=0 then totalcome else 0 end) as '上半年',
sum(case when IsFirstSixMonths=1 then totalcome else 0 end) as '下半年'
from test
group by convert(char(4),Years,120)



结果如下:

case2

相关文章: