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



Jeffrey -

I don't disagree about the power of common table expressions, but I think you could have probably given a better example, since the example you gave doesn't require an intermediate table.

Ignoring the syntax error in your example (you left out the "from Batch_Sum" clause in the
second SELECT statement), your example of using a CTE was:

With Batch_Sum as (Select Batch#,Div2 from OrsBatch group by batch#,
div2) Select Batch#,Div2 from Batch_Sum group by Batch#,Div2 having
count(*) > 1

Doesn't the SQL statement below produce the same results as the one above?

Select Batch#, Div2, count(*) from OrsBatch
group by batch#, div2
having count(*) > 1

(I would probably also add an "order by Batch#, Div2" to the end of the statement to order the results)

Regards,
Steve

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.