News for hackers. Stuff that matters.
Re:Easy Steps to a Complete Understanding of SQL by chris_wot on Tuesday September 03, 2013 @09:58AM (#6320956)
Those are expressions. They only work once you have picked the table(s) - FROM - and determined the rows you want returned - WHERE. The query then groups and orders the results and calculates the scalar value of COUNT(1) which it repeats on every row, then it determines the weekday for every row for the column created_at and uses that value for output.
Re:Easy Steps to a Complete Understanding of SQL by jcampbell1 on Tuesday September 03, 2013 @10:46AM (#6321256)
My point is that a better explanation of the execution ordering is:

FROM, JOIN, WHERE, SELECT, GROUP BY, HAVING, DISTINCT, UNION, ORDER BY, LIMIT.

The author has SELECT after the GROUP BY and HAVING, which doesn't make sense because GROUP BY is aware of expressions in the SELECT statement. Grouping and filtering happens after selection.

Re:Easy Steps to a Complete Understanding of SQL by lukaseder on Tuesday September 03, 2013 @10:56AM (#6321313)
(I had to correct myself)

SELECT is evaluated after GROUP BY, at least in most databases that implement SQL correctly. SQL Server's documentation nicely explains this:

http://technet.microsoft.com/en-us/library/ms189499.aspx

Skip to "Logical Processing Order of the SELECT statement".

MySQL, PostgreSQL, and SQLite behave differently, though!