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

2 回答 2

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]
于 2013-05-28T16:50:21.730 回答
4

您可以使用带有 a 的聚合函数GROUP BY来获取结果:

select TestId, 
   totalEmployees, 
   max(ResponseScore) responseScore, 
   max(EvalScore) EvalScore
from yourTable
group by TestId, totalEmployees;
于 2013-05-28T16:50:37.817 回答