Chinastark/bird_dataset huggingface dataset:
Database: books
Note: language refers to language_name; books with price less than 20% of the average price refers to price < Multiply (AVG(price), 0.2);
Question: What are the language and title of the ordered books with price less than 20% of the average price of all ordered books?
SQL: SELECT DISTINCT book_language.language_name, book.title FROM order_line INNER JOIN book ON order_line.book_id = book.book_id INNER JOIN book_language ON book_language.language_id = book.language_id WHERE order_line.price * 100 < ( SELECT avg(price) FROM order_line ) * 20
Database: food_inspection_2
Note: full name refers to first_name, last_name;
Question: Please list the full names of all the sanitarians under the supervision of Darlisha Jacobs.
SQL: SELECT first_name, last_name FROM employee WHERE title = 'Sanitarian' AND supervisor = ( SELECT employee_id FROM employee WHERE first_name = 'Darlisha' AND last_name = 'Jacobs' )
Database: food_inspection_2
Note: full name refers to first_name, last_name; in May 2010 refers to inspection_date like '2010-05%'; sanitarian refers to title = 'Sanitarian';
Question: Please list the full names of the sanitarians who did at least one inspection in May, 2010.
SQL: SELECT DISTINCT employee.first_name, employee.last_name FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id WHERE strftime('%Y-%m', inspection.inspection_date) = '2010-05' AND employee.title = 'Sanitarian'
Database: food_inspection_2
Note: in 2010 refers to inspection_date like '2010%';
Question: How many inspections were sanitarian Joshua Rosa responsible for in 2010?
SQL: SELECT count(inspection.inspection_id) FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id WHERE strftime('%Y', inspection.inspection_date) = '2010' AND employee.first_name = 'Joshua' AND employee.last_name = 'Rosa'
Database: food_inspection_2
Note: assumed name refers to dba_name;
Question: Please list the assumed name of all the facilities inspected by Joshua Rosa.
SQL: SELECT DISTINCT establishment.dba_name FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE employee.first_name = 'Joshua' AND employee.last_name = 'Rosa'
Database: food_inspection_2
Note: in 2010 refers to inspection_date like '2010%'; restaurant or cafeteria refers to facility_type = 'Restaurant';
Question: Among the facilities that have undergone at least one inspection in 2010, how many of them are restaurants or cafeterias?
SQL: SELECT count(DISTINCT inspection.license_no) FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE strftime('%Y', inspection.inspection_date) = '2010' AND establishment.facility_type = 'Restaurant'
Database: food_inspection_2
Note: location coordinates refers to latitude, longitude; on 2010/5/11 refers to inspection_date = '2010-05-11';
Question: Please list the location coordinates of all the facilities that had an inspection on 2010/5/11.
SQL: SELECT DISTINCT establishment.latitude, establishment.longitude FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE inspection.inspection_date = '2010-05-11'
Database: food_inspection_2
Note: in 2010 refers to inspection_date like '2010%'; in ward no.42 refers to ward = 42;
Question: Among the facilities that have undergone at least one inspection in 2010, how many of them are in ward no.42?
SQL: SELECT count(DISTINCT inspection.license_no) FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE strftime('%Y', inspection.inspection_date) = '2010' AND establishment.ward = 42
Database: food_inspection_2
Note: full name refers to first_name, last_name; the facility Burbank refers to dba_name = 'Burbank';
Question: Please list the full names of all the sanitarians who have inspected the facility Burbank.
SQL: SELECT DISTINCT employee.first_name, employee.last_name FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE establishment.dba_name = 'Burbank' AND employee.title = 'Sanitarian'
Database: food_inspection_2
Note: assumed name refers to dba_name; failed an inspection refers to results = 'Fail'; in 2010 refers to inspection_date like '2010%';
Question: Please list the assumed name of all the facilities that failed an inspection in 2010.
SQL: SELECT DISTINCT establishment.dba_name FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE inspection.results = 'Fail' AND strftime('%Y', inspection.inspection_date) = '2010'
Database: food_inspection_2
Note: full name refers to first_name, last_name;  Amundsen High School refers to dba_name = 'AMUNDSEN HIGH SCHOOL'; on 2010/5/11 refers to inspection_date = '2010-05-11';
Question: What is the full name of the sanitarian who inspected Amundsen High School on 2010/5/11?
SQL: SELECT employee.first_name, employee.last_name FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE inspection.inspection_date = '2010-05-11' AND establishment.dba_name = 'AMUNDSEN HIGH SCHOOL' AND employee.title = 'Sanitarian'
Database: food_inspection_2
Note: have the result of "pass" refers to results = 'Pass';
Question: Among the inspections done by sanitarian Joshua Rosa, how many of them have the result of "pass"?
SQL: SELECT count(inspection.inspection_id) FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id WHERE inspection.results = 'Pass' AND employee.first_name = 'Joshua' AND employee.last_name = 'Rosa'
Database: food_inspection_2
Note: Azha Restaurant Inc. refers to dba_name = 'Azha Restaurant Inc.'; on 2010/1/21 refers to inspection_date = '2010-01-21'; follow-up inspection date refers to followup_to;
Question: After Azha Restaurant Inc. passed the inspection on 2010/1/21, when was the follow-up inspection done?
SQL: SELECT inspection.followup_to FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE establishment.dba_name = 'Azha Restaurant Inc.' AND inspection.results = 'Pass' AND inspection.inspection_date = '2010-01-21'
Database: food_inspection_2
Note: in 2010 refers to inspection_date like '2010%'; the most serious food safety issues refers to risk_level = 3;
Question: Among the facilities that had undergone at least one inspection in 2010, how many of them have the most serious food safety issues?
SQL: SELECT count(DISTINCT establishment.license_no) FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE strftime('%Y', inspection.inspection_date) = '2010' AND establishment.risk_level = 3
Database: food_inspection_2
Note: in the year 2010 refers to inspection_date like '2010%'; salary is over 70000 refers to salary > 70000; average number = divide(sum(inspection where inspection_date like '2010%'), sum(employee_id where salary > 70000));
Question: What is the average number of inspections carried out in the year 2010 by a sanitarian whose salary is over 70000?
SQL: SELECT cast(sum(CASE WHEN inspection.inspection_date LIKE '2010%' THEN 1 ELSE 0 END) AS REAL) / sum(CASE WHEN employee.salary > 70000 THEN 1 ELSE 0 END) FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id
Database: food_inspection_2
Note: "Refrigeration and metal stem thermometers provided and conspicuous" refers to description = 'Refrigeration and metal stem thermometers provided and conspicuous ';
Question: What is the point level of "Refrigeration and metal stem thermometers provided and conspicuous"?
SQL: SELECT point_level FROM inspection_point WHERE description = 'Refrigeration and metal stem thermometers provided and conspicuous '
Database: food_inspection_2
Note: inspection no.48224 refers to inspection_id = '48224'; full name refers to first_name, last_name;
Question: Which employee was responsible for inspection no.48224? Give the full name.
SQL: SELECT employee.first_name, employee.last_name FROM inspection INNER JOIN employee ON inspection.employee_id = employee.employee_id WHERE inspection.inspection_id = 48224
Database: food_inspection_2
Note: All Style Buffet refers to dba_name = 'All Style Buffet'; Restaurant refers to facility_type = 'Restaurant';
Question: How many inspections did All Style Buffet Restaurant have?
SQL: SELECT count(inspection.inspection_id) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.facility_type = 'Restaurant' AND establishment.dba_name = 'All Style Buffet'
Database: food_inspection_2
Note: Wing Hung Chop Suey Restaurant refers to aka_name = 'WING HUNG CHOP SUEY RESTAURANT'; first inspection refers to min(inspection_date);
Question: When did Wing Hung Chop Suey Restaurant have its first inspection?
SQL: SELECT min(inspection.inspection_date) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.aka_name = 'WING HUNG CHOP SUEY RESTAURANT'
Database: food_inspection_2
Note: restaurant refers to facility_type = 'Restaurant'; on 2015/5/8 refers to inspection_date = '2015-05-08';
Question: How many restaurants were inspected on 2015/5/8?
SQL: SELECT count(inspection.license_no) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE inspection.inspection_date = '2015-05-08' AND establishment.facility_type = 'Restaurant'
Database: food_inspection_2
Note: "food maintenance" related refers to category = 'Food Maintenance'; inspection no.1454071 refers to inspection_id = '1454071';
Question: How many "food maintenance" related violations did inspection no.1454071 have?
SQL: SELECT count(violation.point_id) FROM inspection_point INNER JOIN violation ON inspection_point.point_id = violation.point_id WHERE violation.inspection_id = '1454071' AND inspection_point.category = 'Food Maintenance'
Database: food_inspection_2
Note: Royal Thai Cuisine refers to dba_name = 'ROYAL THAI CUISINE'; 2015/5/8 refers to inspection_date = '2015-05-08';
Question: State the number of violations did Royal Thai Cuisine has during the 2015/5/8 inspection.
SQL: SELECT count(violation.point_id) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no INNER JOIN violation ON inspection.inspection_id = violation.inspection_id WHERE inspection.inspection_date = '2015-05-08' AND establishment.dba_name = 'ROYAL THAI CUISINE'
Database: food_inspection_2
Note: grocery store refers to facility_type = 'Grocery Store'; "3635 W DIVERSEY AVE" refers to address = '3635 W DIVERSEY AVE';
Question: For the grocery store located at "3635 W DIVERSEY AVE", how many inspections did it have?
SQL: SELECT count(inspection.inspection_id) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.address = '3635 W DIVERSEY AVE ' AND establishment.facility_type = 'Grocery Store'
Database: food_inspection_2
Note: full name refers to first_name, last_name; most of the inspections refers to max(count(employee_id));
Question: Who is responsible for most of the inspections? Give the full name.
SQL: SELECT t.first_name, t.last_name FROM ( SELECT employee.employee_id, employee.first_name, employee.last_name, count(inspection.inspection_id) FROM inspection INNER JOIN employee ON inspection.employee_id = employee.employee_id GROUP BY employee.employee_id, employee.first_name, employee.last_name ORDER BY count(inspection.inspection_id) DESC LIMIT 1 ) AS t
Database: food_inspection_2
Note: the result of "Out of Business" refers to results = 'Out of Business';
Question: How many inspections done by Lisa Tillman ended up with the result of "Out of Business"?
SQL: SELECT count(inspection.inspection_id) FROM inspection INNER JOIN employee ON inspection.employee_id = employee.employee_id WHERE employee.first_name = 'Lisa' AND employee.last_name = 'Tillman' AND inspection.results = 'Out of Business'
Database: food_inspection_2
Note: sanitarian refers to title = 'Sanitarian'; 5000 N Wolcott Ave refers to address = '5000 N Wolcott Ave'; in May 2011 refers to inspection_date between '2011-04-30' and '2011-06-01';
Question: For the sanitarian who lives on 5000 N Wolcott Ave, how many establishments did he/she inspect in the May of 2011?
SQL: SELECT count(inspection.inspection_id) FROM inspection INNER JOIN employee ON inspection.employee_id = employee.employee_id WHERE employee.address = '5000 N Wolcott Ave' AND employee.title = 'Sanitarian' AND strftime('%Y-%m', inspection.inspection_date) = '2011-05'
Database: food_inspection_2
Note: phone number refers to phone; sanitarian refers to title = 'Sanitarian'; inspection no.634597 refers to inspection_id = '634597';
Question: Show the phone number of the sanitarian who was responsible for inspection no.634597.
SQL: SELECT employee.phone FROM inspection INNER JOIN employee ON inspection.employee_id = employee.employee_id WHERE inspection.inspection_id = 634597 AND employee.title = 'Sanitarian'
Database: food_inspection_2
Note: the most inspections refers to max(count(employee_id));
Question: State the salary of the employee who did the most inspections.
SQL: SELECT employee.salary FROM employee INNER JOIN ( SELECT t.employee_id, count(t.inspection_id) FROM inspection AS t GROUP BY t.employee_id ORDER BY count(t.inspection_id) DESC LIMIT 1 ) AS t2 ON employee.employee_id = t2.employee_id
Database: food_inspection_2
Note: risk level 3 refers to risk_level = '3'; tavern refers to facility_type = 'TAVERN'; average number = divide(count(inspection_id), sum(license_no)) where risk_level = '3' and facility_type = 'TAVERN';
Question: What is the average number of inspections did risk level 3 taverns have?
SQL: SELECT cast(count(inspection.inspection_id) AS REAL) / count(DISTINCT establishment.license_no) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.risk_level = 3 AND establishment.facility_type = 'TAVERN'
Database: food_inspection_2
Note: Pockets refers to dba_name = 'POCKETS'; Restaurant refers to facility_type = 'Restaurant'; pass refers to results = 'Pass'; the inspection pass rate = divide(sum(inspection_id where results = 'Pass'), count(license_no)) where dba_name = 'POCKETS' and facility_type = 'Restaurant';
Question: State the inspection pass rate of Pockets Restaurant.
SQL: SELECT cast(count(CASE WHEN inspection.results = 'Pass' THEN inspection.inspection_id ELSE NULL END) AS REAL) * 100 / count(inspection.inspection_id) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.dba_name = 'POCKETS' AND establishment.facility_type = 'Restaurant'
Database: food_inspection_2
Note: sanitarian refers to title = 'Sanitarian'; in Chicago refers to city = 'Chicago'; zip code 60617 refers to zip = 60617;
Question: How many sanitarian employees in Chicago are from the zip code 60617?
SQL: SELECT count(employee_id) FROM employee WHERE zip = '60617'
Database: food_inspection_2
Note: assumed name refers to dba_name; 2903 W Irving Park Rd refers to address = '2903 W IRVING PARK RD ';
Question: What is the assumed name of the business located at 2903 W Irving Park Rd?
SQL: SELECT DISTINCT dba_name FROM establishment WHERE address = '2903 W IRVING PARK RD '
Database: food_inspection_2
Note: full name refers to first_name, last_name; the lowest salary refers to min(salary);
Question: What is the full name of the employee with the lowest salary?
SQL: SELECT first_name, last_name FROM employee ORDER BY salary ASC LIMIT 1
Database: food_inspection_2
Note: Homemade Pizza refers to dba_name = 'HOMEMADE PIZZA'; a risk level of 2 refers to risk_level = 2;
Question: How many establishments that are doing business as Homemade Pizza have a risk level of 2?
SQL: SELECT count(license_no) FROM establishment WHERE risk_level = 2 AND dba_name = 'HOMEMADE PIZZA'
Database: food_inspection_2
Note: critical food safety problems refers to fine = 500; point_id = 3;
Question: How many inspections with critical food safety problems are under inspection point id 3?
SQL: SELECT count(inspection_id) FROM violation WHERE point_id = 3 AND fine = 500
Database: food_inspection_2
Question: How many employees are under Gregory Cardenas?
SQL: SELECT count(employee.employee_id) FROM employee WHERE employee.supervisor = ( SELECT employee_id FROM employee WHERE first_name = 'Gregory' AND last_name = 'Cardenas' )
Database: food_inspection_2
Note: Renaldi's Pizza refers to dba_name = 'RENALDI''S PIZZA'; first inspection refers to min(inspection_date);
Question: When did Renaldi's Pizza had its first inspection?
SQL: SELECT min(inspection.inspection_date) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE establishment.dba_name = 'RENALDI''S PIZZA'
Database: food_inspection_2
Note: full name refers to first_name, last_name; the most inspection refers to max(count(employee_id)); in March 2016 refers to inspection_date like '2016-03%';
Question: What is the full name of the employee who was responsible for the most inspection in March 2016?
SQL: SELECT employee.first_name, employee.last_name FROM ( SELECT inspection.employee_id, count(inspection.inspection_id) FROM inspection WHERE strftime('%Y-%m', inspection.inspection_date) = '2016-03' GROUP BY inspection.employee_id ORDER BY count(inspection.inspection_id) DESC LIMIT 1 ) AS t2 INNER JOIN employee ON t2.employee_id = employee.employee_id
Database: food_inspection_2
Note: name of business refers to dba_name; passed with conditions refers to results = 'Pass w/ Conditions'; in May 2012 refers to inspection_date like '2012-05%';
Question: What are the names of the businesses that passed with conditions in May 2012?
SQL: SELECT DISTINCT establishment.dba_name FROM inspection INNER JOIN establishment ON inspection.license_no = establishment.license_no WHERE strftime('%Y-%m', inspection.inspection_date) = '2012-05' AND inspection.results = 'Pass w/ Conditions'
Database: food_inspection_2
Note: short form complaint inspection refers to inspection_type = 'Short Form Complaint'; pass refers to results = 'Pass';
Question: Out of all the short form complaint inspections done by David Hodges, how many businesses passed?
SQL: SELECT count(DISTINCT inspection.license_no) FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id WHERE employee.first_name = 'David' AND employee.last_name = 'Hodges' AND employee.employee_id = 153225 AND inspection.inspection_type = 'Short Form Complaint' AND inspection.results = 'Pass'
Database: food_inspection_2
Note: ward 42 refers to ward = 42; at least 5 failed inspection results refers to count(results = 'Fail') >= 5; between 1/1/2010 to 12/31/2015 refers to inspection_date between '2010-01-01' and '2015-12-31';
Question: How many businesses from ward 42 have at least 5 failed inspection results between 1/1/2010 to 12/31/2015?
SQL: SELECT count(DISTINCT establishment.license_no) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no WHERE inspection.inspection_date BETWEEN '2010-01-01' AND '2015-12-31' AND establishment.ward = 42 AND establishment.license_no IN ( SELECT license_no FROM ( SELECT license_no FROM inspection WHERE results = 'Fail' GROUP BY license_no HAVING count(results) >= 5 ) )
Database: food_inspection_2
Note: the highest number of inspections done refers to max(count(employee_id));
Question: How much is the salary of the employee who has the highest number of inspections done of all time?
SQL: SELECT employee.salary FROM employee INNER JOIN ( SELECT employee_id, count(inspection_id) FROM inspection GROUP BY employee_id ORDER BY count(inspection_id) DESC LIMIT 1 ) AS t2 ON employee.employee_id = t2.employee_id
Database: food_inspection_2
Note: assumed name of business refers to dba_name; the highest total fine refers to max(sum(fine)); in 2014 refers to inspection_date like '2014%';
Question: What is the assumed name of the business that has the highest total fine in 2014?
SQL: SELECT t.dba_name FROM ( SELECT establishment.dba_name, sum(violation.fine) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no INNER JOIN violation ON inspection.inspection_id = violation.inspection_id WHERE strftime('%Y', inspection.inspection_date) = '2014' GROUP BY establishment.dba_name ORDER BY sum(violation.fine) DESC LIMIT 1 ) AS t
Database: food_inspection_2
Note: precise location refers to latitude, longitude; the highest number of failed inspections refers to max(count(results where results = 'Fail'));
Question: What is the precise location of the establishment with the highest number of failed inspections?
SQL: SELECT establishment.latitude, establishment.longitude FROM establishment INNER JOIN ( SELECT license_no FROM inspection WHERE results = 'Fail' GROUP BY license_no ORDER BY count(results) DESC LIMIT 1 ) AS t2 ON establishment.license_no = t2.license_no
Database: food_inspection_2
Note: comment of the inspector refers to inspector_comment; Taqueria La Fiesta refers to dba_name = 'TAQUERIA LA FIESTA'; on 1/25/2010 refers to inspection_date = '2010-01-25';
Question: What are the comments of the inspector during the inspection of Taqueria La Fiesta on 1/25/2010?
SQL: SELECT violation.inspector_comment FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no INNER JOIN violation ON inspection.inspection_id = violation.inspection_id WHERE inspection.inspection_date = '2010-01-25' AND establishment.dba_name = 'TAQUERIA LA FIESTA'
Database: food_inspection_2
Note: total fine = sum(fine); Ron of Japan Inc refers to dba_name = 'RON OF JAPAN INC'; on February 2014 refers to inspection_date like '2014-02%';
Question: How much is the total fine given to Ron of Japan Inc in its inspection done on February 2014?
SQL: SELECT sum(violation.fine) FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no INNER JOIN violation ON inspection.inspection_id = violation.inspection_id WHERE strftime('%Y-%m', inspection.inspection_date) = '2014-02' AND establishment.dba_name = 'RON OF JAPAN INC'
Database: food_inspection_2
Note: full name refers to first_name, last_name; Taqueria La Paz refers to dba_name = 'TAQUERIA LA PAZ';
Question: List the full names of the employees who were responsible for inspecting Taqueria La Paz.
SQL: SELECT DISTINCT employee.first_name, employee.last_name FROM establishment INNER JOIN inspection ON establishment.license_no = inspection.license_no INNER JOIN employee ON inspection.employee_id = employee.employee_id WHERE establishment.dba_name = 'TAQUERIA LA PAZ'
Database: food_inspection_2
Note: full name refers to first_name, last_name; the highest amount of fine refers to max(sum(fine));
Question: What is the full name of the employee who gave the highest amount of fine of all time?
SQL: SELECT t.first_name, t.last_name FROM ( SELECT employee.first_name, employee.last_name, sum(violation.fine) FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id INNER JOIN violation ON inspection.inspection_id = violation.inspection_id GROUP BY employee.first_name, employee.last_name ORDER BY sum(violation.fine) DESC LIMIT 1 ) t
Database: food_inspection_2
Note: the highest salary refers to max(salary); sanitarian refers to title = 'Sanitarian'; name refers to first_name, last_name; average number = divide(sum(inspection_id), 5);
Question: What is the average number of inspections done by the top 5 employees with the highest salary? List the names of the said employees.
SQL: SELECT cast(count(DISTINCT inspection.inspection_id) AS REAL) / 5, employee.first_name, employee.last_name FROM employee INNER JOIN inspection ON employee.employee_id = inspection.employee_id WHERE employee.title = 'Sanitarian' ORDER BY employee.salary DESC LIMIT 5