我有一个问题:
SELECT
users.name AS USER,
TIMESHEET.timesheet_date AS DAY,
TIMESHEET.STATUS AS STATUS
FROM TIMESHEET
JOIN users ON TIMESHEET.`rep_id` = users.`id`
WHERE WEEK(TIMESHEET.timesheet_date) = WEEK(CURDATE()) - 1
返回以下内容:每位员工,“上周”每个日期的工作状态:
(样品)
USER DAY STATUS
Lee Fenelon 2012-07-02 Working
Tom Price 2012-07-02 Working
Kevin Duffy 2012-07-02 Working
Keith Donnelly 2012-07-02 Working
Graham Foley 2012-07-02 Sick Leave - No Medical Cert
Dominic Mallinson 2012-07-04 1/2 Day Sick Leave - No Medical Cert
我想做的是修改上述内容,以便每周每位员工获得5个状态,即STATUS_MONDAY = Working
,STATUS_TUESDAY=Sick leave
等
总体要求的输出将是一份报告,显示每位员工每天一个柱子以及当天的工作状态。