Sql 将两行值合并为一行
有谁能告诉我如何在一行和两列中显示两行值、两个不同的列值。下表如下:Sql 将两行值合并为一行,sql,sql-server,sql-server-2008-r2,Sql,Sql Server,Sql Server 2008 R2,有谁能告诉我如何在一行和两列中显示两行值、两个不同的列值。下表如下: 因此,我正在寻找输出: 您可以使用带有分组依据的聚合函数来获得结果: select TestId, totalEmployees, max(ResponseScore) responseScore, max(EvalScore) EvalScore from yourTable group by TestId, totalEmployees; Test ID Total Employee
因此,我正在寻找输出:
您可以使用带有
分组依据的聚合函数来获得结果:
select TestId,
totalEmployees,
max(ResponseScore) responseScore,
max(EvalScore) EvalScore
from yourTable
group by TestId, totalEmployees;
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]
select TestId,
totalEmployees,
max(ResponseScore) responseScore,
max(EvalScore) EvalScore
from yourTable
group by TestId, totalEmployees;