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: how to make 2 rows into 1 row?

Re: how to make 2 rows into 1 row?

From: Knut Talman <knut.talman_at_mytoys.de>
Date: Tue, 02 Jul 2002 19:21:43 +0200
Message-ID: <3D21E127.E0B71470@mytoys.de>


julio wrote:
>
> We have 2 rows of data. They are for the same item but have different data
> and we want 1 row. Does Sajar know?
>
> Terminal rating1 rating2
> 1234 23 34
>
> Terminal addr prior adv
> 1243 54 67 39
>
> we want
>
> Terminal rating1 rating2 addr prior adv
> 1243 23 34 54 67 39

If it's only one row, I'd do an update manually and delete the second row. If not you need a value you can rely on:

if rating1 is always NULL where addr, prior and adv are not NULL:

update tablename a set rating1=
  (select rating1 from tablename
    where Terminal=a.Terminal
      and rating1 is not null),
  rating2=
  (select rating2 from tablename
    where Terminal=a.Terminal
      and rating2 is not null)
where Terminal=1234
  and rating1 is null
  and rating2 is null;

This is just an untested quick hack but I'm sure you get the picture.

Hth,

Knut Received on Tue Jul 02 2002 - 12:21:43 CDT

Original text of this message

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