RE: A How-To

The decode example works like a charm!!!  Thank you so much.
 

-----Original Message-----
From: Jeff Eberhard [mailto:jeff.eberhard@xxxxxxxxx] 
Sent: Monday, May 23, 2005 11:15 AM
To: Burton, Laura
Cc: oracle-l@xxxxxxxxxxxxx
Subject: Re: A How-To

 

Something like this:

select record_key,
       max(decode(id,31,value,'')) start_time,
       max(decode(id,19,value,'')) shift,
       max(decode(id,10,value,'')) rate 
  from t1
 group by record_key;

or this:

select a.record_key, start_time, shift, rate
  from (select record_key, value start_time from t1 where id = '31') a,
       (select record_key, value shift from t1 where id = '19') b, 
       (select record_key, value rate from t1 where id = '10') c
 where a.record_key = b.record_key
   and b.record_key = c.record_key;

Of course both of these have a lot of assumptions about the data, such
as there always being a row (and only one row) for each value specified.
And I won't get into the performance pains this may create. 

 

--Jeff

On 5/23/05, Burton, Laura <BurtonL@xxxxxxxxxxx> wrote:
> I have a table which has multiple records for one individual.  Each
> record represents a different field, i.e. id 31 represents start time,
> id 19 represents shift, id 10 represents rate, etc.

> --
> http://www.freelists.org/webpage/oracle-l
> 
 


--
http://www.freelists.org/webpage/oracle-l

Other related posts: