I have a table with column state_assigned
I have a select that shows me counts of all state_assigned
of active employees with hire dates between x and y:
select
nvl(state_assigned, 'Unknown') state_assigned,
count(nvl(state_assigned, 0)) cnt
from emps
where hire_date between '16-NOV-2009' and '28-DEC-2009'
and active_flag='Y'
group by state_assigned
order by state_assigned
This gives me a list of all the state_assigned of active staff like:
Alabama 2
Florida 10
Georgia 5
Texas 1
I need my select to list of all the states in the table and only count the ones with active employees.. so i end up with a list of all state_assigned and if no active
employees have that state_assigned then it gives a count of 0 so my list is like:
Alabama 2
Florida 10
Georgia 5
South Carolina 0
Texas 1
(basically they want the report to always list all the states for formatting purposes even if nobody is assigned)
I think i need to use a case statement in the select but havnt been able to work it out so far.
If somebody could point me in the right direction i would appreciate it?
I have a select that shows me counts of all state_assigned
of active employees with hire dates between x and y:
select
nvl(state_assigned, 'Unknown') state_assigned,
count(nvl(state_assigned, 0)) cnt
from emps
where hire_date between '16-NOV-2009' and '28-DEC-2009'
and active_flag='Y'
group by state_assigned
order by state_assigned
This gives me a list of all the state_assigned of active staff like:
Alabama 2
Florida 10
Georgia 5
Texas 1
I need my select to list of all the states in the table and only count the ones with active employees.. so i end up with a list of all state_assigned and if no active
employees have that state_assigned then it gives a count of 0 so my list is like:
Alabama 2
Florida 10
Georgia 5
South Carolina 0
Texas 1
(basically they want the report to always list all the states for formatting purposes even if nobody is assigned)
I think i need to use a case statement in the select but havnt been able to work it out so far.
If somebody could point me in the right direction i would appreciate it?