Re: Query from hell

  • From: "Greg Norris" <spikey.mcmarbles@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Thu, 19 Oct 2006 13:21:41 -0500

On 10/19/06, Igor Neyman <ineyman@xxxxxxxxxxxxxx> 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. -- //www.freelists.org/webpage/oracle-l


Other related posts: