我有一个查询:
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
等
所需的总体输出将是一份报告,该报告显示每个员工每天一栏及其当天的工作状态。