sql nested select

Solutions on MaxInterview for sql nested select by the best coders in the world

showing results for - "sql nested select"
Pablo
26 Mar 2018
1SELECT * FROM students WHERE notes > ( SELECT AVG(notes) FROM students );
2
3SELECT * FROM students WHERE class_id = (
4    SELECT id FROM classes WHERE number_of_students = (
5        SELECT MAX(number_of_students) FROM classes
6    )
7);
8
9SELECT subject, MAX(salary_by_subject.avg_salary) AS max_salary
10FROM (
11    SELECT subject, AVG(monthly_salary) AS avg_salary
12    FROM teachers
13    GROUP BY subject
14) salary_by_subject;