db_id
stringclasses 127
values | query
stringlengths 20
523
| question
stringlengths 16
224
| schema
stringclasses 127
values |
---|---|---|---|
flight_1 | SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" INTERSECT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Airbus A340-300" | Show names for all employees who have certificates on both Boeing 737-800 and Airbus A340-300. | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" INTERSECT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Airbus A340-300" | What are the names of all employees who can fly both the Boeing 737-800 and the Airbus A340-300? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT name FROM Employee EXCEPT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" | Show names for all employees who do not have certificate of Boeing 737-800. | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT name FROM Employee EXCEPT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" | What are the names of all employees who are not certified to fly Boeing 737-800s? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY count(*) DESC LIMIT 1 | Show the name of aircraft which fewest people have its certificate. | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY count(*) DESC LIMIT 1 | What are the names of the aircraft that the least people are certified to fly? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid WHERE T2.distance > 5000 GROUP BY T1.aid ORDER BY count(*) >= 5 | Show the name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate. | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid WHERE T2.distance > 5000 GROUP BY T1.aid ORDER BY count(*) >= 5 | What is the name and distance of every aircraft that can cover a distance of more than 5000 and which at least 5 people can fly? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T1.name , T1.salary FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1 | what is the salary and name of the employee who has the most number of aircraft certificates? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T1.name , T1.salary FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1 | What is the salaray and name of the employee that is certified to fly the most planes? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.distance > 5000 GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1 | What is the salary and name of the employee who has the most number of certificates on aircrafts with distance more than 5000? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
flight_1 | SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.distance > 5000 GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1 | What is the salaray and name of the employee with the most certificates to fly planes more than 5000? | create table flight(
flno number(4,0) primary key,
origin varchar2(20),
destination varchar2(20),
distance number(6,0),
departure_date date,
arrival_date date,
price number(7,2),
aid number(9,0),
foreign key("aid") references `aircraft`("aid"));
create table aircraft(
aid number(9,0) primary key,
name varchar2(30),
distance number(6,0));
create table employee(
eid number(9,0) primary key,
name varchar2(30),
salary number(10,2));
create table certificate(
eid number(9,0),
aid number(9,0),
primary key(eid,aid),
foreign key("eid") references `employee`("eid"),
foreign key("aid") references `aircraft`("aid"));
INSERT INTO flight (FLNO, origin, destination, distance, departure_date, arrival_date, price,aid) VALUES (99.0,'Los Angeles','Washington D.C.',2308.0,'04/12/2005 09:30','04/12/2005 09:40',235.98, 1);
INSERT into aircraft (AID,name,distance) values ('1','Boeing 747-400','8430');
INSERT into employee (EID,name,salary) values ('242518965','James Smith','120433');
INSERT into certificate (EID,AID) values ('11564812','2'); |
allergy_1 | SELECT count(DISTINCT allergy) FROM Allergy_type | How many allergies are there? | 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(DISTINCT allergy) FROM Allergy_type | How many allergy entries are there? | 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(DISTINCT allergytype) FROM Allergy_type | How many different allergy types exist? | 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(DISTINCT allergytype) FROM Allergy_type | How many distinct allergies are there? | 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 allergytype FROM Allergy_type | Show all allergy types. | 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 allergytype FROM Allergy_type | What are the different allergy types? | 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 allergy , allergytype FROM Allergy_type | Show all allergies and their types. | 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 allergy , allergytype FROM Allergy_type | What are the allergies and their types? | 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 allergy FROM Allergy_type WHERE allergytype = "food" | Show all allergies with type 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 allergy FROM Allergy_type WHERE allergytype = "food" | What are all the different food allergies? | 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 allergytype FROM Allergy_type WHERE allergy = "Cat" | What is the type of allergy 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 allergytype FROM Allergy_type WHERE allergy = "Cat" | What is allergy type of a cat 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 count(*) FROM Allergy_type WHERE allergytype = "animal" | How many allergies have type 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 Allergy_type WHERE allergytype = "animal" | How many animal type allergies exist? | 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 allergytype , count(*) FROM Allergy_type GROUP BY allergytype | Show all allergy types and the number of allergies in each 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 allergytype , count(*) FROM Allergy_type GROUP BY allergytype | What are the allergy types and how many allergies correspond to each one? | 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 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) DESC LIMIT 1 | Which allergy type has most number of allergies? | 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 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) DESC LIMIT 1 | Which allergy type is most common? | 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 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) ASC LIMIT 1 | Which allergy type has least number of allergies? | 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 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) ASC LIMIT 1 | Which allergy type is the least common? | 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 | How many students are there? | 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 | What is the total number of students? | 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 | Show first name and last name for all students. | 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 | What are the full names of all students | 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(DISTINCT advisor) FROM Student | How many different advisors are listed? | 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(DISTINCT advisor) FROM Student | How many advisors are there? | 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 Major FROM Student | Show all majors. | 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 Major FROM Student | What are the different majors? | 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 city_code FROM Student | Show all cities where students live. | 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 city_code FROM Student | What cities do students live in? | 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 , Age FROM Student WHERE Sex = 'F' | Show first name, last name, age for all female students. Their sex is F. | 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 , Age FROM Student WHERE Sex = 'F' | What are the full names and ages for all female students whose sex is F? | 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 StuID FROM Student WHERE Sex = 'M' | Show student ids for all male students. | 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 StuID FROM Student WHERE Sex = 'M' | What are the student ids for all male students? | 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 | How many students are age 18? | 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 | How many students are 18 years old? | 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 StuID FROM Student WHERE age > 20 | Show all student ids who are older than 20. | 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 StuID FROM Student WHERE age > 20 | What are the student ids for students over 20 years old? | 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 city_code FROM Student WHERE LName = "Kim" | Which city does the student whose last name is "Kim" live in? | 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 city_code FROM Student WHERE LName = "Kim" | Give the city that the student whose family name is Kim lives in. | 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 Advisor FROM Student WHERE StuID = 1004 | Who is the advisor of student with ID 1004? | 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 Advisor FROM Student WHERE StuID = 1004 | Who advises student 1004? | 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 city_code = "HKG" OR city_code = "CHI" | How many students live in HKG or CHI? | 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 city_code = "HKG" OR city_code = "CHI" | Give the number of students living in either HKG or CHI. | 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 min(age) , avg(age) , max(age) FROM Student | Show the minimum, average, and maximum age of all students. | 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 min(age) , avg(age) , max(age) FROM Student | What is the minimum, mean, and maximum age across all students? | 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 LName FROM Student WHERE age = (SELECT min(age) FROM Student) | What is the last name of the youngest student? | 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 LName FROM Student WHERE age = (SELECT min(age) FROM Student) | Provide the last name of the youngest student. | 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 StuID FROM Student WHERE age = (SELECT max(age) FROM Student) | Show the student id of the oldest student. | 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 StuID FROM Student WHERE age = (SELECT max(age) FROM Student) | What student id corresponds to the oldest student? | 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 major , count(*) FROM Student GROUP BY major | Show all majors and corresponding number of students. | 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 major , count(*) FROM Student GROUP BY major | How many students are there for each major? | 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 major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1 | Which major has most number of students? | 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 major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1 | What is the largest major? | 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 age , count(*) FROM Student GROUP BY age | Show all ages and corresponding number of students. | 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 age , count(*) FROM Student GROUP BY age | How old is each student and how many students are each age? | 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 avg(age) , sex FROM Student GROUP BY sex | Show the average age for male and female students. | 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 avg(age) , sex FROM Student GROUP BY sex | What are the average ages for male and female students? | 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 city_code , count(*) FROM Student GROUP BY city_code | Show all cities and corresponding number of students. | 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 city_code , count(*) FROM Student GROUP BY city_code | How many students live in each city? | 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 advisor , count(*) FROM Student GROUP BY advisor | Show all advisors and corresponding number of students. | 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 advisor , count(*) FROM Student GROUP BY advisor | How many students does each advisor have? | 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 advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1 | Which advisor has most number of students? | 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 advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1 | Give the advisor with the most students. | 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 Has_allergy WHERE Allergy = "Cat" | How many students have cat allergies? | 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 Has_allergy WHERE Allergy = "Cat" | How many students are affected by cat allergies? | 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 StuID FROM Has_allergy GROUP BY StuID HAVING count(*) >= 2 | Show all student IDs who have at least two allergies. | 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 StuID FROM Has_allergy GROUP BY StuID HAVING count(*) >= 2 | What are the students ids of students who have more than one 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 StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy | What are the student ids of students who don't have any allergies? | 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 StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy | Which students are unaffected by allergies? | 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 has_allergy AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.sex = "F" AND T1.allergy = "Milk" OR T1.allergy = "Eggs" | How many female students have milk or egg allergies? | 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 has_allergy AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.sex = "F" AND T1.allergy = "Milk" OR T1.allergy = "Eggs" | How many students who are female are allergic to milk or eggs? | 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 Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" | How many students have a food 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 count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" | How many students are affected by food related allergies? | 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 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1 | Which allergy has most number of students affected? | 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 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1 | Which allergy is the most common? | 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 Allergy , count(*) FROM Has_allergy GROUP BY Allergy | Show all allergies with number of students affected. | 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 Allergy , count(*) FROM Has_allergy GROUP BY Allergy | How many students have each different 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 T2.allergytype , count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype | Show all allergy type with number of students affected. | 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 T2.allergytype , count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype | How many students are affected by each allergy 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 lname , age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") | Find the last name and age of the student who has allergy to both milk and 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 lname , age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") | What are the last names and ages of the students who are allergic to milk and 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 T1.Allergy , T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" ORDER BY T1.Allergy | What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies. | 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 T1.Allergy , T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" ORDER BY T1.Allergy | What are the allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names. | 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 , sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") | Find the first name and gender of the student who has allergy to milk but not 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 fname , sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") | What are the first name and gender of the students who have allergy to milk but can put up with cats? | 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 avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "animal") | Find the average age of the students who have allergies with food and animal types. | 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 avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "animal") | How old are the students with allergies to food and animal types on average? | 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')] |