这是我当前的表
是否有选择查询可用于显示日期的第一次和最后一次?我期待如下表所示的结果。
SELECT Day,
Date,
Department,
Name,
MIN(`Time In`) `Time In`,
MAX(`Time Out`) `Time Out`
FROM tableName
GROUP BY Day, Date, Department, Name
SELECT Day,
Date,
Department,
Name,
A.MIN_TIME,
B.MAX_TIME
FROM tableName
LEFT JOIN (SELECT Date, MIN(`Time In`) AS MIN_TIME FROM tableName GROUP BY Date) AS A
ON tableName.Date = A.Date
LEFT JOIN (SELECT Date, MAX(`Time Out`) AS MAX_TIME FROM tableName GROUP BY Date) AS B
ON tableName.Date = B.Date
GROUP BY Date