The error in the SQL syntax is likely caused by the use of the keyword "on" before the function call "getDeptName(ss.site_area)= b.areaName". To fix the error, you should remove the "on" keyword and modify the syntax accordingly. Here's an example of how the SQL query may be corrected:\n\nSELECT t1.rpt_dd, b.areaName, COUNT(*) AS count\nFROM site_situation AS ss\nJOIN site AS s ON ss.site_id = s.site_id\nJOIN (\n SELECT site_id, MAX(rpt_dd) AS max_rpt_dd\n FROM site_situation\n GROUP BY site_id\n) AS t1 ON ss.site_id = t1.site_id AND ss.rpt_dd = t1.max_rpt_dd\nLEFT JOIN (\n SELECT site_area, areaName\n FROM base_site\n WHERE b.parent_id = '00'\n) AS b ON getDeptName(ss.site_area) = b.areaName\nGROUP BY t1.rpt_dd, b.areaName;


原文地址: https://www.cveoy.top/t/topic/p9bc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录