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: Query from hell

Re: Query from hell

From: Greg Norris <spikey.mcmarbles_at_gmail.com>
Date: Thu, 19 Oct 2006 13:21:41 -0500
Message-ID: <d4beff360610191121w55ffb5f9l74379e4c3269543d@mail.gmail.com>


On 10/19/06, Igor Neyman <ineyman_at_perceptron.com> wrote:
> Is there some criteria affecting which county_factor_id ('01', '02', etc.)
> is concatenated? I couldn't find one looking at your query, must be
> missing something.
>
> But, if there is one, you could use DECODE instead of 67 UNIONs:

The CASE statement is another option, which can be useful if the conditions don't lend themselves to simple matching.

SQL> create table test (
  2 col1 varchar2(10)
  3 );

Table created.

SQL> insert into test values ('abc');

1 row created.

SQL> insert into test values ('123');

1 row created.

SQL> select col1 || case when col1 = 'abc' then 'def'

  2                      when col1 = '123' then '456'
  3                 end col1
  4     from test;

COL1



abcdef
123456
-- 
"I'm too sexy for my code." - Awk Sed Fred.
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Oct 19 2006 - 13:21:41 CDT

Original text of this message

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