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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: A How-To

RE: A How-To

From: Burton, Laura <BurtonL_at_frmaint.com>
Date: Mon, 23 May 2005 11:21:01 -0500
Message-ID: <B5E0B4818A669C49A9C22199D9C389F80391865D@MAIL.frmaint.com>


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

-----Original Message-----
From: Jeff Eberhard [mailto:jeff.eberhard_at_gmail.com] Sent: Monday, May 23, 2005 11:15 AM
To: Burton, Laura
Cc: oracle-l_at_freelists.org
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_at_frmaint.com> 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
Received on Mon May 23 2005 - 12:25:49 CDT

Original text of this message

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