通过使用SQL命令,列出idworker,来自worker table的nameworker和total_late,用于“迟到”记录超过1次的工人。
答案 0 :(得分:0)
试试这个(假设有一个Late表,当工人迟到时每次出现一条记录):
SELECT w.idworker, w.nameworker, l.total_late
FROM Worker w LEFT JOIN
(SELECT idworker, SUM(late) as total_late, COUNT(*) AS number_late
FROM Late GROUP BY idworker) l ON w.idworker = l.idworker
WHERE number_late > 1