0
我有這個表「概述」SQL如何轉列行
+--------+---------+-------+-------+-----+-----+----+--------+
|fName |shName |project|task |owner|hours|cmpt|modified|
+--------+---------+-------+-------+-----+-----+----+--------+
|Taskday1|IBM |Website|develop|sam | 5 |25 |2/2/2016
|Taskday1|IBM |website|test |sam | 7 |20 |2/2/2016
|Taskday1|IBM |support|design |ivan | 2 |7 |2/2/2016
|Taskday2|DELL |android|config |peter| 9 |30 |3/2/2016
|Taskday2|IBM |Website|develop|sam | 9 |45 |3/2/2016
我想tranpsose列小時,CMPT,修改和重複每行3次,我的表將這個樣子
|fName |shName|project|task |owner| h/c/m |val
+--------+------+-------+-------+-----+--------+----------+
|Taskday1|IBM |Website|develop|sam |hours |5
|Taskday1|IBM |Website|develop|sam |cmpt |25
|Taskday1|IBM |Website|develop|sam |modified|2/2/2016
|Taskday1|IBM |website|test |sam |hours |7
|Taskday1|IBM |website|test |sam |cmpt |20
|Taskday1|IBM |website|test |sam |modified|2/2/2016
|Taskday1|IBM |support|design |ivan |hours |2
|Taskday1|IBM |support|design |ivan |cmpt |7
|Taskday1|IBM |support|design |ivan |modified|2/2/2016
|Taskday2|DELL |android|config |peter|hours |9
|Taskday2|DELL |android|config |peter|cmpt |30
|Taskday2|DELL |android|config |peter|modified|3/2/2016
|Taskday2|IBM |Website|develop|sam |hours |9
|Taskday2|IBM |Website|develop|sam |cmpt |45
|Taskday2|IBM |Website|develop|sam |modified|3/2/2016
任何想法,請問如何使它?非常感謝你
但是爲什麼?這似乎毫無意義。 – Takarii
做'UNION ALL',每個h/c/m有一個'select' – jarlh