db_id stringclasses 146 values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146 values |
|---|---|---|---|
store_1 | What si the youngest employee's first and last name? | SELECT first_name , last_name FROM employees ORDER BY birth_date DESC LIMIT 1; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List top 10 employee work longest in the company. List employee's first and last name. | SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the first and last names of the top 10 longest-serving employees? | SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Find the number of employees whose title is IT Staff from each city? | SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How many employees who are IT staff are from each city? | SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Which employee manage most number of peoples? List employee's first and last name, and number of people report to that employee. | SELECT T2.first_name , T2.last_name , count(T1.reports_to) FROM employees AS T1 JOIN employees AS T2 ON T1.reports_to = T2.id GROUP BY T1.reports_to ORDER BY count(T1.reports_to) DESC LIMIT 1; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the first and last names of all the employees and how many people report to them? | SELECT T2.first_name , T2.last_name , count(T1.reports_to) FROM employees AS T1 JOIN employees AS T2 ON T1.reports_to = T2.id GROUP BY T1.reports_to ORDER BY count(T1.reports_to) DESC LIMIT 1; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How many orders does Lucas Mancini has? | SELECT count(*) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How many orders does Luca Mancini have in his invoices? | SELECT count(*) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the total amount of money spent by Lucas Mancini? | SELECT sum(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How much money did Lucas Mancini spend? | SELECT sum(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List all media types. | SELECT name FROM media_types; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all the media types? | SELECT name FROM media_types; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List all different genre types. | SELECT DISTINCT name FROM genres; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the different names of the genres? | SELECT DISTINCT name FROM genres; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of all playlist. | SELECT name FROM playlists; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all the playlists? | SELECT name FROM playlists; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Who is the composer of track Fast As a Shark? | SELECT composer FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the composer who created the track "Fast As a Shark"? | SELECT composer FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How long does track Fast As a Shark has? | SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How many milliseconds long is Fast As a Shark? | SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the name of tracks whose genre is Rock? | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the name of all tracks in the Rock genre? | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is title of album which track Balls to the Wall belongs to? | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the name of the album that has the track Ball to the Wall? | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List name of all tracks in Balls to the Wall. | SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the name of all tracks in the album named Balls to the Wall? | SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List title of albums have the number of tracks greater than 10. | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.album_id GROUP BY T1.id HAVING count(T1.id) > 10; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of the albums that have more than 10 tracks? | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.album_id GROUP BY T1.id HAVING count(T1.id) > 10; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of tracks belongs to genre Rock and whose media type is MPEG audio file. | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" AND T3.name = "MPEG audio file"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all Rock tracks that are stored on MPEG audio files? | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" AND T3.name = "MPEG audio file"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of tracks belongs to genre Rock or media type is MPEG audio file. | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" OR T3.name = "MPEG audio file"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all tracks that belong to the Rock genre and whose media type is MPEG? | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" OR T3.name = "MPEG audio file"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of tracks belongs to genre Rock or genre Jazz. | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock" OR T1.name = "Jazz" | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of the tracks that are Rock or Jazz songs? | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock" OR T1.name = "Jazz" | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of all tracks in the playlists of Movies. | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T3.id = T2.playlist_id WHERE T3.name = "Movies"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all tracks that are on playlists titled Movies? | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T3.id = T2.playlist_id WHERE T3.name = "Movies"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List the name of playlist which has number of tracks greater than 100. | SELECT T2.name FROM playlist_tracks AS T1 JOIN playlists AS T2 ON T2.id = T1.playlist_id GROUP BY T1.playlist_id HAVING count(T1.track_id) > 100; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all playlists that have more than 100 tracks? | SELECT T2.name FROM playlist_tracks AS T1 JOIN playlists AS T2 ON T2.id = T1.playlist_id GROUP BY T1.playlist_id HAVING count(T1.track_id) > 100; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | List all tracks bought by customer Daan Peeters. | SELECT T1.name FROM tracks AS T1 JOIN invoice_lines AS T2 ON T1.id = T2.track_id JOIN invoices AS T3 ON T3.id = T2.invoice_id JOIN customers AS T4 ON T4.id = T3.customer_id WHERE T4.first_name = "Daan" AND T4.last_name = "Peeters"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the tracks that Dean Peeters bought? | SELECT T1.name FROM tracks AS T1 JOIN invoice_lines AS T2 ON T1.id = T2.track_id JOIN invoices AS T3 ON T3.id = T2.invoice_id JOIN customers AS T4 ON T4.id = T3.customer_id WHERE T4.first_name = "Daan" AND T4.last_name = "Peeters"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How much is the track Fast As a Shark? | SELECT unit_price FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What is the unit price of the tune "Fast As a Shark"? | SELECT unit_price FROM tracks WHERE name = "Fast As a Shark"; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Find the name of tracks which are in Movies playlist but not in music playlist. | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' EXCEPT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all tracks that are on the Movies playlist but not in the music playlist? | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' EXCEPT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Find the name of tracks which are in both Movies and music playlists. | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' INTERSECT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | What are the names of all the tracks that are in both the Movies and music playlists? | SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' INTERSECT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | Find number of tracks in each genre? | SELECT count(*) , T1.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id GROUP BY T1.name; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
store_1 | How many tracks are in each genre? | SELECT count(*) , T1.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id GROUP BY T1.name; | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from artists table:
id name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE sqlite_sequence(name,seq)
3 rows from sqlite_sequence table:
name seq
genres 25
media_types 5
artists 275
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
3 Restless and Wild 2
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager NaN 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 andrew@chinookcorp.com
2 Edwards Nancy Sales Manager 1.0 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 nancy@chinookcorp.com
3 Peacock Jane Sales Support Agent 2.0 1973-08-29 00:00:00 2002-04-01 00:00:00 1111 6 Ave SW Calgary AB Canada T2P 5M5 +1 (403) 262-3443 +1 (403) 262-6712 jane@chinookcorp.com
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 5
3 François Tremblay None 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 None ftremblay@gmail.com 3
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from genres table:
id name
1 Rock
2 Jazz
3 Metal
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
3 8 2007-01-03 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
3 Protected MPEG-4 video file
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
3 2 6 0.99 1
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
)
3 rows from playlists table:
id name
1 Music
2 Movies
3 TV Shows
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
)
3 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
1 3390
|
journal_committee | How many editors are there? | SELECT count(*) FROM editor | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | List the names of editors in ascending order of age. | SELECT Name FROM editor ORDER BY Age ASC | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | What are the names and ages of editors? | SELECT Name , Age FROM editor | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | List the names of editors who are older than 25. | SELECT Name FROM editor WHERE Age > 25 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the names of editors of age either 24 or 25. | SELECT Name FROM editor WHERE Age = 24 OR Age = 25 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | What is the name of the youngest editor? | SELECT Name FROM editor ORDER BY Age ASC LIMIT 1 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | What are the different ages of editors? Show each age along with the number of editors of that age. | SELECT Age , COUNT(*) FROM editor GROUP BY Age | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Please show the most common age of editors. | SELECT Age FROM editor GROUP BY Age ORDER BY COUNT(*) DESC LIMIT 1 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the distinct themes of journals. | SELECT DISTINCT Theme FROM journal | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the names of editors and the theme of journals for which they serve on committees. | SELECT T2.Name , T3.Theme FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | For each journal_committee, find the editor name and the journal theme. | SELECT T2.Name , T3.Theme FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
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. | SELECT T2.Name , T2.age , T3.Theme FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID ORDER BY T3.Theme ASC | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the names of editors that are on the committee of journals with sales bigger than 3000. | SELECT T2.Name FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID WHERE T3.Sales > 3000 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the id, name of each editor and the number of journal committees they are on. | SELECT T1.editor_id , T1.Name , COUNT(*) FROM editor AS T1 JOIN journal_committee AS T2 ON T1.Editor_ID = T2.Editor_ID GROUP BY T1.editor_id | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | Show the names of editors that are on at least two journal committees. | SELECT T1.Name FROM editor AS T1 JOIN journal_committee AS T2 ON T1.Editor_ID = T2.Editor_ID GROUP BY T1.Name HAVING COUNT(*) >= 2 | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | List the names of editors that are not on any journal committee. | SELECT Name FROM editor WHERE editor_id NOT IN (SELECT editor_id FROM journal_committee) | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | List the date, theme and sales of the journal which did not have any of the listed editors serving on committee. | SELECT date , theme , sales FROM journal EXCEPT SELECT T1.date , T1.theme , T1.sales FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
journal_committee | What is the average sales of the journals that have an editor whose work type is 'Photo'? | SELECT avg(T1.sales) FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID WHERE T2.work_type = 'Photo' | CREATE TABLE "journal" (
"Journal_ID" int,
"Date" text,
"Theme" text,
"Sales" int,
PRIMARY KEY ("Journal_ID")
)
3 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
4 October 7, 2001 at Baltimore Ravens 7494
CREATE TABLE "editor" (
"Editor_ID" int,
"Name" text,
"Age" real,
PRIMARY KEY ("Editor_ID")
)
3 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
3 Marek Siudym 21.0
CREATE TABLE "journal_committee" (
"Editor_ID" int,
"Journal_ID" int,
"Work_Type" text,
PRIMARY KEY ("Editor_ID","Journal_ID"),
FOREIGN KEY ("Editor_ID") REFERENCES `editor`("Editor_ID"),
FOREIGN KEY ("Journal_ID") REFERENCES `journal`("Journal_ID")
)
3 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
6 11 Photo
|
customers_card_transactions | How many accounts do we have? | SELECT count(*) FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of accounts. | SELECT count(*) FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show ids, customer ids, names for all accounts. | SELECT account_id , customer_id , account_name FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the account ids, customer ids, and account names for all the accounts? | SELECT account_id , customer_id , account_name FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show other account details for account with name 338. | SELECT other_account_details FROM Accounts WHERE account_name = "338" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the other account details for the account with the name 338? | SELECT other_account_details FROM Accounts WHERE account_name = "338" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the first name, last name, and phone of the customer with account name 162? | SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = "162" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Give the full name and phone of the customer who has the account name 162. | SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = "162" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many accounts does the customer with first name Art and last name Turcotte have? | SELECT count(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the number of accounts that the customer with the first name Art and last name Turcotte has. | SELECT count(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all customer ids and the number of accounts for each customer. | SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many accounts are there for each customer id? | SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the customer id and number of accounts with most accounts. | SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the customer id of the customer with the most accounts, and how many accounts does this person have? | SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the customer first, last name and id with least number of accounts. | SELECT T2.customer_first_name , T2.customer_last_name , T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Give the full name and customer id of the customer with the fewest accounts. | SELECT T2.customer_first_name , T2.customer_last_name , T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the number of all customers without an account. | SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts) | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many customers do not have an account? | SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts) | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the first names and last names of customers without any account. | SELECT customer_first_name , customer_last_name FROM Customers EXCEPT SELECT T1.customer_first_name , T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the full names of customers who do not have any accounts? | SELECT customer_first_name , customer_last_name FROM Customers EXCEPT SELECT T1.customer_first_name , T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show distinct first and last names for all customers with an account. | SELECT DISTINCT T1.customer_first_name , T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the full names of customers who have accounts? | SELECT DISTINCT T1.customer_first_name , T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many customers have an account? | SELECT count(DISTINCT customer_id) FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of customers who hold an account. | SELECT count(DISTINCT customer_id) FROM Accounts | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many customers do we have? | SELECT count(*) FROM Customers | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of customers. | SELECT count(*) FROM Customers | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show ids, first names, last names, and phones for all customers. | SELECT customer_id , customer_first_name , customer_last_name , customer_phone FROM Customers | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the ids, full names, and phones of each customer? | SELECT customer_id , customer_first_name , customer_last_name , customer_phone FROM Customers | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the phone and email for customer with first name Aniyah and last name Feest? | SELECT customer_phone , customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the phone and email of the customer with the first name Aniyah and last name Feest. | SELECT customer_phone , customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the number of customer cards. | SELECT count(*) FROM Customers_cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many customer cards are there? | SELECT count(*) FROM Customers_cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show ids, customer ids, card type codes, card numbers for all cards. | SELECT card_id , customer_id , card_type_code , card_number FROM Customers_cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.