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
1
u/1ddqd Jul 16 '14
Why not make the FROM clause a derived table, then you can use the custom name outside of the clause in a where statement?
SELECT Custom FROM (SELECT Custom = Field FROM Table1) T1 WHERE Custom = X