在网上查了下,终于是找到了。
select good_id,
一月 = max(case when m = 1 then price else null end ),
二月 = max(case when m = 2 then price else null end ),
三月 = max(case when m = 3 then price else null end ),
四月 = max(case when m = 4 then price else null end ),
五月 = max(case when m = 5 then price else null end ),
六月 = max(case when m = 6 then price else null end ),
七月 = max(case when m = 7 then price else null end ),
八月 = max(case when m = 8 then price else null end ),
九月 = max(case when m = 9 then price else null end ),
十月 = max(case when m = 10 then price else null end ),
十一月 = max(case when m = 11 then price else null end ),
十二月 = max(case when m = 12 then price else null end )
from prices group by good_id
[此贴子已经被作者于2012-11-14 17:19:21编辑过]