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: need query of wildly unormalized table

Re: need query of wildly unormalized table

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Thu, 11 Oct 2007 17:57:17 +0200
Message-ID: <470E47DD.1010309@gmail.com>


EdStevens schrieb:
> Platform: Oracle 10.2.0.1.0
>
> Given a table with a structure something like this
>
> key_field varchar2(10)
> award_1 varchar2(4)
> award_2 varchar2(4)
> award_3 varchar2(4)
> <snip repeatage>
> award_30 varchar2(4)
>
> The requirement is to report all 'key_field' where any of the
> 'award_*' columns contain a selected value. The crude way is
>
> SELECT key_field
> FROM .....
> WHERE
> award_1 = 'AAAA' or
> award_2 = 'AAAA' or
> award_3 = 'AAAA' or
> <snip repeatage>
> award_30 = 'AAAA' or
>
> Surely there is a more elegant way of dealing with this mess, but I'm
> having trouble getting my head wrapped around it. Unfortunately,
> normalizing the data (what a concept!) is beyond my control, other
> than the possibility of using a temp table.
>
> Ideas?
>

where 'AAAA' = ANY (award_1,award_2,award_3...,award_30) Not substantially shorter, but imho easier to read

Best regards

Maxim Received on Thu Oct 11 2007 - 10:57:17 CDT

Original text of this message

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