× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here is another example that just shows a little more what you can do with subselects:

Select *
From astccdta.oetra99 t1
Where Exists( Select 1 from astccdta.oetra99 T2 Where T2.otord# = T1.Otord# and T2.ottrnc = 'CVC' Fetch First 1 Rows Only)
And Exists( Select 1 from astccdta.oetra99 T2 Where T2.otord# = T1.Otord# and T2.ottrnc = 'GRE' Fetch First 1 Rows Only)
And Not Exists( Select 1 from astccdta.oetra99 T2 Where T2.otord# = T1.Otord# and T2.ottrnc Not IN ('CVC','GRE') Fetch First 1 Rows Only)


IME using the "Exists" clause instead of the "In" clause in a scenario like this one performs better.
Especially where you don't care how many records exist with the key value, just that one exists.

Also, this query is more complicated than what has already been suggested.
It would probably only be a good solution if the subselects were more complicated and included extra table joins that you didn't want in the outer select.


Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.