context
stringlengths 27
489
| answer
stringlengths 18
557
| question
stringlengths 12
244
|
---|---|---|
CREATE TABLE tweets (text VARCHAR, createdate VARCHAR)
|
SELECT text FROM tweets ORDER BY createdate
|
List the text of all tweets in the order of date.
|
CREATE TABLE tweets (uid VARCHAR); CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR)
|
SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid
|
Find the name of each user and number of tweets tweeted by each of them.
|
CREATE TABLE user_profiles (name VARCHAR, partitionid VARCHAR, uid VARCHAR); CREATE TABLE tweets (uid VARCHAR)
|
SELECT T1.name, T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) < 2
|
Find the name and partition id for users who tweeted less than twice.
|
CREATE TABLE tweets (uid VARCHAR); CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR)
|
SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) > 1
|
Find the name of the user who tweeted more than once, and number of tweets tweeted by them.
|
CREATE TABLE user_profiles (followers INTEGER, UID VARCHAR); CREATE TABLE tweets (followers INTEGER, UID VARCHAR)
|
SELECT AVG(followers) FROM user_profiles WHERE NOT UID IN (SELECT UID FROM tweets)
|
Find the average number of followers for the users who do not have any tweet.
|
CREATE TABLE user_profiles (followers INTEGER, UID VARCHAR); CREATE TABLE tweets (followers INTEGER, UID VARCHAR)
|
SELECT AVG(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
|
Find the average number of followers for the users who had some tweets.
|
CREATE TABLE user_profiles (followers INTEGER)
|
SELECT MAX(followers), SUM(followers) FROM user_profiles
|
Find the maximum and total number of followers of all users.
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR)
|
SELECT DISTINCT (catalog_entry_name) FROM catalog_contents
|
Find the names of all the catalog entries.
|
CREATE TABLE Attribute_Definitions (attribute_data_type VARCHAR)
|
SELECT attribute_data_type FROM Attribute_Definitions GROUP BY attribute_data_type HAVING COUNT(*) > 3
|
Find the list of attribute data types possessed by more than 3 attribute definitions.
|
CREATE TABLE Attribute_Definitions (attribute_data_type VARCHAR, attribute_name VARCHAR)
|
SELECT attribute_data_type FROM Attribute_Definitions WHERE attribute_name = "Green"
|
What is the attribute data type of the attribute with name "Green"?
|
CREATE TABLE Catalog_Structure (catalog_level_name VARCHAR, catalog_level_number INTEGER)
|
SELECT catalog_level_name, catalog_level_number FROM Catalog_Structure WHERE catalog_level_number BETWEEN 5 AND 10
|
Find the name and level of catalog structure with level between 5 and 10.
|
CREATE TABLE catalogs (catalog_publisher VARCHAR)
|
SELECT DISTINCT (catalog_publisher) FROM catalogs WHERE catalog_publisher LIKE "%Murray%"
|
Find all the catalog publishers whose name contains "Murray"
|
CREATE TABLE catalogs (catalog_publisher VARCHAR)
|
SELECT catalog_publisher FROM catalogs GROUP BY catalog_publisher ORDER BY COUNT(*) DESC LIMIT 1
|
Which catalog publisher has published the most catalogs?
|
CREATE TABLE catalogs (catalog_name VARCHAR, date_of_publication VARCHAR, catalog_id VARCHAR); CREATE TABLE catalog_structure (catalog_id VARCHAR)
|
SELECT t1.catalog_name, t1.date_of_publication FROM catalogs AS t1 JOIN catalog_structure AS t2 ON t1.catalog_id = t2.catalog_id WHERE catalog_level_number > 5
|
Find the names and publication dates of all catalogs that have catalog level number greater than 5.
|
CREATE TABLE Catalog_Contents_Additional_Attributes (catalog_entry_id VARCHAR, attribute_value VARCHAR); CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, catalog_entry_id VARCHAR); CREATE TABLE Catalog_Contents_Additional_Attributes (attribute_value VARCHAR)
|
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.attribute_value = (SELECT attribute_value FROM Catalog_Contents_Additional_Attributes GROUP BY attribute_value ORDER BY COUNT(*) DESC LIMIT 1)
|
What are the entry names of catalog with the attribute possessed by most entries.
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, price_in_dollars VARCHAR)
|
SELECT catalog_entry_name FROM catalog_contents ORDER BY price_in_dollars DESC LIMIT 1
|
What is the entry name of the most expensive catalog (in USD)?
|
CREATE TABLE catalog_structure (catalog_level_name VARCHAR, catalog_level_number VARCHAR); CREATE TABLE catalog_contents (catalog_level_number VARCHAR, price_in_dollars VARCHAR)
|
SELECT t2.catalog_level_name FROM catalog_contents AS t1 JOIN catalog_structure AS t2 ON t1.catalog_level_number = t2.catalog_level_number ORDER BY t1.price_in_dollars LIMIT 1
|
What is the level name of the cheapest catalog (in USD)?
|
CREATE TABLE catalog_contents (price_in_euros INTEGER)
|
SELECT AVG(price_in_euros), MIN(price_in_euros) FROM catalog_contents
|
What are the average and minimum price (in Euro) of all products?
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, height VARCHAR)
|
SELECT catalog_entry_name FROM catalog_contents ORDER BY height DESC LIMIT 1
|
What is the product with the highest height? Give me the catalog entry name.
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, capacity VARCHAR)
|
SELECT catalog_entry_name FROM catalog_contents ORDER BY capacity LIMIT 1
|
Find the name of the product that has the smallest capacity.
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, product_stock_number VARCHAR)
|
SELECT catalog_entry_name FROM catalog_contents WHERE product_stock_number LIKE "2%"
|
Find the names of all the products whose stock number starts with "2".
|
CREATE TABLE Catalog_Contents_Additional_Attributes (catalog_entry_id VARCHAR, catalog_level_number VARCHAR); CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, catalog_entry_id VARCHAR)
|
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8"
|
Find the names of catalog entries with level number 8.
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, LENGTH VARCHAR, width VARCHAR)
|
SELECT catalog_entry_name FROM catalog_contents WHERE LENGTH < 3 OR width > 5
|
Find the names of the products with length smaller than 3 or height greater than 5.
|
CREATE TABLE Catalog_Contents_Additional_Attributes (attribute_id VARCHAR, attribute_value VARCHAR); CREATE TABLE Attribute_Definitions (attribute_name VARCHAR, attribute_id VARCHAR)
|
SELECT t1.attribute_name, t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0
|
Find the name and attribute ID of the attribute definitions with attribute value 0.
|
CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, capacity VARCHAR, price_in_dollars INTEGER)
|
SELECT catalog_entry_name, capacity FROM Catalog_Contents WHERE price_in_dollars > 700
|
Find the name and capacity of products with price greater than 700 (in USD).
|
CREATE TABLE Catalogs (date_of_latest_revision VARCHAR)
|
SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING COUNT(*) > 1
|
Find the dates on which more than one revisions were made.
|
CREATE TABLE catalog_contents (Id VARCHAR)
|
SELECT COUNT(*) FROM catalog_contents
|
How many products are there in the records?
|
CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, next_entry_id INTEGER)
|
SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8
|
Name all the products with next entry ID greater than 8.
|
CREATE TABLE Aircraft (Id VARCHAR)
|
SELECT COUNT(*) FROM Aircraft
|
How many aircrafts do we have?
|
CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR)
|
SELECT name, distance FROM Aircraft
|
Show name and distance for all aircrafts.
|
CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER)
|
SELECT aid FROM Aircraft WHERE distance > 1000
|
Show ids for all aircrafts with more than 1000 distance.
|
CREATE TABLE Aircraft (distance INTEGER)
|
SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
|
How many aircrafts have distance between 1000 and 5000?
|
CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR, aid VARCHAR)
|
SELECT name, distance FROM Aircraft WHERE aid = 12
|
What is the name and distance for aircraft with id 12?
|
CREATE TABLE Aircraft (distance INTEGER)
|
SELECT MIN(distance), AVG(distance), MAX(distance) FROM Aircraft
|
What is the minimum, average, and maximum distance of all aircrafts.
|
CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR, distance VARCHAR)
|
SELECT aid, name FROM Aircraft ORDER BY distance DESC LIMIT 1
|
Show the id and name of the aircraft with the maximum distance.
|
CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR)
|
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
|
Show the name of aircrafts with top three lowest distances.
|
CREATE TABLE Aircraft (name VARCHAR, distance INTEGER)
|
SELECT name FROM Aircraft WHERE distance > (SELECT AVG(distance) FROM Aircraft)
|
Show names for all aircrafts with distances more than the average.
|
CREATE TABLE Employee (Id VARCHAR)
|
SELECT COUNT(*) FROM Employee
|
How many employees do we have?
|
CREATE TABLE Employee (name VARCHAR, salary VARCHAR)
|
SELECT name, salary FROM Employee ORDER BY salary
|
Show name and salary for all employees sorted by salary.
|
CREATE TABLE Employee (eid VARCHAR, salary INTEGER)
|
SELECT eid FROM Employee WHERE salary > 100000
|
Show ids for all employees with at least 100000 salary.
|
CREATE TABLE Employee (salary INTEGER)
|
SELECT COUNT(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000
|
How many employees have salary between 100000 and 200000?
|
CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR)
|
SELECT name, salary FROM Employee WHERE eid = 242518965
|
What is the name and salary for employee with id 242518965?
|
CREATE TABLE Employee (salary INTEGER)
|
SELECT AVG(salary), MAX(salary) FROM Employee
|
What is average and maximum salary of all employees.
|
CREATE TABLE Employee (eid VARCHAR, name VARCHAR, salary VARCHAR)
|
SELECT eid, name FROM Employee ORDER BY salary DESC LIMIT 1
|
Show the id and name of the employee with maximum salary.
|
CREATE TABLE Employee (name VARCHAR, salary VARCHAR)
|
SELECT name FROM Employee ORDER BY salary LIMIT 3
|
Show the name of employees with three lowest salaries.
|
CREATE TABLE Employee (name VARCHAR, salary INTEGER)
|
SELECT name FROM Employee WHERE salary > (SELECT AVG(salary) FROM Employee)
|
Show names for all employees with salary more than the average.
|
CREATE TABLE Employee (eid VARCHAR, salary VARCHAR, name VARCHAR)
|
SELECT eid, salary FROM Employee WHERE name = 'Mark Young'
|
Show the id and salary of Mark Young.
|
CREATE TABLE Flight (Id VARCHAR)
|
SELECT COUNT(*) FROM Flight
|
How many flights do we have?
|
CREATE TABLE Flight (flno VARCHAR, origin VARCHAR, destination VARCHAR)
|
SELECT flno, origin, destination FROM Flight ORDER BY origin
|
Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.
|
CREATE TABLE Flight (flno VARCHAR, origin VARCHAR)
|
SELECT flno FROM Flight WHERE origin = "Los Angeles"
|
Show all flight number from Los Angeles.
|
CREATE TABLE Flight (origin VARCHAR, destination VARCHAR)
|
SELECT origin FROM Flight WHERE destination = "Honolulu"
|
Show origins of all flights with destination 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"
|
Show me the departure date and arrival date for all flights from Los Angeles to Honolulu.
|
CREATE TABLE Flight (flno VARCHAR, distance INTEGER)
|
SELECT flno FROM Flight WHERE distance > 2000
|
Show flight number for all flights with more than 2000 distance.
|
CREATE TABLE Flight (price INTEGER, origin VARCHAR, destination VARCHAR)
|
SELECT AVG(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
|
What is the average price for flights from Los Angeles to Honolulu.
|
CREATE TABLE Flight (origin VARCHAR, destination VARCHAR, price INTEGER)
|
SELECT origin, destination FROM Flight WHERE price > 300
|
Show origin and destination for flights with price higher than 300.
|
CREATE TABLE Flight (flno VARCHAR, distance VARCHAR, price VARCHAR)
|
SELECT flno, distance FROM Flight ORDER BY price DESC LIMIT 1
|
Show the flight number and distance of the flight with maximum price.
|
CREATE TABLE Flight (flno VARCHAR, distance VARCHAR)
|
SELECT flno FROM Flight ORDER BY distance LIMIT 3
|
Show the flight number of flights with three lowest distances.
|
CREATE TABLE Flight (distance INTEGER, price INTEGER, origin VARCHAR)
|
SELECT AVG(distance), AVG(price) FROM Flight WHERE origin = "Los Angeles"
|
What is the average distance and average price for flights from Los Angeles.
|
CREATE TABLE Flight (origin VARCHAR)
|
SELECT origin, COUNT(*) FROM Flight GROUP BY origin
|
Show all origins and the number of flights from each origin.
|
CREATE TABLE Flight (destination VARCHAR)
|
SELECT destination, COUNT(*) FROM Flight GROUP BY destination
|
Show all destinations and the number of flights to each destination.
|
CREATE TABLE Flight (origin VARCHAR)
|
SELECT origin FROM Flight GROUP BY origin ORDER BY COUNT(*) DESC LIMIT 1
|
Which origin has most number of flights?
|
CREATE TABLE Flight (destination VARCHAR)
|
SELECT destination FROM Flight GROUP BY destination ORDER BY COUNT(*) LIMIT 1
|
Which destination has least number of flights?
|
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
|
What is the aircraft name for the flight with number 99
|
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"
|
Show all flight numbers with aircraft Airbus A340-300.
|
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
|
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 FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING COUNT(*) >= 2
|
Show names for all aircraft with at least two flights.
|
CREATE TABLE Certificate (eid VARCHAR)
|
SELECT COUNT(DISTINCT eid) FROM Certificate
|
How many employees have certificate.
|
CREATE TABLE Employee (eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR)
|
SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate
|
Show ids for all employees who don't have a certificate.
|
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"
|
Show names for all aircrafts of which John Williams has certificates.
|
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"
|
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" 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 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"
|
Show names for all employees who do not have certificate of Boeing 737-800.
|
CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR)
|
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 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
|
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 (eid VARCHAR); CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR)
|
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 Aircraft (aid VARCHAR, distance INTEGER); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid 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.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 Allergy_type (allergy VARCHAR)
|
SELECT COUNT(DISTINCT allergy) FROM Allergy_type
|
How many allergies are there?
|
CREATE TABLE Allergy_type (allergytype VARCHAR)
|
SELECT COUNT(DISTINCT allergytype) FROM Allergy_type
|
How many different allergy types exist?
|
CREATE TABLE Allergy_type (allergytype VARCHAR)
|
SELECT DISTINCT allergytype FROM Allergy_type
|
Show all allergy types.
|
CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR)
|
SELECT allergy, allergytype FROM Allergy_type
|
Show all allergies and their types.
|
CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR)
|
SELECT DISTINCT allergy FROM Allergy_type WHERE allergytype = "food"
|
Show all allergies with type food.
|
CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR)
|
SELECT allergytype FROM Allergy_type WHERE allergy = "Cat"
|
What is the type of allergy Cat?
|
CREATE TABLE Allergy_type (allergytype VARCHAR)
|
SELECT COUNT(*) FROM Allergy_type WHERE allergytype = "animal"
|
How many allergies have type animal?
|
CREATE TABLE Allergy_type (allergytype VARCHAR)
|
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 (allergytype VARCHAR)
|
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 (allergytype VARCHAR)
|
SELECT allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) LIMIT 1
|
Which allergy type has least number of allergies?
|
CREATE TABLE Student (Id VARCHAR)
|
SELECT COUNT(*) FROM Student
|
How many students are there?
|
CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR)
|
SELECT Fname, Lname FROM Student
|
Show first name and last name for all students.
|
CREATE TABLE Student (advisor VARCHAR)
|
SELECT COUNT(DISTINCT advisor) FROM Student
|
How many different advisors are listed?
|
CREATE TABLE Student (Major VARCHAR)
|
SELECT DISTINCT Major FROM Student
|
Show all majors.
|
CREATE TABLE Student (city_code VARCHAR)
|
SELECT DISTINCT city_code FROM Student
|
Show all cities where students live.
|
CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Age VARCHAR, Sex VARCHAR)
|
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 Student (StuID VARCHAR, Sex VARCHAR)
|
SELECT StuID FROM Student WHERE Sex = 'M'
|
Show student ids for all male students.
|
CREATE TABLE Student (age VARCHAR)
|
SELECT COUNT(*) FROM Student WHERE age = 18
|
How many students are age 18?
|
CREATE TABLE Student (StuID VARCHAR, age INTEGER)
|
SELECT StuID FROM Student WHERE age > 20
|
Show all student ids who are older than 20.
|
CREATE TABLE Student (city_code VARCHAR, LName VARCHAR)
|
SELECT city_code FROM Student WHERE LName = "Kim"
|
Which city does the student whose last name is "Kim" live in?
|
CREATE TABLE Student (Advisor VARCHAR, StuID VARCHAR)
|
SELECT Advisor FROM Student WHERE StuID = 1004
|
Who is the advisor of student with ID 1004?
|
CREATE TABLE Student (city_code VARCHAR)
|
SELECT COUNT(*) FROM Student WHERE city_code = "HKG" OR city_code = "CHI"
|
How many students live in HKG or CHI?
|
CREATE TABLE Student (age INTEGER)
|
SELECT MIN(age), AVG(age), MAX(age) FROM Student
|
Show the minimum, average, and maximum age of all students.
|
CREATE TABLE Student (LName VARCHAR, age INTEGER)
|
SELECT LName FROM Student WHERE age = (SELECT MIN(age) FROM Student)
|
What is the last name of the youngest student?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.