读书人

奇怪郁闷行转列为什么结果不对?大

发布时间: 2012-01-28 22:06:13 作者: rapoo

奇怪,郁闷,行转列为什么结果不对?大家帮帮我
TB1:
订单号 数量
1 10
2 5
3 8

要求结果:
1 2 3
10 5 8

应该怎么写?

[解决办法]
select max(case when 订单号=1 then 数量 end),
max(case when 订单号=2 then 数量 end),
max(case when 订单号=3 then 数量 end) from tb1

读书人网 >SQL Server

热点推荐