[英]How to merge two rows having same data?
i have a table with some data i want to merge the identical row ieas shown in image two identical rows having same tDateWorked,empid,jobid i want to merge this records so that OT and ST should appears in same line. 我有一个表,其中包含一些数据,我想合并同一行,即如图所示的两个具有相同tDateWorked,empid,jobid的相同行,我想合并此记录,以便OT和ST应该出现在同一行。
You can use aggregation: 您可以使用聚合:
select tDateWorked, empId, craftCodeId, jobId,
sum(ot) as ot, sum(st) as st
from t
group by tDateWorked, empId, craftCodeId, jobId;
If there are only numeric amounts in OT, ST, just try this: 如果OT,ST中只有数字量,请尝试以下操作:
SELECT
tDateWorked, empid, jobid, SUM(OT) AS OT, SUM(ST) AS ST
FROM
Table
GROUP BY
tDateWorked, empid, jobid
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.