理论上,家在 GROUP BY 之后SELECT c.WORK_DATE,
c.ONDUTY_TIME,
c.OFFDUTY_TIME,
group_concat(d.start_date) startDate,
group_concat(d.end_date) endDate,
group_concat(d.duty_explain) dutyExplain,
group_concat(d.duty_status_id) dutyStatusId
FROM (SELECT a.WORK_DATE,
a.ONDUTY_TIME,
a.OFFDUTY_TIME,
b.DUTY_APPLY_ID
FROM (SELECT ONDUTY_TIME,
OFFDUTY_TIME,
WORK_DATE,
SEQ_ID
FROM tbl_duty
WHERE USER_ID = 'xiaodong'
AND WORK_DATE >= '2012/3/20 星期二 0:00:00'
AND WORK_DATE <= '2012/3/29 星期二 0:00:00') a
LEFT JOIN
tbl_duty_to_apply b
ON a.seq_id = b.DUTY_ID) c
LEFT JOIN
tbl_duty_apply d
ON c.DUTY_APPLY_ID = d.SEQ_ID
GROUP BY c.WORK_DATE
ORDER BY c.WORK_DATE DESC;