跪求各位大佬这样的语句如何拼接,日期时间 按周自动更新的最终查询语句如下 SELECT t1.timeDay as 日期, t2.频次, t1.车间 FROM ( select a.timeDAy,b.车间 from (SELECT date_format(lastWeek.`timeDay`,'%Y-%m-%d') as 'timeDay' FROM ( select DATE_SUB(NOW(),interval 13 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 12 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 11 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 10 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 9 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 8 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 7 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 6 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 5 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 4 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 3 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 2 day) as 'timeDay' UNION ALL select DATE_SUB(NOW(),interval 1 day) as 'timeDay' ) as lastWeek WHERE YEARWEEK(lastWeek.`timeDay`,1) = YEARWEEK(NOW(),1)-1 ) a,(SELECTsubstring_index(substring_index( a.车间,',',b.help_topic_id + 1 ),',' ,- 1) AS 车间FROM(select '111车间,112车间,113车间,211车间,212车间' as 车间) aJOIN mysql.help_topic b ON b.help_topic_id <(length(a.车间) - length( replace(a.车间, ',', '') ) + 1)) b ) as t1 LEFT JOIN(SELECT 日期,SUM(频次) AS 频次,车间,部门,公司FROM ( SELECT DATE_FORMAT(检验日期, '%Y-%m-%d') AS 日期, SUM(抽检不合格数量) as 频次, 车间, 部门, 公司 FROM 报检台账 WHERE YEARWEEK(检验日期,1) = YEARWEEK(NOW(),1)-1 AND 车间!='外协车间' AND 公司='${=GETUSERDEPARTMENTS(1)}' GROUP BY DATE_FORMAT(检验日期, '%Y-%m-%d'), 车间 UNION ALL SELECT DATE_FORMAT(反馈日期, '%Y-%m-%d') AS 日期, SUM(不良数量) as 频次, 责任车间 AS 车间, 部门责任 AS 部门, 责任公司 AS 公司 FROM 反馈台账 WHERE YEARWEEK(反馈日期,1) = YEARWEEK(NOW(),1)-1 AND 责任车间!='外协车间' AND 责任公司='${=GETUSERDEPARTMENTS(1)}' GROUP BY DATE_FORMAT(反馈日期, '%Y-%m-%d'), 车间 ) A GROUP BY 日期, 车间 ) as t2 ON t1.timeDay = t2.日期 AND t1.车间 =t2.车间ORDER BYt1.timeDay,t1.车间