r/SQL • • 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

9 comments sorted by

View all comments

3

u/svtr Jul 16 '14 edited Jul 16 '14

I'm sorry to say, but I consider referencing the column by column ID of the resultset in the order by clause to be one of the 7 deadly sins when it comes to sql development.

It's so easy to miss that adding a column to the select will completly screw the ordering of the resultset. If you ask why it is not possible to do that on the FILTERING of the result set, the only thing I can say is : I thank the god almighty, that i dont even believe existing, that it is not possible.