Re: SQL Help!

From: Amine Y. Tarhini <atarhini_at_ringer.cs.utsa.edu>
Date: 1996/07/23
Message-ID: <4t44ds$1q8_at_ring01.cs.utsa.edu>#1/1


In article <31F55250.790C_at_kti.com> Kathy Holley <kholley_at_kti.com> writes:
>Is there a simple way of doing this:
>My table has 2 column: Language, desc
>I need to select desc where Language = 2, if no rows are returned, then I
>need to select desc where Language = 1;
>(Language =1 is the default and will always be there)
>I wrote one select statement to do it, but it seems a bit complicated, I
>use 1 sub-select with 'EXIST' and one union.
>I am sure there must be a better way to do it without having to check for
>nulls and sending a second query.
>
>Thanks in advance for your help!

  I think this should work (I'm not where I can test it):

  select decode(count(table2.desc),0,table1.desc,table2.desc)   from my_table table1, my_table table2
  where table1.language = 1

    and table2.language = 2

-- 
Amine.
atarhini_at_ringer.cs.utsa.edu

The above views are mine only ... etc. etc.
Received on Tue Jul 23 1996 - 00:00:00 CEST

Original text of this message