2013-05-28 191 views
0

任何人都可以請告訴我如何顯示兩行值,兩行不同列值兩列。下面是表:將兩行數值合併爲一個


Test ID  Total Employees Response Score  Eval Score 
1    7     4.24    0 
1    7      0    4.78 
2    13     4.52    0 
2    13      0    4.89 

所以我要尋找的輸出:


Test ID  Total Employees Response Score  Eval Score 
1    7     4.24    4.78 
2    13     4.52    4.89 

回答

4

可以使用聚合函數與GROUP BY得到結果:

select TestId, 
    totalEmployees, 
    max(ResponseScore) responseScore, 
    max(EvalScore) EvalScore 
from yourTable 
group by TestId, totalEmployees; 
+0

我覺得很蠢...........謝謝!!!!!!!!!!! –

4
select [Test ID], 
     [Total Employees], 
     max([Response Score]) as [Response Score], 
     max([Eval Score]) as [Eval Score] 
from your_table 
group by [Test ID], [Total Employees] 
+0

謝謝你的回覆! –