AS keyword is used in a number of places in SQL syntax. In this case it was
used to create a column alias. It actually is not required for that purpose
either (you could have just typed ... COUNT(*) theCount ...), but it sure
makes things more legible and understandable.
As for performance differences... running statements once in the same
session is not really an exhaustive test. You'll need to be more
comprehensive in your test scenarios. Visual Explain will definitely help.
That said, empirically speaking, CTEs (Common Table Expressions) can truly
make a positive difference in many cases, and I use them extensively. For a
statement as straightforward as yours, it shouldn't make that much of a
difference, but query optimizer is a complex beast.
Celebrating 11-Years of SQL Performance Excellence on IBM i, i5/OS and
Subject: Re: Referencing columns in temporary tables using SQL
This mailing list archive is Copyright 1997-2019 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