我希望查询的计算方式像是第2周的“ Shalma”,那么第2周的“总秒数”将只求和。...我希望查询中的结果不在报表中,这有可能吗?>
显示我想要的结果:
PIC Total Seconds SortByWeek
Aida 600 2
Arifah 540000 2
Shalma 28000 1
Shalma 72036900 2
Zul 54000000 1
Zul 3000 2
Zul 100000 3
Zul 283500 4
它显示每个名称每周的总数。
答案 0 :(得分:0)
不要在分组中包含完整的日期。
SELECT PIC, Sum([Total seconds]) AS [SumOfTotalSeconds], SortByWeek, Year(date_worked_smt) AS Yr, days
FROM [union]
INNER JOIN [day] ON union.SortByWeek = day.ID
GROUP BY PIC, Year(date_worked_smt), SortByWeek, days
ORDER BY PIC, SortByWeek;