Skip to content
SQL

Nested Queries

A nested SELECT is a query within a query, i.e. when you have a SELECT statement within the main SELECT.

image.png

Basera queryn på resultatet från en annan query
SELECT *
FROM students
WHERE GPA > (
SELECT AVG(GPA)
FROM students);

SELECT AVG(number_of_students)
FROM classes
WHERE teacher_id IN (
SELECT id
FROM teachers
WHERE subject = 'English' OR subject = 'History');

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.