Re: using case statements within a where clause

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Roji. P. Thomas (lazydragon_at_nowhere.com)
Date: 09/07/04


Date: Tue, 7 Sep 2004 21:13:36 +0530

Vinny,

Try

 SELECT g.fruit_type,
  g.cost,
 g.origin_id
 from groceries g
 where cost is not null
 and fruit_type <> 'orange'
OR exists(select 1 from origin o where
     g.orgin_id = o.id and o.state is not null)

<untested>

-- 
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Vinny Vinn" <VinnyVinn@discussions.microsoft.com> wrote in message
news:793868FC-009B-407E-B143-C371279AA1F6@microsoft.com...
> I have a search condition, an exist statement,which i would like to be
> checked but only in certain instatnces(based on a value which is being
> returned in the same query)  for example
> if fruit_type is orange then i would like to do the existance test
otherwise
> i would like to skip the existance test.
> The preceding case statement will not work! Is it possible to run an
> existance test
> based on a value returned in the select statement?
> Any Ideas would be appreciated!
>
> Thanks,
>  Vinny