我在表 EMP_DETAILS 中有数据
EMPLOYEE_NUMBER ROLE
NSA5421 CONTRACTOR
NSA390 CONTRACTOR
E8923 EMPLOYEE
E2390 EMPLOYEE
即使没有记录,我也想显示零,我尝试了以下但没有得到想要的结果
SELECT CASE WHEN cnt IS NULL THEN 0 ELSE cnt END cnt,
CASE WHEN role IS NULL THEN '0' ELSE role END role
FROM
(SELECT COUNT (*) cnt, role
FROM emp_details
WHERE employee_number = 'E3400'
GROUP BY role)