Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Lag function problem was: Never ending activity in temp file
On 4/13/05, Gints Plivna <gints.plivna_at_gmail.com> wrote:
> The real problem generally was, to count all codes for particular persons=
,
> but in a following manner:
> if person has code 'LVA' then count it and only it.
> if person hasn't code 'LVA' then count all other codes particular person =
has.
For a question like this you probably don't need analytics at all. You can write it using simple group by functions:
SELECT id
, nvl( sum( case when code =3D 'LVA' then 1 end ), count(*) ) code_count
FROM source
GROUP BY id
Have a nice day.
--=20
Edgar
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Apr 13 2005 - 08:32:33 CDT
![]() |
![]() |