관리자 이름으로 그룹화 된 program_code
필드를 기반으로 활성 참가자 수를 계산하고 싶습니다. 그러나 세 가지 조건이 충족되어야하는 동일한 쿼리에서 다른 것의 개수를 원합니다.여러 조건이 포함 된 사례 명세서
select manager_name,
sum (case program_code when 'F' then 1 else 0 end) as F,
sum (case program_code
when 'FS' then 1
else 0
end)
from table1
where status='AC'
group by manager_name
는 그러나 나는이 possible_ind='Y' AND date_attended is not null AND status_cd='P'
나는 모든 조건을 가진 case
성명에서 그것을 넣을 수있는 모든 참가자의 세 번째 수를 원한다. 내가 할 수있는 방법이 있니? select
절에 하위 쿼리가 있어야하나요? select
절에서 하위 쿼리로 시도했지만 manager_name
으로 그룹화하지 않습니다.
select manager_name,
sum (program_code when 'F' then 1 else 0 end) as F,
sum (case program_code
when 'FS' then 1
else 0 end),
(select count(*)
from table1
where possible_ind='Y'
and date_attended is not null
and status_cd='P') as NEW
from table1
where status='AC'
group by manager_name
'status'와'status_cd'는 서로 다른 두 열입니까? – peterm