Search code examples
sqlselectsubqueryansi-sql

Are sub-SELECT's in SELECT and FROM clauses standard-compliant?


The title pretty much says it all. Under "standard-compliant" SQL I mean SQL constructs allowed in any of SQL standards.

I looked through the "Understanding SQL" book, but it mentions subqueries only inside WHERE, GROUP BY, HAVING etc. clauses, not SELECT and FROM (or maybe I'm missing something).

I know MS SQL allows sub-SELECT's in SELECT and FROM. I would like to know if it is a standard behavior. Or maybe it isn't standard, but is now implemented in major SQL databases (I have very little experience with DB's other than MS SQL)?


Solution

  • Yes. You can use a subquery as a derived table wherever you can use a table in a select statement.

    SQL ANSI 92