db_id
stringclasses
146 values
question_en
stringlengths
3
224
hardness
stringclasses
4 values
schema_llm
stringclasses
146 values
query_llm
stringlengths
18
631
schema_llm_min
stringclasses
147 values
schema_dict
stringclasses
146 values
tables_and_columns
stringlengths
18
266
schema_reduzido
stringlengths
25
718
schema_reduzido_only_tables
stringlengths
80
2.27k
store_1
What si the youngest employee's first and last name?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT first_name , last_name FROM employees ORDER BY birth_date DESC LIMIT 1;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'last_name', 'first_name', 'birth_date'] }
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.birth_date (TIMESTAMP), )
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
List top 10 employee work longest in the company. List employee's first and last name.
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'last_name', 'first_name', 'hire_date'] }
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.hire_date (TIMESTAMP), )
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
What are the first and last names of the top 10 longest-serving employees?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'last_name', 'first_name', 'hire_date'] }
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.hire_date (TIMESTAMP), )
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
Find the number of employees whose title is IT Staff from each city?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'title', 'city'] }
TABLE employees ( employees.id (INTEGER), employees.title (VARCHAR(30)), employees.city (VARCHAR(40)), )
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
How many employees who are IT staff are from each city?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'title', 'city'] }
TABLE employees ( employees.id (INTEGER), employees.title (VARCHAR(30)), employees.city (VARCHAR(40)), )
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
Which employee manage most number of peoples? List employee's first and last name, and number of people report to that employee.
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT employees.first_name , employees.last_name , count(employees.reports_to) FROM employees JOIN employees ON employees.reports_to = employees.id GROUP BY employees.reports_to ORDER BY count(employees.reports_to) DESC LIMIT 1;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'last_name', 'first_name', 'reports_to'] }
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.reports_to (INTEGER), ) Possible JOINs: employees.reports_to = employees.id
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
What are the first and last names of all the employees and how many people report to them?
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT employees.first_name , employees.last_name , count(employees.reports_to) FROM employees JOIN employees ON employees.reports_to = employees.id GROUP BY employees.reports_to ORDER BY count(employees.reports_to) DESC LIMIT 1;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'employees': ['id', 'last_name', 'first_name', 'reports_to'] }
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.reports_to (INTEGER), ) Possible JOINs: employees.reports_to = employees.id
TABLE employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Possible JOINs: employees.reports_to = employees.id
store_1
How many orders does Lucas Mancini has?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) FROM customers JOIN invoices ON customers.id = invoices.customer_id WHERE customers.first_name = "Lucas" AND customers.last_name = "Mancini";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'customers': ['id', 'first_name', 'last_name'], 'invoices': ['id', 'customer_id'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), ) Possible JOINs: invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoices.customer_id = customers.id
store_1
How many orders does Luca Mancini have in his invoices?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) FROM customers JOIN invoices ON customers.id = invoices.customer_id WHERE customers.first_name = "Lucas" AND customers.last_name = "Mancini";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'customers': ['id', 'first_name', 'last_name'], 'invoices': ['id', 'customer_id'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), ) Possible JOINs: invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoices.customer_id = customers.id
store_1
What is the total amount of money spent by Lucas Mancini?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT sum(invoices.total) FROM customers JOIN invoices ON customers.id = invoices.customer_id WHERE customers.first_name = "Lucas" AND customers.last_name = "Mancini";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'customers': ['id', 'first_name', 'last_name'], 'invoices': ['id', 'customer_id', 'total'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.total (NUMERIC(10,2)), ) Possible JOINs: invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoices.customer_id = customers.id
store_1
How much money did Lucas Mancini spend?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT sum(invoices.total) FROM customers JOIN invoices ON customers.id = invoices.customer_id WHERE customers.first_name = "Lucas" AND customers.last_name = "Mancini";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'customers': ['id', 'first_name', 'last_name'], 'invoices': ['id', 'customer_id', 'total'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.total (NUMERIC(10,2)), ) Possible JOINs: invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoices.customer_id = customers.id
store_1
List all media types.
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT name FROM media_types;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'media_types': ['id', 'name'] }
TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Possible JOINs:
TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Possible JOINs:
store_1
What are the names of all the media types?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT name FROM media_types;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'media_types': ['id', 'name'] }
TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Possible JOINs:
TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Possible JOINs:
store_1
List all different genre types.
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT DISTINCT name FROM genres;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Possible JOINs:
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Possible JOINs:
store_1
What are the different names of the genres?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT DISTINCT name FROM genres;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Possible JOINs:
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Possible JOINs:
store_1
List the name of all playlist.
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT name FROM playlists;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'playlists': ['id', 'name'] }
TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs:
TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs:
store_1
What are the names of all the playlists?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT name FROM playlists;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'playlists': ['id', 'name'] }
TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs:
TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs:
store_1
Who is the composer of track Fast As a Shark?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT composer FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'composer'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.composer (VARCHAR(220)), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the composer who created the track "Fast As a Shark"?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT composer FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'composer'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.composer (VARCHAR(220)), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
How long does track Fast As a Shark has?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'milliseconds'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.milliseconds (INTEGER), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
How many milliseconds long is Fast As a Shark?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'milliseconds'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.milliseconds (INTEGER), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the name of tracks whose genre is Rock?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id WHERE genres.name = "Rock";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the name of all tracks in the Rock genre?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id WHERE genres.name = "Rock";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is title of album which track Balls to the Wall belongs to?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT albums.title FROM albums JOIN tracks ON albums.id = tracks.genre_id WHERE tracks.name = "Balls to the Wall";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs:
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the name of the album that has the track Ball to the Wall?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT albums.title FROM albums JOIN tracks ON albums.id = tracks.genre_id WHERE tracks.name = "Balls to the Wall";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs:
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List name of all tracks in Balls to the Wall.
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM albums JOIN tracks ON albums.id = tracks.genre_id WHERE albums.title = "Balls to the Wall";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs:
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the name of all tracks in the album named Balls to the Wall?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM albums JOIN tracks ON albums.id = tracks.genre_id WHERE albums.title = "Balls to the Wall";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs:
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List title of albums have the number of tracks greater than 10.
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT albums.title FROM albums JOIN tracks ON albums.id = tracks.album_id GROUP BY albums.id HAVING count(albums.id) > 10;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'album_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.album_id (INTEGER), ) Possible JOINs: tracks.album_id = albums.id
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of the albums that have more than 10 tracks?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT albums.title FROM albums JOIN tracks ON albums.id = tracks.album_id GROUP BY albums.id HAVING count(albums.id) > 10;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'albums': ['id', 'title'], 'tracks': ['id', 'album_id'] }
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), ) TABLE tracks ( tracks.id (INTEGER), tracks.album_id (INTEGER), ) Possible JOINs: tracks.album_id = albums.id
TABLE albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List the name of tracks belongs to genre Rock and whose media type is MPEG audio file.
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id JOIN media_types ON media_types.id = tracks.media_type_id WHERE genres.name = "Rock" AND media_types.name = "MPEG audio file";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'media_type_id', 'genre_id'], 'media_types': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.media_type_id = media_types.id tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of all Rock tracks that are stored on MPEG audio files?
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id JOIN media_types ON media_types.id = tracks.media_type_id WHERE genres.name = "Rock" AND media_types.name = "MPEG audio file";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'media_type_id', 'genre_id'], 'media_types': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.media_type_id = media_types.id tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List the name of tracks belongs to genre Rock or media type is MPEG audio file.
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id JOIN media_types ON media_types.id = tracks.media_type_id WHERE genres.name = "Rock" OR media_types.name = "MPEG audio file";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'media_type_id', 'genre_id'], 'media_types': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.media_type_id = media_types.id tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of all tracks that belong to the Rock genre and whose media type is MPEG?
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id JOIN media_types ON media_types.id = tracks.media_type_id WHERE genres.name = "Rock" OR media_types.name = "MPEG audio file";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'media_type_id', 'genre_id'], 'media_types': ['id', 'name'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.media_type_id = media_types.id tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List the name of tracks belongs to genre Rock or genre Jazz.
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id WHERE genres.name = "Rock" OR genres.name = "Jazz"
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of the tracks that are Rock or Jazz songs?
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM genres JOIN tracks ON genres.id = tracks.genre_id WHERE genres.name = "Rock" OR genres.name = "Jazz"
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'name', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List the name of all tracks in the playlists of Movies.
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlists.id = playlist_tracks.playlist_id WHERE playlists.name = "Movies";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of all tracks that are on playlists titled Movies?
hard
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlists.id = playlist_tracks.playlist_id WHERE playlists.name = "Movies";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
List the name of playlist which has number of tracks greater than 100.
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT playlists.name FROM playlist_tracks JOIN playlists ON playlists.id = playlist_tracks.playlist_id GROUP BY playlist_tracks.playlist_id HAVING count(playlist_tracks.track_id) > 100;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
store_1
What are the names of all playlists that have more than 100 tracks?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT playlists.name FROM playlist_tracks JOIN playlists ON playlists.id = playlist_tracks.playlist_id GROUP BY playlist_tracks.playlist_id HAVING count(playlist_tracks.track_id) > 100;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
store_1
List all tracks bought by customer Daan Peeters.
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN invoice_lines ON tracks.id = invoice_lines.track_id JOIN invoices ON invoices.id = invoice_lines.invoice_id JOIN customers ON customers.id = invoices.customer_id WHERE customers.first_name = "Daan" AND customers.last_name = "Peeters";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'invoice_lines': ['id', 'invoice_id', 'track_id'], 'invoices': ['id', 'customer_id'], 'customers': ['id', 'first_name', 'last_name'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the tracks that Dean Peeters bought?
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN invoice_lines ON tracks.id = invoice_lines.track_id JOIN invoices ON invoices.id = invoice_lines.invoice_id JOIN customers ON customers.id = invoices.customer_id WHERE customers.first_name = "Daan" AND customers.last_name = "Peeters";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'invoice_lines': ['id', 'invoice_id', 'track_id'], 'invoices': ['id', 'customer_id'], 'customers': ['id', 'first_name', 'last_name'] }
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), ) TABLE invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id
TABLE customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) TABLE invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) TABLE invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: customers.support_rep_id = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
How much is the track Fast As a Shark?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT unit_price FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'unit_price'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.unit_price (NUMERIC(10,2)), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What is the unit price of the tune "Fast As a Shark"?
easy
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT unit_price FROM tracks WHERE name = "Fast As a Shark";
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name', 'unit_price'] }
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.unit_price (NUMERIC(10,2)), )
TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
Find the name of tracks which are in Movies playlist but not in music playlist.
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Movies' EXCEPT SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Music'
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of all tracks that are on the Movies playlist but not in the music playlist?
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Movies' EXCEPT SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Music'
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
Find the name of tracks which are in both Movies and music playlists.
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Movies' INTERSECT SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Music'
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
What are the names of all the tracks that are in both the Movies and music playlists?
extra
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Movies' INTERSECT SELECT tracks.name FROM tracks JOIN playlist_tracks ON tracks.id = playlist_tracks.track_id JOIN playlists ON playlist_tracks.playlist_id = playlists.id WHERE playlists.name = 'Music'
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'tracks': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'], 'playlists': ['id', 'name'] }
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id
TABLE playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) TABLE playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
Find number of tracks in each genre?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) , genres.name FROM genres JOIN tracks ON genres.id = tracks.genre_id GROUP BY genres.name;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
store_1
How many tracks are in each genre?
medium
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
SELECT count(*) , genres.name FROM genres JOIN tracks ON genres.id = tracks.genre_id GROUP BY genres.name;
Table albums ( albums.id (INTEGER), albums.title (VARCHAR(160)), albums.artist_id (INTEGER), ) Table artists ( artists.id (INTEGER), artists.name (VARCHAR(120)), ) Table customers ( customers.id (INTEGER), customers.first_name (VARCHAR(40)), customers.last_name (VARCHAR(20)), customers.company (VARCHAR(80)), customers.address (VARCHAR(70)), customers.city (VARCHAR(40)), customers.state (VARCHAR(40)), customers.country (VARCHAR(40)), customers.postal_code (VARCHAR(10)), customers.phone (VARCHAR(24)), customers.fax (VARCHAR(24)), customers.email (VARCHAR(60)), customers.support_rep_id (INTEGER), ) Table employees ( employees.id (INTEGER), employees.last_name (VARCHAR(20)), employees.first_name (VARCHAR(20)), employees.title (VARCHAR(30)), employees.reports_to (INTEGER), employees.birth_date (TIMESTAMP), employees.hire_date (TIMESTAMP), employees.address (VARCHAR(70)), employees.city (VARCHAR(40)), employees.state (VARCHAR(40)), employees.country (VARCHAR(40)), employees.postal_code (VARCHAR(10)), employees.phone (VARCHAR(24)), employees.fax (VARCHAR(24)), employees.email (VARCHAR(60)), ) Table genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) Table invoice_lines ( invoice_lines.id (INTEGER), invoice_lines.invoice_id (INTEGER), invoice_lines.track_id (INTEGER), invoice_lines.unit_price (NUMERIC(10,2)), invoice_lines.quantity (INTEGER), ) Table invoices ( invoices.id (INTEGER), invoices.customer_id (INTEGER), invoices.invoice_date (TIMESTAMP), invoices.billing_address (VARCHAR(70)), invoices.billing_city (VARCHAR(40)), invoices.billing_state (VARCHAR(40)), invoices.billing_country (VARCHAR(40)), invoices.billing_postal_code (VARCHAR(10)), invoices.total (NUMERIC(10,2)), ) Table media_types ( media_types.id (INTEGER), media_types.name (VARCHAR(120)), ) Table playlist_tracks ( playlist_tracks.playlist_id (INTEGER), playlist_tracks.track_id (INTEGER), ) Table playlists ( playlists.id (INTEGER), playlists.name (VARCHAR(120)), ) Table tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: albums.artist_id = artists.id customers.support_rep_id = employees.id employees.reports_to = employees.id invoice_lines.invoice_id = invoices.id invoice_lines.track_id = tracks.id invoices.customer_id = customers.id playlist_tracks.playlist_id = playlists.id playlist_tracks.track_id = tracks.id tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
{ 'artists': ['id', 'name'], 'sqlite_sequence': ['name', 'seq'], 'albums': ['id', 'title', 'artist_id'], 'employees': ['id', 'last_name', 'first_name', 'title', 'reports_to', 'birth_date', 'hire_date', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email'], 'customers': ['id', 'first_name', 'last_name', 'company', 'address', 'city', 'state', 'country', 'postal_code', 'phone', 'fax', 'email', 'support_rep_id'], 'genres': ['id', 'name'], 'invoices': ['id', 'customer_id', 'invoice_date', 'billing_address', 'billing_city', 'billing_state', 'billing_country', 'billing_postal_code', 'total'], 'media_types': ['id', 'name'], 'tracks': ['id', 'name', 'album_id', 'media_type_id', 'genre_id', 'composer', 'milliseconds', 'bytes', 'unit_price'], 'invoice_lines': ['id', 'invoice_id', 'track_id', 'unit_price', 'quantity'], 'playlists': ['id', 'name'], 'playlist_tracks': ['playlist_id', 'track_id'] }
{ 'genres': ['id', 'name'], 'tracks': ['id', 'genre_id'] }
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.genre_id (INTEGER), ) Possible JOINs: tracks.genre_id = genres.id
TABLE genres ( genres.id (INTEGER), genres.name (VARCHAR(120)), ) TABLE tracks ( tracks.id (INTEGER), tracks.name (VARCHAR(200)), tracks.album_id (INTEGER), tracks.media_type_id (INTEGER), tracks.genre_id (INTEGER), tracks.composer (VARCHAR(220)), tracks.milliseconds (INTEGER), tracks.bytes (INTEGER), tracks.unit_price (NUMERIC(10,2)), ) Possible JOINs: tracks.album_id = albums.id tracks.media_type_id = media_types.id tracks.genre_id = genres.id
journal_committee
How many editors are there?
easy
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT count(*) FROM editor
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id'] }
TABLE editor ( editor.Editor_ID (INT), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
List the names of editors in ascending order of age.
easy
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name FROM editor ORDER BY Age ASC
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
What are the names and ages of editors?
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name , Age FROM editor
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
List the names of editors who are older than 25.
easy
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name FROM editor WHERE Age > 25
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
Show the names of editors of age either 24 or 25.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name FROM editor WHERE Age = 24 OR Age = 25
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
What is the name of the youngest editor?
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name FROM editor ORDER BY Age ASC LIMIT 1
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
What are the different ages of editors? Show each age along with the number of editors of that age.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Age , COUNT(*) FROM editor GROUP BY Age
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
Please show the most common age of editors.
hard
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Age FROM editor GROUP BY Age ORDER BY COUNT(*) DESC LIMIT 1
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'age'] }
TABLE editor ( editor.Editor_ID (INT), editor.Age (REAL), ) Possible JOINs:
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Possible JOINs:
journal_committee
Show the distinct themes of journals.
easy
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT DISTINCT Theme FROM journal
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal': ['journal_id', 'theme'] }
TABLE journal ( journal.Journal_ID (INT), journal.Theme (TEXT), ) Possible JOINs:
TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Possible JOINs:
journal_committee
Show the names of editors and the theme of journals for which they serve on committees.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.Name , journal.Theme FROM journal_committee JOIN editor ON journal_committee.Editor_ID = editor.Editor_ID JOIN journal ON journal_committee.Journal_ID = journal.Journal_ID
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal_committee': ['editor_id', 'journal_id'], 'editor': ['editor_id', 'name'], 'journal': ['journal_id', 'theme'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal ( journal.Journal_ID (INT), journal.Theme (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
For each journal_committee, find the editor name and the journal theme.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.Name , journal.Theme FROM journal_committee JOIN editor ON journal_committee.Editor_ID = editor.Editor_ID JOIN journal ON journal_committee.Journal_ID = journal.Journal_ID
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal_committee': ['editor_id', 'journal_id'], 'editor': ['editor_id', 'name'], 'journal': ['journal_id', 'theme'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal ( journal.Journal_ID (INT), journal.Theme (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
Show the names and ages of editors and the theme of journals for which they serve on committees, in ascending alphabetical order of theme.
hard
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.Name , editor.age , journal.Theme FROM journal_committee JOIN editor ON journal_committee.Editor_ID = editor.Editor_ID JOIN journal ON journal_committee.Journal_ID = journal.Journal_ID ORDER BY journal.Theme ASC
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal_committee': ['editor_id', 'journal_id'], 'editor': ['editor_id', 'name', 'age'], 'journal': ['journal_id', 'theme'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal ( journal.Journal_ID (INT), journal.Theme (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
Show the names of editors that are on the committee of journals with sales bigger than 3000.
hard
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.Name FROM journal_committee JOIN editor ON journal_committee.Editor_ID = editor.Editor_ID JOIN journal ON journal_committee.Journal_ID = journal.Journal_ID WHERE journal.Sales > 3000
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal_committee': ['editor_id', 'journal_id'], 'editor': ['editor_id', 'name'], 'journal': ['journal_id', 'sales'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal ( journal.Journal_ID (INT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
Show the id, name of each editor and the number of journal committees they are on.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.editor_id , editor.Name , COUNT(*) FROM editor JOIN journal_committee ON editor.Editor_ID = journal_committee.Editor_ID GROUP BY editor.editor_id
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name'], 'journal_committee': ['editor_id'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
Show the names of editors that are on at least two journal committees.
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT editor.Name FROM editor JOIN journal_committee ON editor.Editor_ID = journal_committee.Editor_ID GROUP BY editor.Name HAVING COUNT(*) >= 2
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name'], 'journal_committee': ['editor_id'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
List the names of editors that are not on any journal committee.
hard
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT Name FROM editor WHERE editor_id NOT IN (SELECT editor_id FROM journal_committee)
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'editor': ['editor_id', 'name'], 'journal_committee': ['editor_id'] }
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), )
TABLE editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
List the date, theme and sales of the journal which did not have any of the listed editors serving on committee.
extra
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT date , theme , sales FROM journal EXCEPT SELECT journal.date , journal.theme , journal.sales FROM journal JOIN journal_committee ON journal.journal_ID = journal_committee.journal_ID
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'journal_committee': ['editor_id', 'journal_id'] }
TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), )
TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
journal_committee
What is the average sales of the journals that have an editor whose work type is 'Photo'?
medium
Table editor ( editor.Editor_ID (INT), editor.Name (TEXT), editor.Age (REAL), ) Table journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) Table journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
SELECT avg(journal.sales) FROM journal JOIN journal_committee ON journal.journal_ID = journal_committee.journal_ID WHERE journal_committee.work_type = 'Photo'
Table editor ( editor.editor_id (INT), editor.name (TEXT), editor.age (REAL), ) Table journal ( journal.journal_id (INT), journal.date (TEXT), journal.theme (TEXT), journal.sales (INT), ) Table journal_committee ( journal_committee.editor_id (INT), journal_committee.journal_id (INT), journal_committee.work_type (TEXT), ) Possible JOINs: journal_committee.editor_id = editor.editor_id journal_committee.journal_id = journal.journal_id
{ 'journal': ['journal_id', 'date', 'theme', 'sales'], 'editor': ['editor_id', 'name', 'age'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
{ 'journal': ['journal_id', 'sales'], 'journal_committee': ['editor_id', 'journal_id', 'work_type'] }
TABLE journal ( journal.Journal_ID (INT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), )
TABLE journal ( journal.Journal_ID (INT), journal.Date (TEXT), journal.Theme (TEXT), journal.Sales (INT), ) TABLE journal_committee ( journal_committee.Editor_ID (INT), journal_committee.Journal_ID (INT), journal_committee.Work_Type (TEXT), ) Possible JOINs: journal_committee.Editor_ID = editor.Editor_ID journal_committee.Journal_ID = journal.Journal_ID
customers_card_transactions
How many accounts do we have?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of accounts.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show ids, customer ids, names for all accounts.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT account_id , customer_id , account_name FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id', 'account_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the account ids, customer ids, and account names for all the accounts?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT account_id , customer_id , account_name FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id', 'account_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show other account details for account with name 338.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT other_account_details FROM Accounts WHERE account_name = "338"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'account_name', 'other_account_details'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the other account details for the account with the name 338?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT other_account_details FROM Accounts WHERE account_name = "338"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'account_name', 'other_account_details'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the first name, last name, and phone of the customer with account name 162?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Customers.customer_phone FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id WHERE Accounts.account_name = "162"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id', 'account_name'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Give the full name and phone of the customer who has the account name 162.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Customers.customer_phone FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id WHERE Accounts.account_name = "162"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id', 'account_name'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many accounts does the customer with first name Art and last name Turcotte have?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Art" AND Customers.customer_last_name = "Turcotte"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the number of accounts that the customer with the first name Art and last name Turcotte has.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Art" AND Customers.customer_last_name = "Turcotte"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all customer ids and the number of accounts for each customer.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many accounts are there for each customer id?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the customer id and number of accounts with most accounts.
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the customer id of the customer with the most accounts, and how many accounts does this person have?
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the customer first, last name and id with least number of accounts.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Accounts.customer_id FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id GROUP BY Accounts.customer_id ORDER BY count(*) ASC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Give the full name and customer id of the customer with the fewest accounts.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Accounts.customer_id FROM Accounts JOIN Customers ON Accounts.customer_id = Customers.customer_id GROUP BY Accounts.customer_id ORDER BY count(*) ASC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the number of all customers without an account.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many customers do not have an account?
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the first names and last names of customers without any account.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_first_name , customer_last_name FROM Customers EXCEPT SELECT Customers.customer_first_name , Customers.customer_last_name FROM Customers JOIN Accounts ON Customers.customer_id = Accounts.customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the full names of customers who do not have any accounts?
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_first_name , customer_last_name FROM Customers EXCEPT SELECT Customers.customer_first_name , Customers.customer_last_name FROM Customers JOIN Accounts ON Customers.customer_id = Accounts.customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show distinct first and last names for all customers with an account.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT Customers.customer_first_name , Customers.customer_last_name FROM Customers JOIN Accounts ON Customers.customer_id = Accounts.customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the full names of customers who have accounts?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT Customers.customer_first_name , Customers.customer_last_name FROM Customers JOIN Accounts ON Customers.customer_id = Accounts.customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'], 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many customers have an account?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT customer_id) FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of customers who hold an account.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT customer_id) FROM Accounts
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'accounts': ['account_id', 'customer_id'] }
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), ) Possible JOINs:
TABLE Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many customers do we have?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id'] }
TABLE Customers ( Customers.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of customers.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id'] }
TABLE Customers ( Customers.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show ids, first names, last names, and phones for all customers.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , customer_first_name , customer_last_name , customer_phone FROM Customers
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the ids, full names, and phones of each customer?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , customer_first_name , customer_last_name , customer_phone FROM Customers
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the phone and email for customer with first name Aniyah and last name Feest?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_phone , customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone', 'customer_email'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the phone and email of the customer with the first name Aniyah and last name Feest.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_phone , customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone', 'customer_email'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the number of customer cards.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many customer cards are there?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show ids, customer ids, card type codes, card numbers for all cards.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_id , customer_id , card_type_code , card_number FROM Customers_cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs: