请大家看看有沒有辦法實現,謝謝。表A
Time charge cus_code
20090101 100 1
20090201 200 1
20090301 300 1
20090401 400 1
20090501 500 1
20090601 600 1
20090301 100 2
20090401 200 2
20090501 100 3
20090601 200 3
20090701 300 3我要的結果
cus_code,20090101,20090201,20090301,20090401,20090501,20090601,20090701
1 ,100 ,200 ,300 ,400 ,500 ,600
2 , , ,100 ,200
3 , , , , ,100 ,200 ,300
另外,月份我只是隨便寫的,具體包括多少個月份要 select distinct time from A,以上只是測試數據,所以請不要在sql中出現20090101,20090201等字樣。
請大家提出實現方法,謝謝。
Time charge cus_code
20090101 100 1
20090201 200 1
20090301 300 1
20090401 400 1
20090501 500 1
20090601 600 1
20090301 100 2
20090401 200 2
20090501 100 3
20090601 200 3
20090701 300 3我要的結果
cus_code,20090101,20090201,20090301,20090401,20090501,20090601,20090701
1 ,100 ,200 ,300 ,400 ,500 ,600
2 , , ,100 ,200
3 , , , , ,100 ,200 ,300
另外,月份我只是隨便寫的,具體包括多少個月份要 select distinct time from A,以上只是測試數據,所以請不要在sql中出現20090101,20090201等字樣。
請大家提出實現方法,謝謝。
http://topic.csdn.net/u/20091019/11/67cd55a3-3f42-4db7-a3f8-91dd52a913cd.html
后可以加上||' order by ...'
你可以按具体需要修改