簡體   English   中英

將兩行值合二為一

[英]Two row values into one

誰能告訴我如何在一行和兩列中顯示兩個行值,兩個不同的列值。 下表是:


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

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]

您可以將聚合函數與GROUP BY以獲取結果:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM