snp.it
snp.it

Reputation: 522

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

Upvotes: 0

Views: 75

Answers (2)

Taryn
Taryn

Reputation: 247700

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;

Upvotes: 4

juergen d
juergen d

Reputation: 204766

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]

Upvotes: 4

Related Questions