We all know that when a case is applied in SQL, the information in the database is converted
For example, select (Case sex if 0 then ' men ' else ' end) as sex from Studentinfo
So what does it do in the aggregate function?
SELECTSex fromStudentSELECTSexCOUNT(*) asNum fromStudentGROUP bySexSELECTSex,province,COUNT(*) asNum fromStudentGROUP bysex,provinceSELECTSex,province,COUNT(province) asNum fromStudentGROUP bysex,provinceSELECTSex,province,COUNT( CaseProvince when 'Zhejiang province' Then 'Zhejiang province' ELSEProvinceEND) asNum fromStudentGROUP bySexSELECTSexCOUNT( CaseProvince when 'Jiangxi Province' Then 'Jiangxi Province' END) asJiangxi Province,COUNT( CaseProvince when 'Guangdong province' Then 'Guangdong province' END) asGuangdong Province,COUNT( CaseProvince when 'Zhejiang province' Then 'Zhejiang province' END) asZhejiang Province fromStudentGROUP bySex
The use of case-then techniques in SQL aggregate functions