The code is applying the last WHERE clause filter to the right-most c column.
To avoid ambiguity, don’t use duplicate column names with this filter-on-alias capability, which was new in 2021.
I’ll pass this on to the dev team. Arguably, duplicate column names in this situation could be turned into an error message, or could be considered fine and be left unchanged. Making it an error would be a breaking change so we would not do that as a bug fix. It would be a design change.
But, it’s a little different from what I meant.
The above ‘duplicate column names’ was an example.
I’ll ask the question more accurately.
I knew ‘order of execution of a Query’ as 'FROM - WHERE -GROUP BY -HAVING - SELECT - ORDER BY’.
However, The query of below are OK. This query is not normal in other DBs like ORACLE.
select a/b as c, * from t1 where c > 1 ;
The normal query is as follows in ORACLE.
select a/b as c, t1.* from t1 where a/b > 1 ;
So, what I want to know is below.
‘order of execution of a Query’ in SingleStore
Query to consider because of ‘order of execution of a Query’
We follow the SQL standard for SELECT-FROM-WHERE-GROUP BY-HAVING clause definitions and order.
We recently introduced support for ability to reference previously-defined aliases in the SELECT list, and ability to filter on an alias in the WHERE clause. This is similar to Sybase IQ, Redshift, and some other database products, but is not in the SQL Standard. See a discussion of these capabilities here: