Chinastark/bird_dataset huggingface dataset:
Database: chicago_crime
Note: no arrest has been made refers to arrest = 'FALSE';
Question: Among the crimes with no arrest made, how many of them happened in the ward represented by alderman Pat Dowell?
SQL: SELECT sum(CASE WHEN ward.alderman_last_name = 'Dowell' THEN 1 ELSE 0 END) FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE crime.arrest = 'FALSE' AND ward.alderman_first_name = 'Pat'
Database: chicago_crime
Note: in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; ward with the most number of crime refers to Max (Count(ward_no)); full name refers to alderman_first_name, alderman_last_name, alderman_name_suffix;
Question: Which alderman represents the ward with the most number of crimes in January, 2018? Please give his or her full name.
SQL: SELECT ward.ward_no, ward.alderman_first_name, ward.alderman_last_name, ward.alderman_name_suffix FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE substr(crime.date, 1, 1) = '1' AND substr(crime.date, 5, 4) = '2018' GROUP BY ward.ward_no ORDER BY count(ward.ward_no) DESC LIMIT 1
Database: chicago_crime
Note: most population refers to Max(population); domestic violence refers to domestic = 'TRUE';
Question: Among the crimes in the ward with the most population, how many of them are cases of domestic violence?
SQL: SELECT count(ward.ward_no) AS num FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE crime.domestic = 'TRUE' ORDER BY ward.population = ( SELECT population FROM ward ORDER BY population DESC LIMIT 1 )
Database: chicago_crime
Note: location coordinates refers to latitude, longitude;
Question: Please list the location coordinates of all the incidents that had happened in the ward represented by alderman Pat Dowell.
SQL: SELECT crime.latitude, crime.longitude FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE ward.alderman_first_name = 'Pat' AND ward.alderman_last_name = 'Dowell' AND crime.latitude IS NOT NULL AND crime.longitude IS NOT NULL
Database: chicago_crime
Note: January, 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; had more incidents refers to Max(Count(ward_no));
Question: The ward represented by which alderman had more incidents in January, 2018, Pat Dowell or Sophia King?
SQL: SELECT ward.alderman_first_name, ward.alderman_last_name, count(ward.ward_no) AS num FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE (substr(crime.date, 1, 1) = '1' AND substr(crime.date, 5, 4) = '2018' AND ward.alderman_first_name = 'Pat' AND ward.alderman_last_name = 'Dowell') OR (ward.alderman_first_name = 'Sophia' AND ward.alderman_last_name = 'King') GROUP BY ward.ward_no
Database: chicago_crime
Note: general description refers to primary_description; 'BATTERY' is the primary_description;
Question: Please list the case numbers of all the incidents with the generic description of "BATTERY" in the IUCR classification.
SQL: SELECT crime.case_number FROM iucr INNER JOIN crime ON iucr.iucr_no = crime.iucr_no WHERE iucr.primary_description = 'BATTERY'
Database: chicago_crime
Note: general description refers to primary_description; 'BATTERY' is the primary_description; do not have arrest made refers to arrest = 'FALSE';
Question: Among the incidents with the generic description of "BATTERY" in the IUCR classification, how many of them do not have arrests made?
SQL: SELECT sum(CASE WHEN crime.arrest = 'FALSE' THEN 1 ELSE 0 END) FROM iucr INNER JOIN crime ON iucr.iucr_no = crime.iucr_no WHERE iucr.primary_description = 'BATTERY'
Database: chicago_crime
Note: "Homicide 1st & 2nd Degree" is the title;
Question: Please list the case numbers of all the crimes whose short description of the kind of crime is "Homicide 1st & 2nd Degree" in the FBI classification.
SQL: SELECT crime.case_number FROM fbi_code INNER JOIN crime ON fbi_code.fbi_code_no = crime.fbi_code_no WHERE fbi_code.title = 'Homicide 1st & 2nd Degree'
Database: chicago_crime
Note: in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; against property refers to crime_against = 'Property';
Question: Among the incidents in January, 2018, how many of them were stated "against Property" in the FBI classification?
SQL: SELECT sum(CASE WHEN substr(crime.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM fbi_code INNER JOIN crime ON fbi_code.fbi_code_no = crime.fbi_code_no WHERE fbi_code.crime_against = 'Property' AND substr(crime.date, 1, 1) = '1'
Database: chicago_crime
Note: in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018';
Question: District commander Robert A. Rubio was responsible for how many incidents in January, 2018?
SQL: SELECT sum(CASE WHEN substr(crime.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM district INNER JOIN crime ON district.district_no = crime.district_no WHERE district.commander = 'Robert A. Rubio' AND substr(crime.date, 1, 1) = '1'
Database: chicago_crime
Note: in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; 'Robert A. Rubio' and 'Glenn White' are both commander; responsible for more incident refers to Max(count(ward_no));
Question: Which district commander was responsible for more incidents in January, 2018, Robert A. Rubio or Glenn White?
SQL: SELECT district.commander FROM district INNER JOIN crime ON district.district_no = crime.district_no WHERE district.commander IN ('Robert A. Rubio', 'Glenn White') AND substr(crime.date, 1, 1) = '1' AND substr(crime.date, 5, 4) = '2018' GROUP BY district.commander
Database: chicago_crime
Note: "Robert A. Rubio" is the commander;
Question: Please list the blocks where all the incidents in the district commanded by Robert A. Rubio took place.
SQL: SELECT crime.block FROM district INNER JOIN crime ON district.district_no = crime.district_no WHERE district.commander = 'Robert A. Rubio'
Database: chicago_crime
Note: in 2018 refers to date like '%2018%'; ward with most population refers to Max(population); average number of incident per month refers to Divide(Count(ward_no), 12);
Question: What is the average number of incidents per month in 2018 in the ward with the most population?
SQL: SELECT count(ward.ward_no) / 12 AS average FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE crime.date LIKE '%2018%' AND ward.population = ( SELECT max(ward.population) FROM ward INNER JOIN crime ON ward.ward_no = crime.ward_no WHERE crime.date LIKE '%2018%' )
Database: chicago_crime
Note: incident with no arrest made refers to arrest = 'FALSE'; general description refers to primary_description; "BATTERY" is the primary_description; percentage = Divide (Count(iucr_no where primary_description = 'BATTERY'), Count(iucr_no)) * 100;
Question: Among all the incidents with no arrest made, what is the percentage of them having a generic description of "BATTERY" in the IUCR classification?
SQL: SELECT cast(sum(CASE WHEN iucr.primary_description = 'BATTERY' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*)FROM iucr INNER JOIN crime ON iucr.iucr_no = crime.iucr_no WHERE crime.arrest = 'FALSE'
Database: food_inspection
Note: restaurants' owners in California refer to owner_state = 'CA';
Question: How many restaurants' owners are in California?
SQL: SELECT count(owner_state) FROM businesses WHERE owner_state = 'CA'
Database: food_inspection
Note: met all requirements in the inspection refers to score = 100;
Question: How many restaurants have met all requirements in the inspection?
SQL: SELECT count(score) FROM inspections WHERE score = 100
Database: food_inspection
Note: inspections carried out in 2016 refer to YEAR(date) = 2016; routine inspections refer to type = 'Routine - Unscheduled';
Question: Among the inspections carried out in 2016, how many of them are routine?
SQL: SELECT count(`date`) FROM inspections WHERE strftime('%Y', `date`) = '2016' AND TYPE = 'Routine - Unscheduled'
Database: food_inspection
Note: met all requirements refers to inspections where score = 100;
Question: Please list the names of all the restaurants that have met all requirements in one inspection.
SQL: SELECT DISTINCT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score = 100
Database: food_inspection
Note: inspected in 2016 refers to YEAR(date) = 2016; San Francisco refers to city in ('San Francisco', 'SF' ,'S.F.', 'SAN FRANCISCO');
Question: Among the restaurants being inspected in 2016, how many of them are in San Francisco?
SQL: SELECT count(DISTINCT businesses.business_id) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE strftime('%Y', inspections.`date`) = '2016' AND businesses.city IN ('San Francisco', 'SAN FRANCISCO', 'SF', 'S.F.')
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; inspection on 2014/1/14 refers to date = '2014-01-14';
Question: What was the type of inspection Tiramisu Kitchen had on 2014/1/14?
SQL: SELECT inspections.type FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.`date` = '2014-01-14' AND businesses.name = 'Tiramisu Kitchen'
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; inspection on 2014/1/14 refers to date = '2014-01-14'; low risk violations refer to risk_category = 'Low Risk';
Question: How many low risk violations were found in the inspection on 2014/1/14 for Tiramisu Kitchen?
SQL: SELECT count(violations.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.`date` = '2014-01-14' AND businesses.name = 'Tiramisu Kitchen' AND violations.risk_category = 'Low Risk'
Database: food_inspection
Note: inspection in 2014 refers to year(date) = 2014; low risk violations refer to risk_category = 'Low Risk';
Question: Please list the names of the restaurants that had a low risk violation in inspections in 2014.
SQL: SELECT DISTINCT businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE strftime('%Y', violations.`date`) = '2014' AND violations.risk_category = 'Low Risk'
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; 2014/1/14 refers to date = '2014-01-14'; low risk violations refer to risk_category = 'Low Risk';
Question: What is the description of the low risk violation of Tiramisu Kitchen on 2014/1/14?
SQL: SELECT violations.description FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.`date` = '2014-01-14' AND businesses.name = 'Tiramisu Kitchen' AND violations.risk_category = 'Low Risk'
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; high risk violations refer to risk_category = 'High Risk';
Question: Please list the descriptions of all the high risk violations of Tiramisu Kitchen.
SQL: SELECT DISTINCT violations.description FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' AND businesses.name = 'Tiramisu Kitchen'
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; routine inspections refer to type = 'Routine - Unscheduled';
Question: How many routine inspections did Tiramisu Kitchen have?
SQL: SELECT count(inspections.business_id) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.type = 'Routine - Unscheduled' AND businesses.name = 'Tiramisu Kitchen'
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; routine inspections refer to type = 'Routine - Unscheduled'; score of over 70 refers to score > 70;
Question: Among the routine inspections of Tiramisu Kitchen, how many of them have a score of over 70?
SQL: SELECT count(businesses.business_id) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'Tiramisu Kitchen' AND inspections.type = 'Routine - Unscheduled' AND inspections.score > 70
Database: food_inspection
Note: Tiramisu Kitchen and OMNI S.F. Hotel - 2nd Floor Pantry are names of the business; more low risk violations refer to MAX(COUNT(risk_category = 'Low Risk'));
Question: Which restaurant had more low risk violation in inspections, Tiramisu Kitchen or OMNI S.F. Hotel - 2nd Floor Pantry?
SQL: SELECT CASE WHEN sum(CASE WHEN businesses.name = 'OMNI S.F. Hotel - 2nd Floor Pantry' THEN 1 ELSE 0 END) > sum(CASE WHEN businesses.name = 'Tiramisu Kitchen' THEN 1 ELSE 0 END) THEN 'OMNI S.F. Hotel - 2nd Floor Pantry' ELSE 'Tiramisu Kitchen' END AS RESULT FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'Low Risk'
Database: food_inspection
Note: restaurants in San Francisco refer to business_id where city in ('San Francisco', 'SF', 'S.F.', 'SAN FRANCISCO'); high risk violations refer to risk_category = 'High Risk';
Question: How many high risk violations do the restaurants in San Francisco have in total?
SQL: SELECT count(businesses.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.city IN ('San Francisco', 'SF', 'S.F.', 'SAN FRANCISCO') AND violations.risk_category = 'High Risk'
Database: food_inspection
Note: the highest total number of high risk violations refer to MAX(COUNT(risk_category = 'High Risk'));
Question: Which restaurant has the highest total number of high risk violations?
SQL: SELECT businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' GROUP BY businesses.name ORDER BY count(businesses.name) DESC LIMIT 1
Database: food_inspection
Note: avg(score);
Question: What is the average scores of Tiramisu Kitchen in all inspections?
SQL: SELECT avg(inspections.score) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'Tiramisu Kitchen'
Database: food_inspection
Note: the most number of inspections refers to MAX(COUNT(business_id)); Id number for that business refers to business_id;
Question: Which business had the most number of inspections? Give the Id number for that business.
SQL: SELECT business_id FROM inspections GROUP BY business_id ORDER BY count(business_id) DESC LIMIT 1
Database: food_inspection
Note: Id number for that business refers to business_id; the most number of violations refers to MAX(COUNT(business_id));
Question: Tell the Id number of the business with the most number of violations.
SQL: SELECT business_id FROM violations GROUP BY business_id ORDER BY count(business_id) DESC LIMIT 1
Database: food_inspection
Note: met all the required standards refers to score = 100; unscheduled routine inspection on 2016/9/28 refers to type = 'Routine - Unscheduled' where date = '2016-09-28';
Question: Give the name of the business which met all the required standards during the unscheduled routine inspection on 2016/9/28.
SQL: SELECT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score = 100 AND inspections.`date` = '2016-09-28' AND inspections.type = 'Routine - Unscheduled'
Database: food_inspection
Note: the most number of high risk violations refers to MAX(COUNT(business_id)) where risk_category = 'High';
Question: Which business had the most number of high risk violations? Give the name of the business.
SQL: SELECT businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' GROUP BY businesses.name ORDER BY count(businesses.name) DESC LIMIT 1
Database: food_inspection
Note: "Stacks Restaurant" is the name of the business; date = '2016-10-04';
Question: How many kinds of violations did "Stacks Restaurant" have on 2016/10/4?
SQL: SELECT count(DISTINCT violations.violation_type_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.name = 'Stacks Restaurant' AND violations.`date` = '2016-10-04'
Database: food_inspection
Note: "Chez Fayala, Inc." is the name of the business; moderate risk violation refers to risk_category = 'Moderate Risk'; date = '2016-07-01';
Question: Give the description of the moderate risk violation which "Chez Fayala, Inc." had on 2016/7/1.
SQL: SELECT violations.description FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.name = 'Chez Fayala, Inc.' AND violations.`date` = '2016-07-01' AND violations.risk_category = 'Moderate Risk'
Database: food_inspection
Note: the lowest score for unscheduled routine inspection refers to type = 'Routine - Unscheduled' where MIN(score); date = '2016-09-26';
Question: Which business had the lowest score for the unscheduled routine inspection on 2016/9/26? Give the name of the business.
SQL: SELECT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE score = ( SELECT min(score) FROM inspections WHERE `date` = '2016-09-26' AND TYPE = 'Routine - Unscheduled' ) AND inspections.`date` = '2016-09-26' AND inspections.type = 'Routine - Unscheduled'
Database: food_inspection
Note: the most number of inspections because of complaint refers to type = 'Complaint' where MAX(business_id);
Question: Provide the name of the business which had the most number of inspections because of complaint.
SQL: SELECT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.type = 'Complaint' GROUP BY businesses.name ORDER BY count(inspections.business_id) DESC LIMIT 1
Database: food_inspection
Note: "Soma Restaurant And Bar" is the name of the business; unscheduled routine inspections refer to type = 'Routine - Unscheduled';
Question: How many unscheduled routine inspections did "Soma Restaurant And Bar" have?
SQL: SELECT count(inspections.business_id) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'Soma Restaurant And Bar' AND inspections.type = 'Routine - Unscheduled'
Database: food_inspection
Note: the most number of the low risk violations refers to MAX(COUNT(business_id)) where risk_category = 'Low Risk' ;
Question: Give the address of the business with the most number of the low risk violations.
SQL: SELECT businesses.address FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'Low Risk' GROUP BY businesses.address ORDER BY count(violations.business_id) DESC LIMIT 1
Database: food_inspection
Note: low risk violation because of "Permit license or inspection report not posted" refers to risk_category = 'Low Risk' where description = 'Permit license or inspection report not posted'; business was the first one refers to name where MIN(date);
Question: Which business was the first one to get a low risk violation because of "Permit license or inspection report not posted"? Give the name of the business.
SQL: SELECT businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.`date` = ( SELECT min(`date`) FROM violations WHERE risk_category = 'Low Risk' AND description = 'Permit license or inspection report not posted' ) AND violations.risk_category = 'Low Risk' AND violations.description = 'Permit license or inspection report not posted'
Database: food_inspection
Question: For the business which got the most number of violations, how many inspections did it have?
SQL: SELECT count(inspections.business_id) FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id GROUP BY violations.business_id ORDER BY count(violations.business_id) DESC LIMIT 1
Database: food_inspection
Note: date = '2013-10-07';
Question: For the business whose business certificate number is 304977, how many violations did it have on 2013/10/7?
SQL: SELECT count(violations.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.business_certificate = '304977' AND violations.`date` = '2013-10-07'
Database: food_inspection
Note: DIVIDE(SUM(score where type = 'Routine - Unscheduled' and name = 'Chairman Bao'), COUNT(type = 'Routine - Unscheduled' where name = 'Chairman Bao'));
Question: What is the average score for "Chairman Bao" in all its unscheduled routine inspections?
SQL: SELECT cast(sum(CASE WHEN businesses.name = 'Chairman Bao' THEN inspections.score ELSE 0 END) AS REAL) / count(CASE WHEN inspections.type = 'Routine - Unscheduled' THEN inspections.score ELSE 0 END) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id
Database: food_inspection
Note: DIVIDE(COUNT(risk_category = 'Moderate Risk' where name = 'Melody Lounge'), COUNT(business_id where name = 'Melody Lounge')) as percentage;
Question: What percentage of the violations for "Melody Lounge" are moderate risks?
SQL: SELECT cast(sum(CASE WHEN violations.risk_category = 'Moderate Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / count(violations.business_id) FROM businesses INNER JOIN violations ON businesses.business_id = violations.business_id WHERE businesses.name = 'Melody Lounge'
Database: food_inspection
Note: eateries in Hayward refer city = 'HAYWARD';
Question: How many eateries are located in Hayward?
SQL: SELECT count(business_id) FROM businesses WHERE city = 'HAYWARD'
Database: food_inspection
Note: establishments have the same meaning as businesses; inspection score of no more than 50 refers to score < 50;
Question: How many establishments have an inspection score of no more than 50?
SQL: SELECT count(DISTINCT business_id) FROM inspections WHERE score < 50
Database: food_inspection
Note: eateries applied in 2012 refer to business_id where application_date between '2012-01-01' and '2012-12-31';
Question: How many eateries applied in 2012?
SQL: SELECT count(business_id) FROM businesses WHERE strftime('%Y', application_date) = '2012'
Database: food_inspection
Note: foodborne illness investigations refer to inspections where type = 'Foodborne Illness Investigation'; investigations in 2014 refers to date between '2014-01-01' and '2014-12-31';
Question: How many foodborne illness investigations were done in 2014?
SQL: SELECT count(business_id) FROM inspections WHERE strftime('%Y', `date`) = '2014' AND TYPE = 'Foodborne Illness Investigation'
Database: food_inspection
Note: 5 or more establishments COUNT(business_id) >= 5;
Question: How many owners have 5 or more establishments?
SQL: SELECT count(t1.owner_name) FROM ( SELECT owner_name FROM businesses GROUP BY owner_name HAVING count(owner_name) > 5 ) t1
Database: food_inspection
Note: establishments have the same meaning as businesses; met all of the required standards refers to score = 100; year(date) = 2013;
Question: What are the names of the establishments that met all of the required standards in 2013?
SQL: SELECT DISTINCT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE strftime('%Y', inspections.`date`) = '2013' AND inspections.score = 100
Database: food_inspection
Note: the highest health and safety hazards refer to risk_category = 'High Risk'; year(date) = 2016; establishments has the same meaning as businesses;
Question: In 2016, which city has the highest number of establishments with the highest health and safety hazards?
SQL: SELECT businesses.city FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE strftime('%Y', violations.`date`) = '2016' AND violations.risk_category = 'High Risk' GROUP BY businesses.city ORDER BY count(businesses.city) DESC LIMIT 1
Database: food_inspection
Note: the lowest inspection score refers to MIN(score);
Question: What is the name of the establishment with the lowest inspection score of all time?
SQL: SELECT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score = ( SELECT min(score) FROM inspections )