All Forums Database
ksaikrishna 26 posts Joined 08/11
25 Jun 2012
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

 

dnoeth 4628 posts Joined 11/04
25 Jun 2012

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

Dieter

ksaikrishna 26 posts Joined 08/11
26 Jun 2012

Thanks for your Reply Dieter!

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

 

You must sign in to leave a comment.