简体   繁体   中英

Two row values into one

Can anyone please tell me how I can have show two row values , two different column value in one row an two columns. Below is the table :


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 

So I am looking for the output:


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]

You can use an aggregate function with a GROUP BY to get the result:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM