Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Easy SQL question

Re: Easy SQL question

From: Thomas Devallé <tdevalle_at_hotmail.com>
Date: Wed, 20 Feb 2002 22:49:39 +0100
Message-ID: <3c741a36$0$75150$ba620e4c@news.skynet.be>


Use NVL...
"Mark Hamilton" <user_at_user.net> a écrit dans le message news: u77v53ckc8i316_at_corp.supernews.com...
>
> Oracle v7.3.3
> The following SQL Statement is to count employees per department, per Rep
> status. How can I get the count to show if the count is zero '0'?
>
> -- BEGIN SQL --
> select j.deptid
> ,decode(substr(j.sal_admin_plan,1,1)
> ,'R','Rep'
> ,'Non-Rep') as Rep
> ,count (j.emplid) as Count
> from ps_job j
> where j.effdt = (select max(j1.effdt)
> from ps_job j1
> where j1.emplid = j.emplid
> and j1.effdt >= '1-JAN-2001')
> and j.effseq = (select max(j1.effseq)
> from ps_job j1
> where j1.emplid = j.emplid
> and j1.effdt = j.effdt)
> and j.action <> 'TER'
> group by j.deptid, decode(substr(j.sal_admin_plan,1,1)
> ,'R', 'Rep'
> ,'Non-Rep')
> order by j.deptid, Rep DESC;
> -- END SQL --
>
> Thanks,
>
> Mark Hamilton
>
>
Received on Wed Feb 20 2002 - 15:49:39 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US