Re: SQL Help!

From: Julian Goulet <jgoulet_at_whsun2.whoi.edu>
Date: 1996/07/24
Message-ID: <4t54m7$9is_at_dilbert.whoi.edu>#1/1


Amine Y. Tarhini (atarhini_at_ringer.cs.utsa.edu) wrote:

: 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!

How about:

	select desc ... where language =
		(select max(language) ...
		where language = 2 or language = 1 ) ;

jgoulet_at_mola.gso.ure.edu Received on Wed Jul 24 1996 - 00:00:00 CEST

Original text of this message