Hi all,
I'm trying to find the male-to-female ratio in each department. The situation is empSEX is a VARCHAR2 datatype.
I need "M" / "F" as a new column.
SELECT Dept,
count(empID),
TO_NUMBER(count(case when empSEX = 'M' then 1 else null end)) M,
TO_NUMBER(count(case when empSEX = 'F' then 1 else null end)) F
FROM EMPLOYEE
WHERE Date=’200909’;
I'm not sure if I should be using the TO_NUMBER function instead of CONVERT or something else. Also, what happens when there are no females in a department, can't divide by zero?
As always any help will be greatly appreciated. Thanks.