SQLite Forum

Aliased function result with the same name issue
I had a vague thought that this was discussed before and finally found that the referencing of aliases in where and join clauses is not in the SQL standard. Actually both PostgreSQL and MySQL doesn't like it. I was wrong about MySql since I didn't test a query with a changed alias name. So, current tests for

  <blockquote>select trim(txt) as txtalias from testspaces where txtalias <> ''</blockquote>

  <blockquote>Unknown column 'txtalias' in 'where clause'</blockquote>
  <blockquote>column "txtalias" does not exist</blockquote>

So, as long as it's an sqlite-only feature, it follows its own rules, no question asked. 

My vague feeling was probably originated from an answer at the maillist from Igor Tandetnik many years ago that even quoted elsewhere sometimes without attribution 

Per SQL standard, column aliases can be referenced in ORDER BY, GROUP BY and HAVING clauses. As an extension, SQLite also allows them in WHERE and JOIN ON clauses, but again, such usage is non-standard (though very convenient at times). Neither the standard nor SQLite implementation allow referencing aliases in the SELECT clause.

Still can't find anything related at sqlite.org (including requirements)