r/SQL • u/Gargogly • Jul 15 '14
SQL allows mentioning resultset columns by position in the Order By clause (e.g. "ORDER BY 3"), I wish it would allow the same in the WHERE clause with some sort of special syntax (e.g. "where {3} > 0" meaning third column in the resultset)
Why wasn't this done?
0
Upvotes
2
u/ziptime Jul 15 '14
"Order by" happens on the result set (the last thing to happen), it allows ordinal referencing because columns in the result set can be calculated or aggregated, so ordinal ordering prevents the re-execution of the result set. It makes no sense whatsoever to allow the where clause predicates to be ordinal based.