training_input
stringlengths 118
1.06k
|
---|
###context:CREATE TABLE employee (name VARCHAR, age VARCHAR)
###human: Sort employee names by their age in ascending order.
###assistant: SELECT name FROM employee ORDER BY age |
###context:CREATE TABLE employee (city VARCHAR)
###human: What is the number of employees from each city?
###assistant: SELECT COUNT(*), city FROM employee GROUP BY city |
###context:CREATE TABLE employee (city VARCHAR, age INTEGER)
###human: Which cities do more than one employee under age 30 come from?
###assistant: SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING COUNT(*) > 1 |
###context:CREATE TABLE shop (LOCATION VARCHAR)
###human: Find the number of shops in each location.
###assistant: SELECT COUNT(*), LOCATION FROM shop GROUP BY LOCATION |
###context:CREATE TABLE shop (manager_name VARCHAR, district VARCHAR, number_products VARCHAR)
###human: Find the manager name and district of the shop whose number of products is the largest.
###assistant: SELECT manager_name, district FROM shop ORDER BY number_products DESC LIMIT 1 |
###context:CREATE TABLE shop (Number_products INTEGER)
###human: find the minimum and maximum number of products of all stores.
###assistant: SELECT MIN(Number_products), MAX(Number_products) FROM shop |
###context:CREATE TABLE shop (name VARCHAR, LOCATION VARCHAR, district VARCHAR, number_products VARCHAR)
###human: Return the name, location and district of all shops in descending order of number of products.
###assistant: SELECT name, LOCATION, district FROM shop ORDER BY number_products DESC |
###context:CREATE TABLE shop (name VARCHAR, number_products INTEGER)
###human: Find the names of stores whose number products is more than the average number of products.
###assistant: SELECT name FROM shop WHERE number_products > (SELECT AVG(number_products) FROM shop) |
###context:CREATE TABLE evaluation (Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
###human: find the name of employee who was awarded the most times in the evaluation.
###assistant: SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE evaluation (Employee_ID VARCHAR, bonus VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
###human: Find the name of the employee who got the highest one time bonus.
###assistant: SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1 |
###context:CREATE TABLE evaluation (name VARCHAR, Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
###human: Find the names of employees who never won any award in the evaluation.
###assistant: SELECT name FROM employee WHERE NOT Employee_ID IN (SELECT Employee_ID FROM evaluation) |
###context:CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR)
###human: What is the name of the shop that is hiring the largest number of employees?
###assistant: SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t1.shop_id ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (name VARCHAR, shop_id VARCHAR)
###human: Find the name of the shops that do not hire any employee.
###assistant: SELECT name FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM hiring) |
###context:CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR)
###human: Find the number of employees hired in each shop; show the shop name as well.
###assistant: SELECT COUNT(*), t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t2.name |
###context:CREATE TABLE evaluation (bonus INTEGER)
###human: What is total bonus given in all evaluations?
###assistant: SELECT SUM(bonus) FROM evaluation |
###context:CREATE TABLE hiring (Id VARCHAR)
###human: Give me all the information about hiring.
###assistant: SELECT * FROM hiring |
###context:CREATE TABLE shop (district VARCHAR, Number_products INTEGER)
###human: Which district has both stores with less than 3000 products and stores with more than 10000 products?
###assistant: SELECT district FROM shop WHERE Number_products < 3000 INTERSECT SELECT district FROM shop WHERE Number_products > 10000 |
###context:CREATE TABLE shop (LOCATION VARCHAR)
###human: How many different store locations are there?
###assistant: SELECT COUNT(DISTINCT LOCATION) FROM shop |
###context:CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR, document_description VARCHAR)
###human: List document IDs, document names, and document descriptions for all documents.
###assistant: SELECT document_id, document_name, document_description FROM Documents |
###context:CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR, Document_Description VARCHAR)
###human: What is the document name and template id for document with description with the letter 'w' in it?
###assistant: SELECT document_name, template_id FROM Documents WHERE Document_Description LIKE "%w%" |
###context:CREATE TABLE Documents (document_id VARCHAR, template_id VARCHAR, Document_Description VARCHAR, document_name VARCHAR)
###human: What is the document id, template id and description for document named "Robbin CV"?
###assistant: SELECT document_id, template_id, Document_Description FROM Documents WHERE document_name = "Robbin CV" |
###context:CREATE TABLE Documents (template_id VARCHAR)
###human: How many different templates do all document use?
###assistant: SELECT COUNT(DISTINCT template_id) FROM Documents |
###context:CREATE TABLE Templates (Template_ID VARCHAR, Template_Type_Code VARCHAR); CREATE TABLE Documents (Template_ID VARCHAR)
###human: How many documents are using the template with type code 'PPT'?
###assistant: SELECT COUNT(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID = T2.Template_ID WHERE T2.Template_Type_Code = 'PPT' |
###context:CREATE TABLE Documents (template_id VARCHAR)
###human: Show all template ids and number of documents using each template.
###assistant: SELECT template_id, COUNT(*) FROM Documents GROUP BY template_id |
###context:CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (Template_Type_Code VARCHAR, template_id VARCHAR)
###human: What is the id and type code for the template used by the most documents?
###assistant: SELECT T1.template_id, T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_id ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE Documents (template_id VARCHAR)
###human: Show ids for all templates that are used by more than one document.
###assistant: SELECT template_id FROM Documents GROUP BY template_id HAVING COUNT(*) > 1 |
###context:CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR)
###human: Show ids for all templates not used by any document.
###assistant: SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents |
###context:CREATE TABLE Templates (Id VARCHAR)
###human: How many templates do we have?
###assistant: SELECT COUNT(*) FROM Templates |
###context:CREATE TABLE Templates (template_id VARCHAR, version_number VARCHAR, template_type_code VARCHAR)
###human: Show template ids, version numbers, and template type codes for all templates.
###assistant: SELECT template_id, version_number, template_type_code FROM Templates |
###context:CREATE TABLE Templates (template_type_code VARCHAR)
###human: Show all distinct template type codes for all templates.
###assistant: SELECT DISTINCT template_type_code FROM Templates |
###context:CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)
###human: What are the ids of templates with template type code PP or PPT?
###assistant: SELECT template_id FROM Templates WHERE template_type_code = "PP" OR template_type_code = "PPT" |
###context:CREATE TABLE Templates (template_type_code VARCHAR)
###human: How many templates have template type code CV?
###assistant: SELECT COUNT(*) FROM Templates WHERE template_type_code = "CV" |
###context:CREATE TABLE Templates (version_number INTEGER, template_type_code VARCHAR)
###human: What is the version number and template type code for the template with version number later than 5?
###assistant: SELECT version_number, template_type_code FROM Templates WHERE version_number > 5 |
###context:CREATE TABLE Templates (template_type_code VARCHAR)
###human: Show all template type codes and number of templates for each.
###assistant: SELECT template_type_code, COUNT(*) FROM Templates GROUP BY template_type_code |
###context:CREATE TABLE Templates (template_type_code VARCHAR)
###human: Which template type code has most number of templates?
###assistant: SELECT template_type_code FROM Templates GROUP BY template_type_code ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE Templates (template_type_code VARCHAR)
###human: Show all template type codes with less than three templates.
###assistant: SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING COUNT(*) < 3 |
###context:CREATE TABLE Templates (template_type_code VARCHAR, Version_Number INTEGER)
###human: What the smallest version number and its template type code?
###assistant: SELECT MIN(Version_Number), template_type_code FROM Templates |
###context:CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR); CREATE TABLE Documents (template_id VARCHAR, document_name VARCHAR)
###human: What is the template type code of the template used by document with the name "Data base"?
###assistant: SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T2.document_name = "Data base" |
###context:CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)
###human: Show all document names using templates with template type code BK.
###assistant: SELECT T2.document_name FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T1.template_type_code = "BK" |
###context:CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR)
###human: Show all template type codes and the number of documents using each type.
###assistant: SELECT T1.template_type_code, COUNT(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code |
###context:CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR)
###human: Which template type code is used by most number of documents?
###assistant: SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR)
###human: Show all template type codes that are not used by any document.
###assistant: SELECT template_type_code FROM Templates EXCEPT SELECT template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id |
###context:CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
###human: Show all template type codes and descriptions.
###assistant: SELECT template_type_code, template_type_description FROM Ref_template_types |
###context:CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)
###human: What is the template type descriptions for template type code "AD".
###assistant: SELECT template_type_description FROM Ref_template_types WHERE template_type_code = "AD" |
###context:CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
###human: What is the template type code for template type description "Book".
###assistant: SELECT template_type_code FROM Ref_template_types WHERE template_type_description = "Book" |
###context:CREATE TABLE Templates (template_type_code VARCHAR, Template_ID VARCHAR); CREATE TABLE Documents (template_ID VARCHAR); CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)
###human: What are the distinct template type descriptions for the templates ever used by any document?
###assistant: SELECT DISTINCT T1.template_type_description FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code JOIN Documents AS T3 ON T2.Template_ID = T3.template_ID |
###context:CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR); CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
###human: What are the template ids with template type description "Presentation".
###assistant: SELECT T2.template_id FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code WHERE T1.template_type_description = "Presentation" |
###context:CREATE TABLE Paragraphs (Id VARCHAR)
###human: How many paragraphs in total?
###assistant: SELECT COUNT(*) FROM Paragraphs |
###context:CREATE TABLE Documents (document_ID VARCHAR, document_name VARCHAR); CREATE TABLE Paragraphs (document_ID VARCHAR)
###human: How many paragraphs for the document with name 'Summer Show'?
###assistant: SELECT COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_ID = T2.document_ID WHERE T2.document_name = 'Summer Show' |
###context:CREATE TABLE paragraphs (other_details VARCHAR, paragraph_text VARCHAR)
###human: Show paragraph details for paragraph with text 'Korea ' .
###assistant: SELECT other_details FROM paragraphs WHERE paragraph_text LIKE 'korea' |
###context:CREATE TABLE Documents (document_id VARCHAR, Document_Name VARCHAR); CREATE TABLE Paragraphs (paragraph_id VARCHAR, paragraph_text VARCHAR, document_id VARCHAR)
###human: Show all paragraph ids and texts for the document with name 'Welcome to NY'.
###assistant: SELECT T1.paragraph_id, T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.Document_Name = 'Welcome to NY' |
###context:CREATE TABLE Paragraphs (paragraph_text VARCHAR, document_id VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR)
###human: Show all paragraph texts for the document "Customer reviews".
###assistant: SELECT T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.document_name = "Customer reviews" |
###context:CREATE TABLE Paragraphs (document_id VARCHAR)
###human: Show all document ids and the number of paragraphs in each document. Order by document id.
###assistant: SELECT document_id, COUNT(*) FROM Paragraphs GROUP BY document_id ORDER BY document_id |
###context:CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR)
###human: Show all document ids, names and the number of paragraphs in each document.
###assistant: SELECT T1.document_id, T2.document_name, COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id |
###context:CREATE TABLE Paragraphs (document_id VARCHAR)
###human: List all document ids with at least two paragraphs.
###assistant: SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) >= 2 |
###context:CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR)
###human: What is the document id and name with greatest number of paragraphs?
###assistant: SELECT T1.document_id, T2.document_name FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE Paragraphs (document_id VARCHAR)
###human: What is the document id with least number of paragraphs?
###assistant: SELECT document_id FROM Paragraphs GROUP BY document_id ORDER BY COUNT(*) LIMIT 1 |
###context:CREATE TABLE Paragraphs (document_id VARCHAR)
###human: What is the document id with 1 to 2 paragraphs?
###assistant: SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) BETWEEN 1 AND 2 |
###context:CREATE TABLE Paragraphs (document_id VARCHAR, paragraph_text VARCHAR)
###human: Show the document id with paragraph text 'Brazil' and 'Ireland'.
###assistant: SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Brazil' INTERSECT SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Ireland' |
###context:CREATE TABLE teacher (Id VARCHAR)
###human: How many teachers are there?
###assistant: SELECT COUNT(*) FROM teacher |
###context:CREATE TABLE teacher (Name VARCHAR, Age VARCHAR)
###human: List the names of teachers in ascending order of age.
###assistant: SELECT Name FROM teacher ORDER BY Age |
###context:CREATE TABLE teacher (Age VARCHAR, Hometown VARCHAR)
###human: What are the age and hometown of teachers?
###assistant: SELECT Age, Hometown FROM teacher |
###context:CREATE TABLE teacher (name VARCHAR, hometown VARCHAR)
###human: List the name of teachers whose hometown is not `` Little Lever Urban District '' .
###assistant: SELECT name FROM teacher WHERE hometown <> "little lever urban district" |
###context:CREATE TABLE teacher (Name VARCHAR, Age VARCHAR)
###human: Show the name of teachers aged either 32 or 33?
###assistant: SELECT Name FROM teacher WHERE Age = 32 OR Age = 33 |
###context:CREATE TABLE teacher (Hometown VARCHAR, Age VARCHAR)
###human: What is the hometown of the youngest teacher?
###assistant: SELECT Hometown FROM teacher ORDER BY Age LIMIT 1 |
###context:CREATE TABLE teacher (Hometown VARCHAR)
###human: Show different hometown of teachers and the number of teachers from each hometown.
###assistant: SELECT Hometown, COUNT(*) FROM teacher GROUP BY Hometown |
###context:CREATE TABLE teacher (Hometown VARCHAR)
###human: List the most common hometown of teachers.
###assistant: SELECT Hometown FROM teacher GROUP BY Hometown ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE teacher (Hometown VARCHAR)
###human: Show the hometowns shared by at least two teachers.
###assistant: SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2 |
###context:CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR)
###human: Show names of teachers and the courses they are arranged to teach.
###assistant: SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID |
###context:CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR)
###human: Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
###assistant: SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name |
###context:CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course_ID VARCHAR, Course VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR)
###human: Show the name of the teacher for the math course.
###assistant: SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math" |
###context:CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR)
###human: Show names of teachers and the number of courses they teach.
###assistant: SELECT T2.Name, COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name |
###context:CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR)
###human: Show names of teachers that teach at least two courses.
###assistant: SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2 |
###context:CREATE TABLE course_arrange (Name VARCHAR, Teacher_id VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_id VARCHAR)
###human: List the names of teachers who have not been arranged to teach courses.
###assistant: SELECT Name FROM teacher WHERE NOT Teacher_id IN (SELECT Teacher_id FROM course_arrange) |
###context:CREATE TABLE visitor (age INTEGER)
###human: How many visitors below age 30 are there?
###assistant: SELECT COUNT(*) FROM visitor WHERE age < 30 |
###context:CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER)
###human: Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
###assistant: SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC |
###context:CREATE TABLE visitor (age INTEGER, Level_of_membership VARCHAR)
###human: What is the average age of the visitors whose membership level is not higher than 4?
###assistant: SELECT AVG(age) FROM visitor WHERE Level_of_membership <= 4 |
###context:CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER, age VARCHAR)
###human: Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
###assistant: SELECT name, Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC |
###context:CREATE TABLE museum (museum_id VARCHAR, name VARCHAR, num_of_staff VARCHAR)
###human: Find the id and name of the museum that has the most staff members?
###assistant: SELECT museum_id, name FROM museum ORDER BY num_of_staff DESC LIMIT 1 |
###context:CREATE TABLE museum (num_of_staff INTEGER, open_year INTEGER)
###human: Find the average number of staff working for the museums that were open before 2009.
###assistant: SELECT AVG(num_of_staff) FROM museum WHERE open_year < 2009 |
###context:CREATE TABLE museum (Num_of_Staff VARCHAR, Open_Year VARCHAR, name VARCHAR)
###human: What are the opening year and staff number of the museum named Plaza Museum?
###assistant: SELECT Num_of_Staff, Open_Year FROM museum WHERE name = 'Plaza Museum' |
###context:CREATE TABLE museum (name VARCHAR, num_of_staff INTEGER, open_year INTEGER)
###human: find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
###assistant: SELECT name FROM museum WHERE num_of_staff > (SELECT MIN(num_of_staff) FROM museum WHERE open_year > 2010) |
###context:CREATE TABLE visit (visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, name VARCHAR, age VARCHAR)
###human: find the id, name and age for visitors who visited some museums more than once.
###assistant: SELECT t1.id, t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t1.id HAVING COUNT(*) > 1 |
###context:CREATE TABLE visit (visitor_id VARCHAR, Total_spent INTEGER); CREATE TABLE visitor (name VARCHAR, Level_of_membership VARCHAR, id VARCHAR)
###human: What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
###assistant: SELECT t2.visitor_id, t1.name, t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY SUM(t2.Total_spent) DESC LIMIT 1 |
###context:CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR); CREATE TABLE visit (Museum_ID VARCHAR)
###human: What are the id and name of the museum visited most times?
###assistant: SELECT t2.Museum_ID, t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE visit (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR); CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR)
###human: What is the name of the museum that had no visitor yet?
###assistant: SELECT name FROM museum WHERE NOT Museum_ID IN (SELECT museum_id FROM visit) |
###context:CREATE TABLE visitor (name VARCHAR, age VARCHAR, id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, num_of_ticket VARCHAR)
###human: Find the name and age of the visitor who bought the most tickets at once.
###assistant: SELECT t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1 |
###context:CREATE TABLE visit (num_of_ticket INTEGER)
###human: What are the average and maximum number of tickets bought in all visits?
###assistant: SELECT AVG(num_of_ticket), MAX(num_of_ticket) FROM visit |
###context:CREATE TABLE visit (Total_spent INTEGER, visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, Level_of_membership VARCHAR)
###human: What is the total ticket expense of the visitors whose membership level is 1?
###assistant: SELECT SUM(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id WHERE t1.Level_of_membership = 1 |
###context:CREATE TABLE visitor (name VARCHAR, id VARCHAR); CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)
###human: What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
###assistant: SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011 |
###context:CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visitor (id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)
###human: Find the number of visitors who did not visit any museum opened after 2010.
###assistant: SELECT COUNT(*) FROM visitor WHERE NOT id IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID WHERE t1.open_year > 2010) |
###context:CREATE TABLE museum (open_year VARCHAR)
###human: How many museums were opened after 2013 or before 2008?
###assistant: SELECT COUNT(*) FROM museum WHERE open_year > 2013 OR open_year < 2008 |
###context:CREATE TABLE players (Id VARCHAR)
###human: Find the total number of players.
###assistant: SELECT COUNT(*) FROM players |
###context:CREATE TABLE matches (Id VARCHAR)
###human: Find the total number of matches.
###assistant: SELECT COUNT(*) FROM matches |
###context:CREATE TABLE players (first_name VARCHAR, birth_date VARCHAR, country_code VARCHAR)
###human: List the first name and birth date of all players from the country with code USA.
###assistant: SELECT first_name, birth_date FROM players WHERE country_code = 'USA' |
###context:CREATE TABLE matches (loser_age INTEGER, winner_age INTEGER)
###human: Find the average age of losers and winners of all matches.
###assistant: SELECT AVG(loser_age), AVG(winner_age) FROM matches |
###context:CREATE TABLE matches (winner_rank INTEGER)
###human: Find the average rank of winners in all matches.
###assistant: SELECT AVG(winner_rank) FROM matches |
###context:CREATE TABLE matches (loser_rank INTEGER)
###human: Find the highest rank of losers in all matches.
###assistant: SELECT MIN(loser_rank) FROM matches |
###context:CREATE TABLE players (country_code VARCHAR)
###human: find the number of distinct country codes of all players.
###assistant: SELECT COUNT(DISTINCT country_code) FROM players |
###context:CREATE TABLE matches (loser_name VARCHAR)
###human: Find the number of distinct name of losers.
###assistant: SELECT COUNT(DISTINCT loser_name) FROM matches |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.