× 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.




I have two SQL statements that produce the same results. They both have
about the same process time (1 second or less).

Which do you think should perform better or do you see where I could
improve? This is going into a web app and similar statements will also be
processed. Statement 1 uses a join to bring in the records needed, while
the other uses the EXISTS statement.

Select Sum(temp1), Sum(temp2), Sum(temp3),sum(temp4)
From
(SELECT RCUNNO Unit, max(RCTCONC) temp1, max(RCCALL) temp2,
max(RCPRAIS) temp3, max(RCCC) temp4
FROM FILEA b
JOIN FILEB c ON b.RCCONO = c.CONO
And c.CONO = '001'
And c.RNUM = 1
And c.ANum = 12
And b.RCUNNO = c.UNNO
WHERE RCUNKN = '0'
AND RCRNUM = 0
AND RCANUM = 0
AND RCFYR = 2008
AND RCFPD = 2
Group By b.RCUNNO ) a

-- OR

Select Sum(temp1), Sum(temp2), Sum(temp3),sum(temp4)
From
(SELECT RCUNNO Unit, max(RCTCONC) temp1, max(RCCALL) temp2,
max(RCPRAIS) temp3, max(RCCC) temp4
FROM FILEA b
WHERE RCCONO = '001'
AND RCUNKN = '0'
AND RCRNUM = 0
AND RCANUM = 0
AND Exists(Select '1' From FILEB Where b.RCCono = CONO And
Rnum = 1 And Anum = 12 And b.RCUNNO = UNNO)
AND RCFYR = 2008
AND RCFPD = 2
Group By b.RCUNNO ) a

Thank you in advance.


Michael Schutte
Admin Professional
Bob Evans Farms, Inc.
"The Secret's the Sauce! Enjoy our new Bob-B-Q Pulled Pork Knife & Fork
Sandwich!"


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.