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

Home -> Community -> Usenet -> c.d.o.server -> Re: Group By question

Re: Group By question

From: Jan <janik_at_pobox.sk>
Date: 17 Aug 2004 01:07:26 -0700
Message-ID: <81511301.0408162303.3395764b@posting.google.com>


SELECT CASE

        WHEN row_number() OVER(PARTITION BY dept ORDER BY name) = 1 THEN dept
        ELSE NULL 
        END dept, 
        name
   FROM t
     ORDER BY dept,name


Jan

dennishancy_at_eaton.com (Dennis Hancy) wrote in message news:<248587ca.0408161258.40a492cc_at_posting.google.com>...
> I have a table with this structure:
>
> SSN varchar2
> NAME varchar2
> DEPT number
>
>
> I need to produce a report that looks like this:
>
> Dept Name
> 0001 Edmund
> Miranda
> Zachary
> 0002 Stuart
> Mary
> Erica
> Kendall
> Adam
> Jamie
> 0003 Maria
> Ryan
>
> In other words, I don't want to repeat the the department number. I
> only want to see it on the first line.
>
> How do I accomplish this with SQL?
>
> Thanks.
>
>
> Dennis Hancy
> Eaton Corporation
> Cleveland, OH
Received on Tue Aug 17 2004 - 03:07:26 CDT

Original text of this message

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