August 2017
Intermediate to advanced
214 pages
4h 31m
English
The result of all our aggregations was a single value. This single value can also be used as a scalar to perform operations on more advanced queries. These scalars are used in the form of subqueries.
A subquery is a query within a query, in simple terms. The result of one query is used to obtain the result of another query.
For example, the result obtained from the averaging query can be used to selectively print only those temperatures that were above average:
SELECT * FROM temperature WHERE value > (SELECT avg(value) FROM temperature);
In the preceding query, (SELECT avg(value) FROM temperature) is executed first, and the value obtained from it (since it is one-dimensional) ...
Read now
Unlock full access