CASE...WHEN... and SUM() function

According to the first few digits of the ID card number, it is determined which area belongs to the sender, and the number of people who send the passengers to each area is made to make a pie chart

SELECT SUM(CASE WHEN SUBSTR(DW_CTKY_GFDPXX.ZJHM,1,4) = ‘3716’ THEN 1 ELSE 0 END)AS Binzhou, SUM(CASE WHEN SUBSTR(DW_CTKY_GFDPXX.ZJHM,1,4) != ‘3716’ AND SUBSTR(DW_CTKY_GFDPXX.ZJHM,1,2) = ‘37’ THEN 1 ELSE 0 END)AS Shandong people outside Binzhou, SUM(CASE WHEN SUBSTR(DW_CTKY_GFDPXX.ZJHM,1,2) = ‘37’ THEN 1 ELSE 0 END)AS Shandong, SUM(CASE WHEN SUBSTR(DW_CTKY_GFDPXX.ZJHM,1,2) !=’37’ THEN 1 ELSE 0 END)AS Outside the province FROM QBHCHL.DW_CTKY_GFDPXX At first, I want to use count() to count the data. As a result, mysql always reports an error. Later, I found out that the case is not used with count, but using sum() is OK, and the first few bits in mysql can use SUBSTRING. () or LEFT (), but there is no LEFT () function in ORACLE, the intercepted function is named SUBSTR (), in the name is also different from SUBSTRING ()