I have write sql query where i am join four table with student_id is common in all four table .Please tell me what is error in my sql query.i get this error.
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COUNT(CASE WHEN account.status = 'pending' THEN 1 ELSE NULL END) AS 'pending', ' at line 1
SELECT student_branch.level_id COUNT(CASE WHEN account.status = 'pending' THEN 1 ELSE NULL END) AS 'pending',
COUNT(CASE WHEN account.status = 'paid' THEN 1 ELSE NULL END) AS 'paid',
COUNT(*) AS total FROM student LEFT JOIN account ON student.student_id=account.student_id LEFT JOIN student_branch ON student.student_id=student_branch.student_id WHERE student_branch.level_id!='' AND student.status = 'ACTIVE'
AND student_branch.branch_id = '$data' AND account.fee_active = 1 GROUP BY student_branch.level_id