SQL QUERY help

Database
Enthusiast

SQL QUERY help

Hi All,

I have following data in table level.

Can some one helpmeon this?

Category          barcode       local code      value

abc                   111                    1              18

abc                   111                    2               20

abc                   111                    3               15

abc                   222                    1               17

abc                   222                    2               18

Output:

Category          barcode       local code      value

abc                   111                    1               18

                                                   2               20

                                                   3               15

                         222                    1               17

                                                   2               18

Thanks,

Saikrishna.k

2 REPLIES
Junior Contributor

Re: SQL QUERY help

For a report in BTEQ it's a simple ".SUPPRESS 1,2", but otherwise...

You could use (untested):

select

case

  when row_number() over (partition by Category order by Category, barcode, localcode) = 1

  then category

else '' end,

select

case

  when row_number() over (partition by Category, barcode order by Category, barcode, localcode) = 1

  then category

else '' end

...

order by Category, barcode, localcode;

But IMHO this seems to be formatting for a kind of report and this should be done on the client side.

Dieter

Enthusiast

Re: SQL QUERY help

Thanks for your Reply Dieter!

Yes, I need this query to test one of the report in my project.