db_id
stringclasses 127
values | query
stringlengths 20
523
| question
stringlengths 16
224
| schema
stringclasses 127
values |
---|---|---|---|
allergy_1 | SELECT fname , lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | List the first and last name of the students who do not have any food type allergy. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT fname , lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | What is the full name of each student who is not allergic to any type of food. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT count(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | Find the number of male (sex is 'M') students who have some food type allery. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT count(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | How many male students (sex is 'M') are allergic to any type of food? | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT DISTINCT T1.fname , T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = "Milk" OR T2.Allergy = "Cat" | Find the different first names and cities of the students who have allergy to milk or cat. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT DISTINCT T1.fname , T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = "Milk" OR T2.Allergy = "Cat" | What are the distinct first names and cities of the students who have allergy either to milk or to cat? | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT count(*) FROM Student WHERE age > 18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal") | Find the number of students who are older than 18 and do not have allergy to either food or animal. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT count(*) FROM Student WHERE age > 18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal") | How many students are over 18 and do not have allergy to food type or animal type? | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT fname , major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy") | Find the first name and major of the students who are not allegry to soy. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
allergy_1 | SELECT fname , major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy") | What are the first name and major of the students who are able to consume soy? | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
INSERT into Student values ( 1001, 'Smith', 'Linda', 18, 'F', 600, 1121,'BAL');
INSERT into Has_Allergy values ( 1001, 'Cat' );
INSERT into Allergy_Type values ( 'Eggs', 'food' );
INSERT INTO Allergy_Type VALUES [('Eggs', 'food'), ('Nuts', 'food')]
INSERT INTO Has_Allergy VALUES [(1001, 'Cat'), (1002, 'Shellfish')]
INSERT INTO Student VALUES [(1001, 'Smith', 'Linda', 18, 'F', 600, 1121, 'BAL'), (1002, 'Kim', 'Tracy', 19, 'F', 600, 7712, 'HKG')] |
store_1 | SELECT billing_country , COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5; | A list of the top 5 countries by number of invoices. List country name and number of invoices. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_country , COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5; | What are the top 5 countries by number of invoices and how many do they have? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_country , SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8; | A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_country , SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8; | What are the names of the top 8 countries by total invoice size and what are those sizes? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_country , AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10; | A list of the top 10 countries by average invoice size. List country name and average invoice size. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_country , AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10; | What are the names of the countries and average invoice size of the top countries by size? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY T2.invoice_date DESC LIMIT 5; | Find out 5 customers who most recently purchased something. List customers' first and last name. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY T2.invoice_date DESC LIMIT 5; | What are the first and last names of the 5 customers who purchased something most recently? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name , COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10; | Find out the top 10 customers by total number of orders. List customers' first and last name and the number of total orders. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name , COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10; | What are the top 10 customers' first and last names by total number of orders and how many orders did they make? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name , SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10; | List the top 10 customers by total gross sales. List customers' first and last name and total gross sales. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name , SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10; | What are the top 10 customers' first and last names with the highest gross sales, and also what are the sales? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.name , COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 5; | List the top 5 genres by number of tracks. List genres name and total tracks. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.name , COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 5; | How many tracks does each genre have and what are the names of the top 5? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums; | List every album's title. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums; | What are the titles of all the albums? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums ORDER BY title; | List every album ordered by album title in ascending order. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums ORDER BY title; | What are the titles of all the albums alphabetically ascending? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title; | List every album whose title starts with A in alphabetical order. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title; | What are the titles of all albums that start with A in alphabetical order? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY total LIMIT 10; | List the customers first and last name of 10 least expensive invoices. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY total LIMIT 10; | What are the first and last names of the customers with the 10 cheapest invoices? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT sum(total) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"; | List total amount of invoice from Chicago, IL. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT sum(total) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"; | What are the total amount of money in the invoices billed from Chicago, Illinois? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT COUNT(*) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"; | List the number of invoices from Chicago, IL. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT COUNT(*) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"; | How many invoices were billed from Chicago, IL? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state; | List the number of invoices from the US, grouped by state. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state; | How many invoices were billed from each state? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1; | List the state in the US with the most invoices. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1; | What are the states with the most invoices? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) , SUM(total) FROM invoices WHERE billing_state = "CA"; | List the number of invoices and the invoice total from California. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT billing_state , COUNT(*) , SUM(total) FROM invoices WHERE billing_state = "CA"; | What is the number of invoices and total money billed in them from CA? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Aerosmith"; | List Aerosmith's albums. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Aerosmith"; | What are the titles of all the Aerosmith albums? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Billy Cobham"; | How many albums does Billy Cobham has? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Billy Cobham"; | How many albums has Billy Cobam released? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT company FROM customers WHERE first_name = "Eduardo" AND last_name = "Martins"; | Eduardo Martins is a customer at which company? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT company FROM customers WHERE first_name = "Eduardo" AND last_name = "Martins"; | What is the company where Eduardo Martins is a customer? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT email , phone FROM customers WHERE first_name = "Astrid" AND last_name = "Gruber"; | What is Astrid Gruber's email and phone number? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT email , phone FROM customers WHERE first_name = "Astrid" AND last_name = "Gruber"; | What is the email and phone number of Astrid Gruber the customer? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM customers WHERE city = "Prague"; | How many customers live in Prague city? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM customers WHERE city = "Prague"; | How many customers live in the city of Prague? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM customers WHERE state = "CA"; | How many customers in state of CA? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM customers WHERE state = "CA"; | How many customers are from California? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida"; | What country does Roberto Almeida live? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida"; | In which country does Roberto Almeida? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%' | List the name of albums that are released by aritist whose name has 'Led' | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%' | What is the title of the album that was released by the artist whose name has the phrase 'Led'? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = "Steve" AND T1.last_name = "Johnson"; | How many customers does Steve Johnson support? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = "Steve" AND T1.last_name = "Johnson"; | What is the count of customers that Steve Johnson supports? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title , phone , hire_date FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is the title, phone and hire date of Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT title , phone , hire_date FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is the title, phone number and hire date for the employee named Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.first_name , T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = "Nancy" AND T1.last_name = "Edwards"; | find the full name of employees who report to Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.first_name , T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = "Nancy" AND T1.last_name = "Edwards"; | What is the first and last name of the employee who reports to Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT address FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is the address of employee Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT address FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is Nancy Edwards's address? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1 | Find the full name of employee who supported the most number of customers. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.first_name , T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1 | What is the full name of the employee who has the most customers? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM employees WHERE country = "Canada"; | How many employees are living in Canada? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) FROM employees WHERE country = "Canada"; | How many employees live in Canada? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT phone FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is employee Nancy Edwards's phone number? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT phone FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | What is the the phone number of Nancy Edwards? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT first_name , last_name FROM employees ORDER BY birth_date DESC LIMIT 1; | Who is the youngest employee in the company? List employee's first and last name. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT first_name , last_name FROM employees ORDER BY birth_date DESC LIMIT 1; | What si the youngest employee's first and last name? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10; | List top 10 employee work longest in the company. List employee's first and last name. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT first_name , last_name FROM employees ORDER BY hire_date ASC LIMIT 10; | What are the first and last names of the top 10 longest-serving employees? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city | Find the number of employees whose title is IT Staff from each city? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT count(*) , city FROM employees WHERE title = 'IT Staff' GROUP BY city | How many employees who are IT staff are from each city? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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; | Which employee manage most number of peoples? List employee's first and last name, and number of people report to that employee. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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; | What are the first and last names of all the employees and how many people report to them? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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"; | How many orders does Lucas Mancini has? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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"; | How many orders does Luca Mancini have in his invoices? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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"; | What is the total amount of money spent by Lucas Mancini? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | 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"; | How much money did Lucas Mancini spend? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT name FROM media_types; | List all media types. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT name FROM media_types; | What are the names of all the media types? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT DISTINCT name FROM genres; | List all different genre types. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT DISTINCT name FROM genres; | What are the different names of the genres? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT name FROM playlists; | List the name of all playlist. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT name FROM playlists; | What are the names of all the playlists? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT composer FROM tracks WHERE name = "Fast As a Shark"; | Who is the composer of track Fast As a Shark? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT composer FROM tracks WHERE name = "Fast As a Shark"; | What is the composer who created the track "Fast As a Shark"? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark"; | How long does track Fast As a Shark has? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark"; | How many milliseconds long is Fast As a Shark? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock"; | What is the name of tracks whose genre is Rock? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock"; | What is the name of all tracks in the Rock genre? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"; | What is title of album which track Balls to the Wall belongs to? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"; | What is the name of the album that has the track Ball to the Wall? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"; | List name of all tracks in Balls to the Wall. | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |
store_1 | SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"; | What is the name of all tracks in the album named Balls to the Wall? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
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
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
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
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
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
);
INSERT INTO genres (name) VALUES ('Rock')
INSERT INTO media_types (name) VALUES ('MPEG audio file')
INSERT INTO artists (name) VALUES ('AC/DC')
INSERT INTO albums (title, artist_id) VALUES ('For Those About To Rock We Salute You', 1)
INSERT INTO tracks (name, album_id, media_type_id, genre_id, composer, milliseconds, bytes, unit_price) VALUES ('For Those About To Rock (We Salute You)
INSERT INTO employees (last_name, first_name, title, birth_date, hire_date, address, city, state, country, postal_code, phone, fax, email) VALUES ('Adams', 'Andrew', 'General Manager', '1962-02-18 00:00:00', '2002-08-14 00:00:00', '11120 Jasper Ave NW', 'Edmonton', 'AB', 'Canada', 'T5K 2N1', '+1 (780)
INSERT INTO customers (first_name, last_name, company, address, city, state, country, postal_code, phone, fax, email, support_rep_id) VALUES ('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)
INSERT INTO invoices (customer_id, invoice_date, billing_address, billing_city, billing_country, billing_postal_code, total) VALUES (2, '2007-01-01 00:00:00', 'Theodor-Heuss-Straße 34', 'Stuttgart', 'Germany', '70174', 1.98)
INSERT INTO invoice_lines (invoice_id, track_id, unit_price, quantity) VALUES (1, 2, 0.99, 1)
INSERT INTO playlists (name) VALUES ('Music')
INSERT INTO playlist_tracks (playlist_id, track_id) VALUES (1, 3402) |