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: Jeff Eberhard <jeff.eberhard_at_gmail.com>
Date: Mon, 23 May 2005 10:15:26 -0600
Message-ID: <f19573390505230915c42f29e@mail.gmail.com>


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:22:18 CDT

Original text of this message

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