任何人都可以告诉我如何显示两行值,一行两列不同的列值和两列。以下是表格:
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
答案 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]
答案 1 :(得分:4)
您可以使用带有GROUP BY
的聚合函数来获得结果:
select TestId,
totalEmployees,
max(ResponseScore) responseScore,
max(EvalScore) EvalScore
from yourTable
group by TestId, totalEmployees;