Subject | [ib-support] Re: SQL ORDER BY problem |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-07-25T21:53:52Z |
>What's wrong with this in a SELECT stored proc, or did I not follow yourlogic?
Nice try Andrew, but you do not need any SP for this question.
>EXISTS is my favourite keyword :-)Exactly, use it directly within the SQL:
SELECT * FROM TableA
WHERE C1 = 'X'
AND (C2 = 'Y' OR NOT EXISTS(SELECT 1 FROM TableA B WHERE B.C1 = 'X' AND
B.C2='Y'))
No reason to make simple things complicated (though if speed is a big issue,
your solution may be slightly faster since you only execute EXISTS once),
Set
-well beaten by Andrew in the slogan competition