| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: counting zeros
Just a quick glance, so it may not work.  Basically moving the rep and nonrep
into a column by group:
select substr(j.deptid,0,2) as Groups,
sum(decode(substr(j.sal_admin_plan,0,1),'R',1,0)) RepCount,
sum(decode(substr(j.sal_admin_plan,0,1),'R',0,1)) NonRepCount
 from ps_job j
where j.empl_rcd_nbr = '0'
  and j.effdt = (SELECT MAX(j1.effdt)
     FROM ps_job j1
    WHERE j1.emplid = j.emplid
  AND j1.effdt <= '1-APR-2001')
  AND j.effseq = (SELECT MAX(j1.effseq)
          FROM ps_job j1
         WHERE j1.emplid = j.emplid
           AND j1.effdt = j.effdt)
Might have to wrap the sum() in an nvl to translate nulls to 0 - should work! Received on Tue Mar 12 2002 - 09:28:37 CST
![]()  | 
![]()  |