通過一年數據的比較,我有類似如下表:並排方在SQL
Year | Product | Value
2006 A 10
2006 B 20
2006 C 30
2007 A 40
2007 B 50
2007 C 60
我想一個查詢將返回以下比較
Product | 2006 Value | 2007 Value
A 10 40
B 20 50
C 30 60
是什麼這樣做的選擇?它可以在沒有連接的情況下完成嗎?
我正在使用DB2,但所有SQL類型的答案都會有所幫助。
關於在其他DBMS你的問題的一般部分有一個'PIVOT'關鍵詞 – 2010-06-14 20:40:05