SQL组合行

问题描述 投票:0回答:1

我有一张桌子,显示常规时间和加班时间。由于旧系统导出数据的方式,在许多支付期间,我最终得到了每个支付期间的2条记录 - 一条用于常规小时,另一条用于加班。在SQL中是否有一种简单的方法可以将加班时间与常规时间一起添加到同一记录中,然后删除加班记录?

sql
1个回答
1
投票

您应该能够使用聚合:

select accountingid, payperiodenddate,
       sum(regularhours) as regularhours, sum(othours) as othours
from t
group by accountingid, payperiodenddate;
© www.soinside.com 2019 - 2024. All rights reserved.