我有一个mysql查询,我希望按名称分组几天。现在,它只是按名称分组一天,我不知道问题在哪里,你能帮忙吗。
SELECT attendance.username,
attendance.date,
attendance.time_in,
attendance.time_out,
attendance_count.count_time,
attendance_count.appendix
FROM attendance
LEFT JOIN attendance_count
ON (attendance.date=attendance_count.date)
AND (attendance.username = attendance_count.username)
WHERE (STR_TO_DATE(attendance.date, '%m/%d/%Y')
BETWEEN STR_TO_DATE('01/21/2013', '%m/%d/%Y')
AND STR_TO_DATE('02/20/2013', '%m/%d/%Y'))
GROUP BY attendance.username
答案 0 :(得分:0)
'有些日子'是不可理解的。请提供更多相关信息。
SELECT attendance.username,
attendance.date,
attendance.time_in,
attendance.time_out,
attendance_count.count_time,
attendance_count.appendix
FROM attendance
LEFT JOIN attendance_count
ON (attendance.date=attendance_count.date)
AND (attendance.username = attendance_count.username)
WHERE (STR_TO_DATE(attendance.date, '%m/%d/%Y')
BETWEEN STR_TO_DATE('01/21/2013', '%m/%d/%Y')
AND STR_TO_DATE('02/20/2013', '%m/%d/%Y'))
GROUP BY attendance.username , DAY(attendance.date)