我有一个表,其中有些数据我想合并同一行 即,如图像中所示,两个相同的行具有相同的tDateWorked,empid,jobid 我想合并此记录,以便OT和ST应该出现在同一行。
答案 0 :(得分:1)
您可以使用聚合:
select tDateWorked, empId, craftCodeId, jobId,
sum(ot) as ot, sum(st) as st
from t
group by tDateWorked, empId, craftCodeId, jobId;
答案 1 :(得分:0)
如果OT,ST中只有数字量,请尝试以下操作:
SELECT
tDateWorked, empid, jobid, SUM(OT) AS OT, SUM(ST) AS ST
FROM
Table
GROUP BY
tDateWorked, empid, jobid