Tag Info

New answers tagged

1

The syntax restrictions mentioned by @a_horse_with_no_name are merely a reflection of how the query is logically processed by the SQL database engine: The FROM clause is processed and all required tables are identified, after possibly resolving view definitions. The WHERE clause is processed, applying predicates to the table rows. The GROUP BY clause is ...


1

Why does the alias not work in the GROUP BY clause? Because these simply are the syntax rules. A column alias may be used in the ORDER BY clause but not in the GROUP BY clause. If you look at the syntax diagrams this becomes obvious: The order by clause is defined as: So after the ORDER BY an expression is allowed, a position (order by 1) or a ...



Top 50 recent answers are included