SQL - SQLite - Python - サブクエリ - クエリの中にあるクエリ - 非相関サブクエリ, IN
Head First SQL ―頭とからだで覚えるSQLの基本、 Lynn Beighley(著)、 佐藤 直生(監訳)、 松永 多苗子(翻訳)、 オライリージャパンの 9章(サブクエリ - クエリの中にあるクエリ)、p.404(エクササイズ)の解答を求めてみる。
schema3.sql
select title from job_listings
where salary = (select max(salary)
from job_listings);
select mc.first_name, mc.last_name
from my_contacts mc
natural join job_current jc
where jc.salary > (select avg(salary)
from job_current);
select mc.first_name, mc.last_name
from my_contacts mc
natural join job_current
where jc.title = 'Webデザイナー'
and mc.zip_code
in (select zip
from job_listings
where title = 'Webデザイナー');
select mc.first_name, mc.last_name
from my_contacts mc
natural join job_current jc
where jc.salary = (select max(salary)
from job_current);