我在下面的查询中遇到问题
SELECT DATE(jc.`date_in`) DAY,
CASE
WHEN jb.`modified_fr` <> 0 THEN ROUND(SUM(jb.`modified_fr`),1)
ELSE ROUND(SUM(jd.`fr1`),1)
END AS AmountOfHoursBooked
,ds.`name` AS dealership, d.`name` AS Department
FROM jobcard jc
LEFT JOIN job jb
ON jc.`id` = jb.`jobcard`
LEFT JOIN job_definition jd
ON jb.`job_definition` = jd.`id`
LEFT JOIN department d
ON jc.`department` = d.`id`
JOIN dealership ds
ON d.`dealership` = ds.`id`
WHERE MONTH(jc.`date_in`) = MONTH(CURRENT_DATE())
AND YEAR(jc.`date_in`) = YEAR(CURRENT_DATE())
AND jd.`fr1` <> 0
AND jc.`status` <> 5
GROUP BY DATE(jc.`date_in`),jc.`department`;
我需要它做的是如果案例回来了,它应该使用修改后的fr代替jb表中的原始fr吗?
我错过了什么?
提前致谢