1
如何將行列值轉換爲列值。如何將行列值轉換爲列值
例如: -
我有5行,每行有5列。我需要根據ID進行轉換。
我的查詢是:
Select id,year,height,weight,date from user_det
---------------------------------------------------------
| Id | Year | height| weight| date |
---------------------------------------------------------
| 1 | 20082009 | 122 | 23 | 4/15/2009 |
---------------------------------------------------------
| 1 | 20092010 | 135 | 39 | 3/19/2010 |
---------------------------------------------------------
| 2 | 20082009 | 132 | 20 | 2/23/2009 |
---------------------------------------------------------
| 3 | 20142015 | 133 | 28 | 2/24/2015 |
---------------------------------------------------------
如果我按ID最多2我需要結果像下表
id | year1 | height1 |weight1 | date1 | year2 | height2|weight2|date2
-------------------------------------------------------------------------------
1 |20082009| 122 | 23 |4/15/2009| 20092010 | 135 | 39 |3/19/2010
--------------------------------------------------------------------------------
2 |20082009 | 135 | 20 |2/23/2009| | | |
--------------------------------------------------------------------------------
3 |20152015 | 133 | 28 |2/24/2015| | | |
謝謝你這麼多..工作很好.. – Asm1990