Caught exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') group by neev_designation_id) as b ON a.nevid = b.id group by neev_designa' at line 77 The SQL being executed was: select -- a.id,a.nevid, a.neev_designation, sum(manpower) as manpower a.id, a.nevid, a.neev_designation, sum(manpower) as manpower -- , count(distinct user_id) AS manpowerd from (select 'all' as id, id as nevid, 'Total All' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where status='1' union select 'allsales' as id, id as nevid, 'Total All Sales' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where dept = 2 and status='1' union select 'allafsales' as id, id as nevid, 'Total All After Sales' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where dept = 1 and status='1' union select 'cm' as id, id as nevid, 'Total CM' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where role_type = 1 and status='1' union select 'cmsales' as id, id as nevid, 'Total CM Sales' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where role_type = 1 and status='1' and dept='2' union select 'cmafsales' as id, id as nevid, 'Total CM After Sales' as neev_designation, ifnull(db_order, 999) as db_order from audi_neev_designation where role_type = 1 and status='1' and dept='1' ) as a left outer join (SELECT neev_designation_id AS id, sum(manpower) AS manpower FROM user_attrition_dashboard a, dealership_master c WHERE c.dealership_id=a.dealer_id and (a.month = month('2024-09-30') and a.year=year('2024-09-30')) and c.dealership_id in () group by neev_designation_id) as b ON a.nevid = b.id group by neev_designation