instruction
stringlengths 12
244
| input
stringlengths 27
489
| output
stringlengths 18
557
| text
stringlengths 194
1.14k
|
---|---|---|---|
Find the dates on which more than one revisions were made. | CREATE TABLE Catalogs (date_of_latest_revision VARCHAR) | SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING COUNT(*) > 1 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Catalogs (date_of_latest_revision VARCHAR) Question: Find the dates on which more than one revisions were made. [/INST] SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING COUNT(*) > 1 </s> |
How many products are there in the records? | CREATE TABLE catalog_contents (Id VARCHAR) | SELECT COUNT(*) FROM catalog_contents | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE catalog_contents (Id VARCHAR) Question: How many products are there in the records? [/INST] SELECT COUNT(*) FROM catalog_contents </s> |
Name all the products with next entry ID greater than 8. | CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, next_entry_id INTEGER) | SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, next_entry_id INTEGER) Question: Name all the products with next entry ID greater than 8. [/INST] SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8 </s> |
How many aircrafts do we have? | CREATE TABLE Aircraft (Id VARCHAR) | SELECT COUNT(*) FROM Aircraft | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (Id VARCHAR) Question: How many aircrafts do we have? [/INST] SELECT COUNT(*) FROM Aircraft </s> |
Show name and distance for all aircrafts. | CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR) | SELECT name, distance FROM Aircraft | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR) Question: Show name and distance for all aircrafts. [/INST] SELECT name, distance FROM Aircraft </s> |
Show ids for all aircrafts with more than 1000 distance. | CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER) | SELECT aid FROM Aircraft WHERE distance > 1000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER) Question: Show ids for all aircrafts with more than 1000 distance. [/INST] SELECT aid FROM Aircraft WHERE distance > 1000 </s> |
How many aircrafts have distance between 1000 and 5000? | CREATE TABLE Aircraft (distance INTEGER) | SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (distance INTEGER) Question: How many aircrafts have distance between 1000 and 5000? [/INST] SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000 </s> |
What is the name and distance for aircraft with id 12? | CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR, aid VARCHAR) | SELECT name, distance FROM Aircraft WHERE aid = 12 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR, aid VARCHAR) Question: What is the name and distance for aircraft with id 12? [/INST] SELECT name, distance FROM Aircraft WHERE aid = 12 </s> |
What is the minimum, average, and maximum distance of all aircrafts. | CREATE TABLE Aircraft (distance INTEGER) | SELECT MIN(distance), AVG(distance), MAX(distance) FROM Aircraft | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (distance INTEGER) Question: What is the minimum, average, and maximum distance of all aircrafts. [/INST] SELECT MIN(distance), AVG(distance), MAX(distance) FROM Aircraft </s> |
Show the id and name of the aircraft with the maximum distance. | CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR, distance VARCHAR) | SELECT TOP 1 aid, name FROM Aircraft ORDER BY distance DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR, distance VARCHAR) Question: Show the id and name of the aircraft with the maximum distance. [/INST] SELECT TOP 1 aid, name FROM Aircraft ORDER BY distance DESC </s> |
Show the name of aircrafts with top three lowest distances. | CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR) | SELECT TOP 3 name FROM Aircraft ORDER BY distance | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR) Question: Show the name of aircrafts with top three lowest distances. [/INST] SELECT TOP 3 name FROM Aircraft ORDER BY distance </s> |
Show names for all aircrafts with distances more than the average. | CREATE TABLE Aircraft (name VARCHAR, distance INTEGER) | SELECT name FROM Aircraft WHERE distance > (SELECT AVG(distance) FROM Aircraft) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, distance INTEGER) Question: Show names for all aircrafts with distances more than the average. [/INST] SELECT name FROM Aircraft WHERE distance > (SELECT AVG(distance) FROM Aircraft) </s> |
How many employees do we have? | CREATE TABLE Employee (Id VARCHAR) | SELECT COUNT(*) FROM Employee | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (Id VARCHAR) Question: How many employees do we have? [/INST] SELECT COUNT(*) FROM Employee </s> |
Show name and salary for all employees sorted by salary. | CREATE TABLE Employee (name VARCHAR, salary VARCHAR) | SELECT name, salary FROM Employee ORDER BY salary | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, salary VARCHAR) Question: Show name and salary for all employees sorted by salary. [/INST] SELECT name, salary FROM Employee ORDER BY salary </s> |
Show ids for all employees with at least 100000 salary. | CREATE TABLE Employee (eid VARCHAR, salary INTEGER) | SELECT eid FROM Employee WHERE salary > 100000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (eid VARCHAR, salary INTEGER) Question: Show ids for all employees with at least 100000 salary. [/INST] SELECT eid FROM Employee WHERE salary > 100000 </s> |
How many employees have salary between 100000 and 200000? | CREATE TABLE Employee (salary INTEGER) | SELECT COUNT(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (salary INTEGER) Question: How many employees have salary between 100000 and 200000? [/INST] SELECT COUNT(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000 </s> |
What is the name and salary for employee with id 242518965? | CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR) | SELECT name, salary FROM Employee WHERE eid = 242518965 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR) Question: What is the name and salary for employee with id 242518965? [/INST] SELECT name, salary FROM Employee WHERE eid = 242518965 </s> |
What is average and maximum salary of all employees. | CREATE TABLE Employee (salary INTEGER) | SELECT AVG(salary), MAX(salary) FROM Employee | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (salary INTEGER) Question: What is average and maximum salary of all employees. [/INST] SELECT AVG(salary), MAX(salary) FROM Employee </s> |
Show the id and name of the employee with maximum salary. | CREATE TABLE Employee (eid VARCHAR, name VARCHAR, salary VARCHAR) | SELECT TOP 1 eid, name FROM Employee ORDER BY salary DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (eid VARCHAR, name VARCHAR, salary VARCHAR) Question: Show the id and name of the employee with maximum salary. [/INST] SELECT TOP 1 eid, name FROM Employee ORDER BY salary DESC </s> |
Show the name of employees with three lowest salaries. | CREATE TABLE Employee (name VARCHAR, salary VARCHAR) | SELECT TOP 3 name FROM Employee ORDER BY salary | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, salary VARCHAR) Question: Show the name of employees with three lowest salaries. [/INST] SELECT TOP 3 name FROM Employee ORDER BY salary </s> |
Show names for all employees with salary more than the average. | CREATE TABLE Employee (name VARCHAR, salary INTEGER) | SELECT name FROM Employee WHERE salary > (SELECT AVG(salary) FROM Employee) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, salary INTEGER) Question: Show names for all employees with salary more than the average. [/INST] SELECT name FROM Employee WHERE salary > (SELECT AVG(salary) FROM Employee) </s> |
Show the id and salary of Mark Young. | CREATE TABLE Employee (eid VARCHAR, salary VARCHAR, name VARCHAR) | SELECT eid, salary FROM Employee WHERE name = 'Mark Young' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (eid VARCHAR, salary VARCHAR, name VARCHAR) Question: Show the id and salary of Mark Young. [/INST] SELECT eid, salary FROM Employee WHERE name = 'Mark Young' </s> |
How many flights do we have? | CREATE TABLE Flight (Id VARCHAR) | SELECT COUNT(*) FROM Flight | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (Id VARCHAR) Question: How many flights do we have? [/INST] SELECT COUNT(*) FROM Flight </s> |
Show flight number, origin, destination of all flights in the alphabetical order of the departure cities. | CREATE TABLE Flight (flno VARCHAR, origin VARCHAR, destination VARCHAR) | SELECT flno, origin, destination FROM Flight ORDER BY origin | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, origin VARCHAR, destination VARCHAR) Question: Show flight number, origin, destination of all flights in the alphabetical order of the departure cities. [/INST] SELECT flno, origin, destination FROM Flight ORDER BY origin </s> |
Show all flight number from Los Angeles. | CREATE TABLE Flight (flno VARCHAR, origin VARCHAR) | SELECT flno FROM Flight WHERE origin = "Los Angeles" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, origin VARCHAR) Question: Show all flight number from Los Angeles. [/INST] SELECT flno FROM Flight WHERE origin = "Los Angeles" </s> |
Show origins of all flights with destination Honolulu. | CREATE TABLE Flight (origin VARCHAR, destination VARCHAR) | SELECT origin FROM Flight WHERE destination = "Honolulu" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (origin VARCHAR, destination VARCHAR) Question: Show origins of all flights with destination Honolulu. [/INST] SELECT origin FROM Flight WHERE destination = "Honolulu" </s> |
Show me the departure date and arrival date for all flights from Los Angeles to Honolulu. | CREATE TABLE Flight (departure_date VARCHAR, arrival_date VARCHAR, origin VARCHAR, destination VARCHAR) | SELECT departure_date, arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (departure_date VARCHAR, arrival_date VARCHAR, origin VARCHAR, destination VARCHAR) Question: Show me the departure date and arrival date for all flights from Los Angeles to Honolulu. [/INST] SELECT departure_date, arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" </s> |
Show flight number for all flights with more than 2000 distance. | CREATE TABLE Flight (flno VARCHAR, distance INTEGER) | SELECT flno FROM Flight WHERE distance > 2000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, distance INTEGER) Question: Show flight number for all flights with more than 2000 distance. [/INST] SELECT flno FROM Flight WHERE distance > 2000 </s> |
What is the average price for flights from Los Angeles to Honolulu. | CREATE TABLE Flight (price INTEGER, origin VARCHAR, destination VARCHAR) | SELECT AVG(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (price INTEGER, origin VARCHAR, destination VARCHAR) Question: What is the average price for flights from Los Angeles to Honolulu. [/INST] SELECT AVG(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" </s> |
Show origin and destination for flights with price higher than 300. | CREATE TABLE Flight (origin VARCHAR, destination VARCHAR, price INTEGER) | SELECT origin, destination FROM Flight WHERE price > 300 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (origin VARCHAR, destination VARCHAR, price INTEGER) Question: Show origin and destination for flights with price higher than 300. [/INST] SELECT origin, destination FROM Flight WHERE price > 300 </s> |
Show the flight number and distance of the flight with maximum price. | CREATE TABLE Flight (flno VARCHAR, distance VARCHAR, price VARCHAR) | SELECT TOP 1 flno, distance FROM Flight ORDER BY price DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, distance VARCHAR, price VARCHAR) Question: Show the flight number and distance of the flight with maximum price. [/INST] SELECT TOP 1 flno, distance FROM Flight ORDER BY price DESC </s> |
Show the flight number of flights with three lowest distances. | CREATE TABLE Flight (flno VARCHAR, distance VARCHAR) | SELECT TOP 3 flno FROM Flight ORDER BY distance | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, distance VARCHAR) Question: Show the flight number of flights with three lowest distances. [/INST] SELECT TOP 3 flno FROM Flight ORDER BY distance </s> |
What is the average distance and average price for flights from Los Angeles. | CREATE TABLE Flight (distance INTEGER, price INTEGER, origin VARCHAR) | SELECT AVG(distance), AVG(price) FROM Flight WHERE origin = "Los Angeles" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (distance INTEGER, price INTEGER, origin VARCHAR) Question: What is the average distance and average price for flights from Los Angeles. [/INST] SELECT AVG(distance), AVG(price) FROM Flight WHERE origin = "Los Angeles" </s> |
Show all origins and the number of flights from each origin. | CREATE TABLE Flight (origin VARCHAR) | SELECT origin, COUNT(*) FROM Flight GROUP BY origin | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (origin VARCHAR) Question: Show all origins and the number of flights from each origin. [/INST] SELECT origin, COUNT(*) FROM Flight GROUP BY origin </s> |
Show all destinations and the number of flights to each destination. | CREATE TABLE Flight (destination VARCHAR) | SELECT destination, COUNT(*) FROM Flight GROUP BY destination | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (destination VARCHAR) Question: Show all destinations and the number of flights to each destination. [/INST] SELECT destination, COUNT(*) FROM Flight GROUP BY destination </s> |
Which origin has most number of flights? | CREATE TABLE Flight (origin VARCHAR) | SELECT TOP 1 origin FROM Flight GROUP BY origin ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (origin VARCHAR) Question: Which origin has most number of flights? [/INST] SELECT TOP 1 origin FROM Flight GROUP BY origin ORDER BY COUNT(*) DESC </s> |
Which destination has least number of flights? | CREATE TABLE Flight (destination VARCHAR) | SELECT TOP 1 destination FROM Flight GROUP BY destination ORDER BY COUNT(*) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (destination VARCHAR) Question: Which destination has least number of flights? [/INST] SELECT TOP 1 destination FROM Flight GROUP BY destination ORDER BY COUNT(*) </s> |
What is the aircraft name for the flight with number 99 | CREATE TABLE Flight (aid VARCHAR, flno VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR) | SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (aid VARCHAR, flno VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR) Question: What is the aircraft name for the flight with number 99 [/INST] SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99 </s> |
Show all flight numbers with aircraft Airbus A340-300. | CREATE TABLE Flight (flno VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) | SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Flight (flno VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) Question: Show all flight numbers with aircraft Airbus A340-300. [/INST] SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300" </s> |
Show aircraft names and number of flights for each aircraft. | CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Flight (aid VARCHAR) | SELECT T2.name, COUNT(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Flight (aid VARCHAR) Question: Show aircraft names and number of flights for each aircraft. [/INST] SELECT T2.name, COUNT(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid </s> |
Show names for all aircraft with at least two flights. | CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Flight (aid VARCHAR) | SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Flight (aid VARCHAR) Question: Show names for all aircraft with at least two flights. [/INST] SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING COUNT(*) >= 2 </s> |
How many employees have certificate. | CREATE TABLE Certificate (eid VARCHAR) | SELECT COUNT(DISTINCT eid) FROM Certificate | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Certificate (eid VARCHAR) Question: How many employees have certificate. [/INST] SELECT COUNT(DISTINCT eid) FROM Certificate </s> |
Show ids for all employees who don't have a certificate. | CREATE TABLE Employee (eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR) | SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR) Question: Show ids for all employees who don't have a certificate. [/INST] SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate </s> |
Show names for all aircrafts of which John Williams has certificates. | CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Employee (eid VARCHAR, name VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR) | SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Employee (eid VARCHAR, name VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR) Question: Show names for all aircrafts of which John Williams has certificates. [/INST] SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams" </s> |
Show names for all employees who have certificate of Boeing 737-800. | CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) | 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" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) Question: Show names for all employees who have certificate of Boeing 737-800. [/INST] 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" </s> |
Show names for all employees who have certificates on both Boeing 737-800 and Airbus A340-300. | CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) | 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" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) Question: Show names for all employees who have certificates on both Boeing 737-800 and Airbus A340-300. [/INST] 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" </s> |
Show names for all employees who do not have certificate of Boeing 737-800. | CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Employee (name VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) | 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" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Employee (name VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR) Question: Show names for all employees who do not have certificate of Boeing 737-800. [/INST] 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" </s> |
Show the name of aircraft which fewest people have its certificate. | CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR) | SELECT TOP 1 T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR) Question: Show the name of aircraft which fewest people have its certificate. [/INST] SELECT TOP 1 T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY COUNT(*) DESC </s> |
Show the name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate. | CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR, distance INTEGER) | 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 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR, distance INTEGER) Question: Show the name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate. [/INST] 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 </s> |
what is the salary and name of the employee who has the most number of aircraft certificates? | CREATE TABLE Certificate (eid VARCHAR); CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR) | SELECT TOP 1 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 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Certificate (eid VARCHAR); CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR) Question: what is the salary and name of the employee who has the most number of aircraft certificates? [/INST] SELECT TOP 1 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 </s> |
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 Aircraft (aid VARCHAR, distance INTEGER); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR) | SELECT TOP 1 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 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR) Question: What is the salary and name of the employee who has the most number of certificates on aircrafts with distance more than 5000? [/INST] SELECT TOP 1 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 </s> |
How many allergies are there? | CREATE TABLE Allergy_type (allergy VARCHAR) | SELECT COUNT(DISTINCT allergy) FROM Allergy_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergy VARCHAR) Question: How many allergies are there? [/INST] SELECT COUNT(DISTINCT allergy) FROM Allergy_type </s> |
How many different allergy types exist? | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT COUNT(DISTINCT allergytype) FROM Allergy_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: How many different allergy types exist? [/INST] SELECT COUNT(DISTINCT allergytype) FROM Allergy_type </s> |
Show all allergy types. | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT DISTINCT allergytype FROM Allergy_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: Show all allergy types. [/INST] SELECT DISTINCT allergytype FROM Allergy_type </s> |
Show all allergies and their types. | CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) | SELECT allergy, allergytype FROM Allergy_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) Question: Show all allergies and their types. [/INST] SELECT allergy, allergytype FROM Allergy_type </s> |
Show all allergies with type food. | CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) | SELECT DISTINCT allergy FROM Allergy_type WHERE allergytype = "food" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) Question: Show all allergies with type food. [/INST] SELECT DISTINCT allergy FROM Allergy_type WHERE allergytype = "food" </s> |
What is the type of allergy Cat? | CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR) | SELECT allergytype FROM Allergy_type WHERE allergy = "Cat" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR) Question: What is the type of allergy Cat? [/INST] SELECT allergytype FROM Allergy_type WHERE allergy = "Cat" </s> |
How many allergies have type animal? | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT COUNT(*) FROM Allergy_type WHERE allergytype = "animal" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: How many allergies have type animal? [/INST] SELECT COUNT(*) FROM Allergy_type WHERE allergytype = "animal" </s> |
Show all allergy types and the number of allergies in each type. | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT allergytype, COUNT(*) FROM Allergy_type GROUP BY allergytype | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: Show all allergy types and the number of allergies in each type. [/INST] SELECT allergytype, COUNT(*) FROM Allergy_type GROUP BY allergytype </s> |
Which allergy type has most number of allergies? | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT TOP 1 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: Which allergy type has most number of allergies? [/INST] SELECT TOP 1 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) DESC </s> |
Which allergy type has least number of allergies? | CREATE TABLE Allergy_type (allergytype VARCHAR) | SELECT TOP 1 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_type (allergytype VARCHAR) Question: Which allergy type has least number of allergies? [/INST] SELECT TOP 1 allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) </s> |
How many students are there? | CREATE TABLE Student (Id VARCHAR) | SELECT COUNT(*) FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (Id VARCHAR) Question: How many students are there? [/INST] SELECT COUNT(*) FROM Student </s> |
Show first name and last name for all students. | CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR) | SELECT Fname, Lname FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR) Question: Show first name and last name for all students. [/INST] SELECT Fname, Lname FROM Student </s> |
How many different advisors are listed? | CREATE TABLE Student (advisor VARCHAR) | SELECT COUNT(DISTINCT advisor) FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (advisor VARCHAR) Question: How many different advisors are listed? [/INST] SELECT COUNT(DISTINCT advisor) FROM Student </s> |
Show all majors. | CREATE TABLE Student (Major VARCHAR) | SELECT DISTINCT Major FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (Major VARCHAR) Question: Show all majors. [/INST] SELECT DISTINCT Major FROM Student </s> |
Show all cities where students live. | CREATE TABLE Student (city_code VARCHAR) | SELECT DISTINCT city_code FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (city_code VARCHAR) Question: Show all cities where students live. [/INST] SELECT DISTINCT city_code FROM Student </s> |
Show first name, last name, age for all female students. Their sex is F. | CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Age VARCHAR, Sex VARCHAR) | SELECT Fname, Lname, Age FROM Student WHERE Sex = 'F' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Age VARCHAR, Sex VARCHAR) Question: Show first name, last name, age for all female students. Their sex is F. [/INST] SELECT Fname, Lname, Age FROM Student WHERE Sex = 'F' </s> |
Show student ids for all male students. | CREATE TABLE Student (StuID VARCHAR, Sex VARCHAR) | SELECT StuID FROM Student WHERE Sex = 'M' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (StuID VARCHAR, Sex VARCHAR) Question: Show student ids for all male students. [/INST] SELECT StuID FROM Student WHERE Sex = 'M' </s> |
How many students are age 18? | CREATE TABLE Student (age VARCHAR) | SELECT COUNT(*) FROM Student WHERE age = 18 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (age VARCHAR) Question: How many students are age 18? [/INST] SELECT COUNT(*) FROM Student WHERE age = 18 </s> |
Show all student ids who are older than 20. | CREATE TABLE Student (StuID VARCHAR, age INTEGER) | SELECT StuID FROM Student WHERE age > 20 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (StuID VARCHAR, age INTEGER) Question: Show all student ids who are older than 20. [/INST] SELECT StuID FROM Student WHERE age > 20 </s> |
Which city does the student whose last name is "Kim" live in? | CREATE TABLE Student (city_code VARCHAR, LName VARCHAR) | SELECT city_code FROM Student WHERE LName = "Kim" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (city_code VARCHAR, LName VARCHAR) Question: Which city does the student whose last name is "Kim" live in? [/INST] SELECT city_code FROM Student WHERE LName = "Kim" </s> |
Who is the advisor of student with ID 1004? | CREATE TABLE Student (Advisor VARCHAR, StuID VARCHAR) | SELECT Advisor FROM Student WHERE StuID = 1004 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (Advisor VARCHAR, StuID VARCHAR) Question: Who is the advisor of student with ID 1004? [/INST] SELECT Advisor FROM Student WHERE StuID = 1004 </s> |
How many students live in HKG or CHI? | CREATE TABLE Student (city_code VARCHAR) | SELECT COUNT(*) FROM Student WHERE city_code = "HKG" OR city_code = "CHI" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (city_code VARCHAR) Question: How many students live in HKG or CHI? [/INST] SELECT COUNT(*) FROM Student WHERE city_code = "HKG" OR city_code = "CHI" </s> |
Show the minimum, average, and maximum age of all students. | CREATE TABLE Student (age INTEGER) | SELECT MIN(age), AVG(age), MAX(age) FROM Student | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (age INTEGER) Question: Show the minimum, average, and maximum age of all students. [/INST] SELECT MIN(age), AVG(age), MAX(age) FROM Student </s> |
What is the last name of the youngest student? | CREATE TABLE Student (LName VARCHAR, age INTEGER) | SELECT LName FROM Student WHERE age = (SELECT MIN(age) FROM Student) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (LName VARCHAR, age INTEGER) Question: What is the last name of the youngest student? [/INST] SELECT LName FROM Student WHERE age = (SELECT MIN(age) FROM Student) </s> |
Show the student id of the oldest student. | CREATE TABLE Student (StuID VARCHAR, age INTEGER) | SELECT StuID FROM Student WHERE age = (SELECT MAX(age) FROM Student) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (StuID VARCHAR, age INTEGER) Question: Show the student id of the oldest student. [/INST] SELECT StuID FROM Student WHERE age = (SELECT MAX(age) FROM Student) </s> |
Show all majors and corresponding number of students. | CREATE TABLE Student (major VARCHAR) | SELECT major, COUNT(*) FROM Student GROUP BY major | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (major VARCHAR) Question: Show all majors and corresponding number of students. [/INST] SELECT major, COUNT(*) FROM Student GROUP BY major </s> |
Which major has most number of students? | CREATE TABLE Student (major VARCHAR) | SELECT TOP 1 major FROM Student GROUP BY major ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (major VARCHAR) Question: Which major has most number of students? [/INST] SELECT TOP 1 major FROM Student GROUP BY major ORDER BY COUNT(*) DESC </s> |
Show all ages and corresponding number of students. | CREATE TABLE Student (age VARCHAR) | SELECT age, COUNT(*) FROM Student GROUP BY age | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (age VARCHAR) Question: Show all ages and corresponding number of students. [/INST] SELECT age, COUNT(*) FROM Student GROUP BY age </s> |
Show the average age for male and female students. | CREATE TABLE Student (sex VARCHAR, age INTEGER) | SELECT AVG(age), sex FROM Student GROUP BY sex | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (sex VARCHAR, age INTEGER) Question: Show the average age for male and female students. [/INST] SELECT AVG(age), sex FROM Student GROUP BY sex </s> |
Show all cities and corresponding number of students. | CREATE TABLE Student (city_code VARCHAR) | SELECT city_code, COUNT(*) FROM Student GROUP BY city_code | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (city_code VARCHAR) Question: Show all cities and corresponding number of students. [/INST] SELECT city_code, COUNT(*) FROM Student GROUP BY city_code </s> |
Show all advisors and corresponding number of students. | CREATE TABLE Student (advisor VARCHAR) | SELECT advisor, COUNT(*) FROM Student GROUP BY advisor | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (advisor VARCHAR) Question: Show all advisors and corresponding number of students. [/INST] SELECT advisor, COUNT(*) FROM Student GROUP BY advisor </s> |
Which advisor has most number of students? | CREATE TABLE Student (advisor VARCHAR) | SELECT TOP 1 advisor FROM Student GROUP BY advisor ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (advisor VARCHAR) Question: Which advisor has most number of students? [/INST] SELECT TOP 1 advisor FROM Student GROUP BY advisor ORDER BY COUNT(*) DESC </s> |
How many students have cat allergies? | CREATE TABLE Has_allergy (Allergy VARCHAR) | SELECT COUNT(*) FROM Has_allergy WHERE Allergy = "Cat" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (Allergy VARCHAR) Question: How many students have cat allergies? [/INST] SELECT COUNT(*) FROM Has_allergy WHERE Allergy = "Cat" </s> |
Show all student IDs who have at least two allergies. | CREATE TABLE Has_allergy (StuID VARCHAR) | SELECT StuID FROM Has_allergy GROUP BY StuID HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (StuID VARCHAR) Question: Show all student IDs who have at least two allergies. [/INST] SELECT StuID FROM Has_allergy GROUP BY StuID HAVING COUNT(*) >= 2 </s> |
What are the student ids of students who don't have any allergies? | CREATE TABLE Has_allergy (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR) | SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR) Question: What are the student ids of students who don't have any allergies? [/INST] SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy </s> |
How many female students have milk or egg allergies? | CREATE TABLE Student (StuID VARCHAR, sex VARCHAR); CREATE TABLE has_allergy (StuID VARCHAR, allergy VARCHAR) | 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" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (StuID VARCHAR, sex VARCHAR); CREATE TABLE has_allergy (StuID VARCHAR, allergy VARCHAR) Question: How many female students have milk or egg allergies? [/INST] 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" </s> |
How many students have a food allergy? | CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) | SELECT COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR) Question: How many students have a food allergy? [/INST] SELECT COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" </s> |
Which allergy has most number of students affected? | CREATE TABLE Has_allergy (Allergy VARCHAR) | SELECT TOP 1 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (Allergy VARCHAR) Question: Which allergy has most number of students affected? [/INST] SELECT TOP 1 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY COUNT(*) DESC </s> |
Show all allergies with number of students affected. | CREATE TABLE Has_allergy (Allergy VARCHAR) | SELECT Allergy, COUNT(*) FROM Has_allergy GROUP BY Allergy | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (Allergy VARCHAR) Question: Show all allergies with number of students affected. [/INST] SELECT Allergy, COUNT(*) FROM Has_allergy GROUP BY Allergy </s> |
Show all allergy type with number of students affected. | CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR) | SELECT T2.allergytype, COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR) Question: Show all allergy type with number of students affected. [/INST] SELECT T2.allergytype, COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype </s> |
Find the last name and age of the student who has allergy to both milk and cat. | CREATE TABLE Has_allergy (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR) | 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") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR) Question: Find the last name and age of the student who has allergy to both milk and cat. [/INST] 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") </s> |
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 Has_allergy (Allergy VARCHAR, StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR, Fname VARCHAR); CREATE TABLE Allergy_type (Allergy VARCHAR, AllergyType VARCHAR) | 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 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (Allergy VARCHAR, StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR, Fname VARCHAR); CREATE TABLE Allergy_type (Allergy VARCHAR, AllergyType VARCHAR) Question: What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies. [/INST] 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 </s> |
Find the first name and gender of the student who has allergy to milk but not cat. | CREATE TABLE Student (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Has_allergy (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR) | 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") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Has_allergy (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR) Question: Find the first name and gender of the student who has allergy to milk but not cat. [/INST] 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") </s> |
Find the average age of the students who have allergies with food and animal types. | CREATE TABLE Student (age INTEGER, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR) | 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") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (age INTEGER, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR) Question: Find the average age of the students who have allergies with food and animal types. [/INST] 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") </s> |
List the first and last name of the students who do not have any food type allergy. | CREATE TABLE Student (fname VARCHAR, lname VARCHAR, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR) | SELECT fname, lname FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student (fname VARCHAR, lname VARCHAR, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR) Question: List the first and last name of the students who do not have any food type allergy. [/INST] SELECT fname, lname FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") </s> |
Find the number of male (sex is 'M') students who have some food type allery. | CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Student (sex VARCHAR, StuID VARCHAR) | SELECT COUNT(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Student (sex VARCHAR, StuID VARCHAR) Question: Find the number of male (sex is 'M') students who have some food type allery. [/INST] SELECT COUNT(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") </s> |
Find the different first names and cities of the students who have allergy to milk or cat. | CREATE TABLE Has_Allergy (stuid VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, city_code VARCHAR, stuid VARCHAR) | SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = "Milk" OR T2.Allergy = "Cat" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_Allergy (stuid VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, city_code VARCHAR, stuid VARCHAR) Question: Find the different first names and cities of the students who have allergy to milk or cat. [/INST] SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = "Milk" OR T2.Allergy = "Cat" </s> |
Find the number of students who are older than 18 and do not have allergy to either food or animal. | CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Student (age VARCHAR, StuID VARCHAR) | SELECT COUNT(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Student (age VARCHAR, StuID VARCHAR) Question: Find the number of students who are older than 18 and do not have allergy to either food or animal. [/INST] SELECT COUNT(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal") </s> |
Find the first name and major of the students who are not allegry to soy. | CREATE TABLE Has_allergy (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR) | SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy") | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Has_allergy (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR) Question: Find the first name and major of the students who are not allegry to soy. [/INST] SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy") </s> |