ivoa-std / ADQL

Astronomical Data Query Language Standard
https://wiki.ivoa.net/twiki/bin/view/IVOA/ADQL
Creative Commons Attribution Share Alike 4.0 International
7 stars 7 forks source link

CTEs are subqueries #57

Closed mbtaylor closed 3 years ago

mbtaylor commented 3 years ago

Should section 2.2.1 "Subqueries" mention WITH clauses (CTEs) alongside WHERE and FROM clauses as another place where subqueries are permitted?

gmantele commented 3 years ago

Indeed, it makes sense to mention CTEs in this section.

I guess something like the following, just at the end of this section:

If supported by the implementation, table subqueries MAY be used for declaring named result set in the WITH clause of the main query:

WITH subsample AS (
    SELECT alpha_source.id FROM alpha_source WHERE id < 10
)
SELECT
    alpha_source.id
FROM
    alpha_source INNER JOIN subsample USING(id)
WHERE
    alpha_source.id >= 5