Re: Lag function problem was: Never ending activity in temp file

  • From: Edgar Chupit <chupit@xxxxxxxxx>
  • To: Gints Plivna <gints.plivna@xxxxxxxxx>
  • Date: Wed, 13 Apr 2005 15:28:31 +0300

On 4/13/05, Gints Plivna <gints.plivna@xxxxxxxxx> 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
--
//www.freelists.org/webpage/oracle-l

Other related posts: