Here is how a SELECT works in SQL … at least in theory. Real products will optimize things, but the code has to produce the same results.
The high level skeleton for a SELECT is
[WITH < cte list >] SELECT < column list > FROM < table constructor > [WHERE < row search condition >] [GROUP BY < grouping list >] [HAVING < group search condition >];
Please note that the only required clauses are SELECT and FROM. The WHERE clause is the most common additional clause. The ...