SELECT com_jobcard.job_card_num, sum( worked_qty ),employee.emp_name
FROM timer_completed
INNER JOIN process ON process.id = timer_completed.process_id
INNER JOIN com_jobcard ON com_jobcard.id = timer_completed.job_card_id
INNER JOIN employee ON employee.id = timer_completed.employee_id
AND process.id = '611'
AND timer_completed.group_id = '60'
AND timer_completed.report_date = DATE_ADD(CURDATE(), INTERVAL -1 DAY)
GROUP BY com_jobcard.job_card_num
UNION
SELECT job_card_num , die_qty,id FROM com_jobcard
在第一个查询中,我想在Orderby timer_completed.report_date DESC
中订购结果集,但我使用了Groupby
函数
答案 0 :(得分:0)
您可以使用
GROUP BY timer_completed.report_date, com_jobcard.job_card_num
ORDER BY timer_completed.report_date DESC