db_id
stringclasses
68 values
question
stringlengths
24
325
evidence
stringlengths
0
580
SQL
stringlengths
23
728
chicago_crime
How many districts are there in the police district building with a zip code of 60608?
district refers to district_name
SELECT COUNT(*) AS cnt FROM District WHERE zip_code = 60608
chicago_crime
Who is the crime against criminal sexual abuse?
"Criminal Sexual Abuse" is the title of crime
SELECT crime_against FROM FBI_Code WHERE title = 'Criminal Sexual Abuse'
chicago_crime
Which community has the highest number of neighborhoods?
community with highest number of neighborhoods refers to Max(Count(community_area_no)); community refers to community_area_name
SELECT T1.community_area_name FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no ORDER BY T2.community_area_no DESC LIMIT 1
chicago_crime
Who is the commanding officer in the district with the highest number of reported crimes where no arrest has been made?
where no arrest refers to arrest = 'FALSE'; highest number of crime refers to Max(Count(report_no)); commanding officer refers to commander
SELECT T2.commander FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.arrest = 'FALSE' GROUP BY T2.commander ORDER BY COUNT(T1.report_no) DESC LIMIT 1
chicago_crime
Between Deering and Near West districts, which district reported the most number of crime incidents that happened in a library?
"Deering" and "Near West" are both district_name; 'LIBRARY' is the location_description; district with the most number of crime Max(Count(district_no))
SELECT T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.district_name IN ('Deering', 'Near West') AND T2.location_description = 'LIBRARY' GROUP BY T1.district_name ORDER BY COUNT(T2.district_no) DESC LIMIT 1
chicago_crime
How many arrests have been made due to forcible entry burglary that took place in a day care center?
"BURGLARY" is the primary_description; 'FORCIBLE ENTRY' is the secondary_description; 'DAY CARE CENTER' is the location_description; arrests have been made refers to arrest = 'TRUE'
SELECT SUM(CASE WHEN T2.arrest = 'TRUE' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T2.location_description = 'DAY CARE CENTER' AND T1.secondary_description = 'FORCIBLE ENTRY' AND T1.primary_description = 'BURGLARY'
chicago_crime
What is the name of the district with the highest number of domestic violence cases?
domestic violence refers to domestic = 'TRUE'; highest number of case refers to Max(Count(district_no)); name of district refers to distric_name
SELECT T2.district_name FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.domestic = 'TRUE' GROUP BY T2.district_name ORDER BY COUNT(T1.district_no) DESC LIMIT 1
chicago_crime
In the least populated community, what is the most common location of all the reported crime incidents?
least populated refers to Min(Population); community refers to community_area_no; most common location refers to Max(Count(location_description))
SELECT T2.location_description FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no WHERE T1.population = ( SELECT MIN(population) FROM Community_Area ) AND T2.location_description IS NOT NULL GROUP BY T2.location_description
chicago_crime
How many violation of laws are there where no arrest has been made?
"The violation of laws " is the description of incidents; no arrest has been made refers to arrest = 'FALSE'
SELECT SUM(CASE WHEN T1.description LIKE '%The violation of laws%' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T2.Arrest = 'FALSE'
chicago_crime
What is the precise coordinate of the location where simple assault incidents happened the most in Chatham?
precise coordinates refers to latitude, longitude; 'Simple Assault' is the title of incident; 'Chatham' is the community_area_name; most incident happened refers to Max(Count(latitude, longitude))
SELECT T2.latitude, T2.longitude FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.title = 'Simple Assault' AND T3.community_area_name = 'Chatham' AND T3.community_area_no = 44 ORDER BY T2.latitude DESC, T2.longitude DESC LIMIT 1
chicago_crime
How many crime against society were reported in Englewood?
"Englewood" is the community_area_name; 'Society' is the crime_against
SELECT SUM(CASE WHEN T3.community_area_name = 'Englewood' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.crime_against = 'Society'
chicago_crime
What is the weekly average number of fraud incidents that were reported in January 2018? Provide the description of the location where the majority of fraud incidents occurred in the said month.
fraud incident refers to title = 'Fraud'; reported in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; description of location refers to location_description; weekly average refers to Divide (Count(report_no), 4); majority of incidents occurred refers to Max(Count(location_description))
SELECT CAST(COUNT(T1.fbi_code_no) AS REAL) / 4 FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018'
chicago_crime
What are the communities that are grouped together on the central side?
central side refers to side = 'Central'; community refers to community_area_name
SELECT community_area_name FROM Community_Area WHERE side = 'Central'
chicago_crime
Please list all of the contact information for the police district Near West.
"Near West" is the district_name; all contact information refers to phone, fax, tty, twitter
SELECT phone, fax, tty, twitter FROM District WHERE district_name = 'Near West'
chicago_crime
Who is responsible for crime cases in district Lincoln?
"Lincoln" is the district_name; responsible for crime case refers to commander
SELECT commander FROM District WHERE district_name = 'Lincoln'
chicago_crime
What is the percentage of severe cases that are related to sexual assault?
related to sexual assault refers to primary_description = 'CRIME SEXUAL ASSAULT'; severe case refers to index_code = 'I'; percentage = Divide (Count (iucr_no where primary_description = 'CRIME SEXUAL ASSAULT'), Count (iucr_no)) * 100
SELECT CAST(SUM(CASE WHEN primary_description = 'CRIM SEXUAL ASSAULT' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM IUCR WHERE index_code = 'I'
chicago_crime
What are the neighborhoods that are located in the North Center community area?
"North Center" is the community_area_name; neighborhoods refers to neighborhood_name
SELECT T2.neighborhood_name FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no WHERE T1.community_area_name = 'North Center'
chicago_crime
How many neighborhoods can be found in the Forest Glen community area?
"Forest Glen" is the community_area_name; neighborhoods refers to neighborhood_name
SELECT SUM(CASE WHEN T2.community_area_name = 'Forest Glen' THEN 1 ELSE 0 END) FROM Neighborhood AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no
chicago_crime
How many crime cases have been classified as "Weapons Violation" by the FBI?
"Weapons Violation" is the title of crime; crime cases refers to report_no;
SELECT SUM(CASE WHEN T2.title = 'Weapons Violation' THEN 1 ELSE 0 END) FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no
chicago_crime
Please list any three criminal sexual assault cases against persons where the criminals have been arrested.
"Criminal Sexual Assault" is the title of crime; against person refers to crime_against = 'Persons'; criminals have been arrested refers to arrest = 'TRUE'; cases refers to case_number
SELECT T2.case_number FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.title = 'Criminal Sexual Assault' AND T2.arrest = 'TRUE' AND T1.crime_against = 'Persons' LIMIT 3
chicago_crime
Please state the district name where incident number JB106545 took place.
incident number JB106545 refers to case_number = 'JB106545'
SELECT T1.case_number FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T2.title = 'Criminal Sexual Assault' AND T2.crime_against = 'Persons' AND T1.arrest = 'TRUE' LIMIT 3
chicago_crime
What is the general description for case number JB106010?
general description refers to primary_description
SELECT T1.primary_description FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T2.case_number = 'JB106010'
chicago_crime
Please name three communities that experience the fraud incident.
communities refers to community_area_name; 'Fraud Incident' is the title of crime
SELECT T3.community_area_name FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.title = 'Criminal Sexual Assault' LIMIT 3
chicago_crime
What was the major type of crime that happened in the Rogers Park community area?
"Rogers Park" is the community_area_name; major type of crime refers to title
SELECT T1.fbi_code_no, T1.title FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T3.community_area_name = 'Rogers Park' GROUP BY T1.fbi_code_no, T1.title
chicago_crime
At which district did the multiple homicide case number JB120039 occurred?
multiple homicide refers to Count(case_number) > 1; district refers to district_name
SELECT T1.district_no, T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T2.case_number = 'JB120039' GROUP BY T1.district_no, T1.district_name
chicago_crime
What is the percentage of crime cases that have been classified as "drug abuse" by the FBI and happened on the street?
"Drug Abuse" is the title of crime; happened on the street refers to location_description = 'STREET';  percentage = Divide (Count(fbi_code_no where location_description = 'STREET'), Count(fbi_code_no)) * 100
SELECT CAST(SUM(CASE WHEN T2.title = 'Drug Abuse' AND T1.location_description = 'STREET' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.fbi_code_no) FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no
chicago_crime
Provide the ward number with the highest population.
highest population refers to Max(Population); ward number refers to ward_no
SELECT ward_no FROM Ward ORDER BY Population DESC LIMIT 1
chicago_crime
What is the beat and location description of the case JB112212?
case JB112212 refers to case_number = 'JB112212'
SELECT beat, location_description FROM Crime WHERE case_number = 'JB112212'
chicago_crime
Give the FBI code for the crime described by "The killing of one human being by another."
"The killing of one human being by another" is the description; FBI code refers to fbi_code_no
SELECT fbi_code_no FROM FBI_Code WHERE description = 'The killing of one human being by another.'
chicago_crime
Provide at least 5 ward office addresses associated with the crimes that happened in the community of Montclare.
"Montclare" is the community_area_name
SELECT T3.ward_office_address FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN Ward AS T3 ON T2.ward_no = T3.ward_no WHERE T1.community_area_name = 'Montclare' GROUP BY T3.ward_office_address LIMIT 5
chicago_crime
List down the district's commander associated with the crime that happened at the yard and has a beat of 532.
beat of 532 refers to beat = 532; happened in the Yard refers to location_description = 'YARD'; district commander refers to commander
SELECT T2.address, T2.commander FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.location_description = 'YARD' AND T1.beat = 532
chicago_crime
What is the neighborhood name in the community area of Lake View?
"Lake View" is the community_area_name
SELECT T2.neighborhood_name FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no WHERE T1.community_area_name = 'Lake View'
chicago_crime
Name the neighborhood of the community area in crime with report number 23843?
neighborhood refers to neighborhood_name; '23778' is the report_no
SELECT T3.neighborhood_name FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN Neighborhood AS T3 ON T2.community_area_no = T3.community_area_no WHERE T2.report_no = 23778
chicago_crime
What is the FBI description of the crime for report number 23778?
"23778" is the report_no; FBI description refers to description
SELECT T1.description FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T2.report_no = 23843
chicago_crime
List down the report number of crimes associated with the district commander named Jill M. Stevens.
report number refers report_no; 'Jill M. Stevens" is the commander
SELECT SUM(CASE WHEN T1.commander = 'Jill M. Stevens' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no
chicago_crime
Among the crimes happened in the neighborhood called "Avalon Park", what is the percentage of crimes that happened inside the house?
"Avalon Park" is the neghborhood_name; happened inside the house refers to location_description = 'HOUSE'; percentage = Divide (Count(location_description = 'HOUSE'), Count(location_description)) * 100
SELECT CAST(SUM(CASE WHEN T2.location_description = 'HOUSE' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.location_description) AS persent FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN Neighborhood AS T3 ON T2.community_area_no = T3.community_area_no WHERE T3.neighborhood_name = 'Avalon Park'
chicago_crime
What is the full name of the alderman of ward no.21?
full name of alderman refers to alderman_first_name, alderman_last_name, alderman_name_suffix
SELECT alderman_first_name, alderman_last_name, alderman_name_suffix FROM Ward WHERE ward_no = 21
chicago_crime
What is the ward ID of the most crowded ward?
most crowded ward refers to Max(Population)
SELECT ward_no FROM Ward ORDER BY Population DESC LIMIT 1
chicago_crime
How many incidents have the general description of "ASSAULT" in the IUCR classification?
general description refers to primary_description; 'ASSAULT' is the primary_description; incidents refers to iucr_no
SELECT COUNT(*) FROM IUCR WHERE primary_description = 'ASSAULT'
chicago_crime
How many incidents are considered "severe" in the IUCR classification?
severe refers to index_code = 'I'; incidents refers to iucr_no
SELECT COUNT(*) FROM IUCR WHERE index_code = 'I'
chicago_crime
Among the crimes with no arrest made, how many of them happened in the ward represented by alderman Pat Dowell?
no arrest has been made refers to arrest = 'FALSE'
SELECT SUM(CASE WHEN T1.alderman_last_name = 'Dowell' THEN 1 ELSE 0 END) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.arrest = 'FALSE' AND T1.alderman_first_name = 'Pat'
chicago_crime
Which alderman represents the ward with the most number of crimes in January, 2018? Please give his or her full name.
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
SELECT T1.ward_no, T1.alderman_first_name, T1.alderman_last_name, T1.alderman_name_suffix FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' GROUP BY T1.ward_no ORDER BY COUNT(T1.ward_no) DESC LIMIT 1
chicago_crime
Please list the location coordinates of all the incidents that had happened in the ward represented by alderman Pat Dowell.
location coordinates refers to latitude, longitude
SELECT T2.latitude, T2.longitude FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T1.alderman_first_name = 'Pat' AND T1.alderman_last_name = 'Dowell' AND T2.latitude IS NOT NULL AND T2.longitude IS NOT NULL
chicago_crime
The ward represented by which alderman had more incidents in January, 2018, Pat Dowell or Sophia King?
January, 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; had more incidents refers to Max(Count(ward_no))
SELECT T1.alderman_first_name, T1.alderman_last_name, COUNT(T1.ward_no) AS num FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE (SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' AND T1.alderman_first_name = 'Pat' AND T1.alderman_last_name = 'Dowell') OR (T1.alderman_first_name = 'Sophia' AND T1.alderman_last_name = 'King') GROUP BY T1.ward_no
chicago_crime
Please list the case numbers of all the incidents with the generic description of "BATTERY" in the IUCR classification.
general description refers to primary_description; 'BATTERY' is the primary_description
SELECT T2.case_number FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'
chicago_crime
Among the incidents with the generic description of "BATTERY" in the IUCR classification, how many of them do not have arrests made?
general description refers to primary_description; 'BATTERY' is the primary_description; do not have arrest made refers to arrest = 'FALSE'
SELECT SUM(CASE WHEN T2.arrest = 'FALSE' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'
chicago_crime
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.
"Homicide 1st & 2nd Degree" is the title
SELECT T2.case_number FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.title = 'Homicide 1st & 2nd Degree'
chicago_crime
Among the incidents in January, 2018, how many of them were stated "against Property" in the FBI classification?
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; against property refers to crime_against = 'Property'
SELECT SUM(CASE WHEN SUBSTR(T2.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.crime_against = 'Property' AND SUBSTR(T2.date, 1, 1) = '1'
chicago_crime
District commander Robert A. Rubio was responsible for how many incidents in January, 2018?
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'
SELECT SUM(CASE WHEN SUBSTR(T2.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander = 'Robert A. Rubio' AND SUBSTR(T2.date, 1, 1) = '1'
chicago_crime
Which district commander was responsible for more incidents in January, 2018, Robert A. Rubio or Glenn White?
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))
SELECT T1.commander FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander IN ('Robert A. Rubio', 'Glenn White') AND SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' GROUP BY T1.commander
chicago_crime
Please list the blocks where all the incidents in the district commanded by Robert A. Rubio took place.
"Robert A. Rubio" is the commander
SELECT T2.block FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander = 'Robert A. Rubio'
chicago_crime
What is the average number of incidents per month in 2018 in the ward with the most population?
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)
SELECT COUNT(T1.ward_no) / 12 AS average FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.date LIKE '%2018%' AND T1.Population = ( SELECT MAX(T1.Population) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.date LIKE '%2018%' )
chicago_crime
Among all the incidents with no arrest made, what is the percentage of them having a generic description of "BATTERY" in the IUCR classification?
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
SELECT CAST(SUM(CASE WHEN T1.primary_description = 'BATTERY' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*)FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T2.arrest = 'FALSE'
food_inspection
How many restaurants' owners are in California?
restaurants' owners in California refer to owner_state = 'CA';
SELECT COUNT(owner_state) FROM businesses WHERE owner_state = 'CA'
food_inspection
How many restaurants have met all requirements in the inspection?
met all requirements in the inspection refers to score = 100;
SELECT COUNT(score) FROM inspections WHERE score = 100
food_inspection
Please list the names of all the restaurants that have met all requirements in one inspection.
met all requirements refers to inspections where score = 100;
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100
food_inspection
Please list the descriptions of all the high risk violations of Tiramisu Kitchen.
Tiramisu Kitchen is the name of the business; high risk violations refer to risk_category = 'High Risk';
SELECT DISTINCT T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' AND T2.name = 'Tiramisu Kitchen'
food_inspection
How many routine inspections did Tiramisu Kitchen have?
Tiramisu Kitchen is the name of the business; routine inspections refer to type = 'Routine - Unscheduled';
SELECT COUNT(T1.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.type = 'Routine - Unscheduled' AND T2.name = 'Tiramisu Kitchen'
food_inspection
Among the routine inspections of Tiramisu Kitchen, how many of them have a score of over 70?
Tiramisu Kitchen is the name of the business; routine inspections refer to type = 'Routine - Unscheduled'; score of over 70 refers to score > 70;
SELECT COUNT(T2.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen' AND T1.type = 'Routine - Unscheduled' AND T1.score > 70
food_inspection
Which restaurant had more low risk violation in inspections, Tiramisu Kitchen or OMNI S.F. Hotel - 2nd Floor Pantry?
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'));
SELECT CASE WHEN SUM(CASE WHEN T2.name = 'OMNI S.F. Hotel - 2nd Floor Pantry' THEN 1 ELSE 0 END) > SUM(CASE WHEN T2.name = 'Tiramisu Kitchen' THEN 1 ELSE 0 END) THEN 'OMNI S.F. Hotel - 2nd Floor Pantry' ELSE 'Tiramisu Kitchen' END AS result FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'Low Risk'
food_inspection
How many high risk violations do the restaurants in San Francisco have in total?
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';
SELECT COUNT(T2.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.city IN ('San Francisco', 'SF', 'S.F.', 'SAN FRANCISCO') AND T1.risk_category = 'High Risk'
food_inspection
Which restaurant has the highest total number of high risk violations?
the highest total number of high risk violations refer to MAX(COUNT(risk_category = 'High Risk'));
SELECT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' GROUP BY T2.name ORDER BY COUNT(T2.name) DESC LIMIT 1
food_inspection
What is the average scores of Tiramisu Kitchen in all inspections?
avg(score);
SELECT AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen'
food_inspection
Which business had the most number of inspections? Give the Id number for that business.
the most number of inspections refers to MAX(COUNT(business_id)); Id number for that business refers to business_id;
SELECT business_id FROM inspections GROUP BY business_id ORDER BY COUNT(business_id) DESC LIMIT 1
food_inspection
Tell the Id number of the business with the most number of violations.
Id number for that business refers to business_id; the most number of violations refers to MAX(COUNT(business_id));
SELECT business_id FROM violations GROUP BY business_id ORDER BY COUNT(business_id) DESC LIMIT 1
food_inspection
Which business had the most number of high risk violations? Give the name of the business.
the most number of high risk violations refers to MAX(COUNT(business_id)) where risk_category = 'High';
SELECT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' GROUP BY T2.name ORDER BY COUNT(T2.name) DESC LIMIT 1
food_inspection
Provide the name of the business which had the most number of inspections because of complaint.
the most number of inspections because of complaint refers to type = 'Complaint' where MAX(business_id);
SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.type = 'Complaint' GROUP BY T2.name ORDER BY COUNT(T1.business_id) DESC LIMIT 1
food_inspection
How many unscheduled routine inspections did "Soma Restaurant And Bar" have?
"Soma Restaurant And Bar" is the name of the business; unscheduled routine inspections refer to type = 'Routine - Unscheduled';
SELECT COUNT(T1.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Soma Restaurant And Bar' AND T1.type = 'Routine - Unscheduled'
food_inspection
Give the address of the business with the most number of the low risk violations.
the most number of the low risk violations refers to MAX(COUNT(business_id)) where risk_category = 'Low Risk' ;
SELECT T2.address FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'Low Risk' GROUP BY T2.address ORDER BY COUNT(T1.business_id) DESC LIMIT 1
food_inspection
For the business which got the most number of violations, how many inspections did it have?
SELECT COUNT(T2.business_id) FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id GROUP BY T1.business_id ORDER BY COUNT(T1.business_id) DESC LIMIT 1
food_inspection
What is the average score for "Chairman Bao" in all its unscheduled routine inspections?
DIVIDE(SUM(score where type = 'Routine - Unscheduled' and name = 'Chairman Bao'), COUNT(type = 'Routine - Unscheduled' where name = 'Chairman Bao'));
SELECT CAST(SUM(CASE WHEN T2.name = 'Chairman Bao' THEN T1.score ELSE 0 END) AS REAL) / COUNT(CASE WHEN T1.type = 'Routine - Unscheduled' THEN T1.score ELSE 0 END) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id
food_inspection
What percentage of the violations for "Melody Lounge" are moderate risks?
DIVIDE(COUNT(risk_category = 'Moderate Risk' where name = 'Melody Lounge'), COUNT(business_id where name = 'Melody Lounge')) as percentage;
SELECT CAST(SUM(CASE WHEN T2.risk_category = 'Moderate Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.business_id) FROM businesses AS T1 INNER JOIN violations AS T2 ON T1.business_id = T2.business_id WHERE T1.name = 'Melody Lounge'
food_inspection
How many eateries are located in Hayward?
eateries in Hayward refer city = 'HAYWARD';
SELECT COUNT(business_id) FROM businesses WHERE city = 'HAYWARD'
food_inspection
How many establishments have an inspection score of no more than 50?
establishments have the same meaning as businesses; inspection score of no more than 50 refers to score < 50;
SELECT COUNT(DISTINCT business_id) FROM inspections WHERE score < 50
food_inspection
How many owners have 5 or more establishments?
5 or more establishments COUNT(business_id) > = 5;
SELECT COUNT(T1.owner_name) FROM ( SELECT owner_name FROM businesses GROUP BY owner_name HAVING COUNT(owner_name) > 5 ) T1
food_inspection
What is the name of the establishment with the lowest inspection score of all time?
the lowest inspection score refers to MIN(score);
SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = ( SELECT MIN(score) FROM inspections )
food_inspection
How many high risks violations did the Tiramisu Kitchen violate?
Tiramisu Kitchen is the name of the business; high risks violations refer to risk_category = 'High Risk';
SELECT COUNT(T1.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen' AND T1.risk_category = 'High Risk'
food_inspection
How many establishments with the tax code H24 have complaint inspections of 5 or more?
establishments with the tax code H24 refer to business_id where tax_code = 'H24'; complaint inspections of 5 or more refer to inspections where type = 'Complaint' and COUNT(business_id) ≥ 5;
SELECT COUNT(*) FROM ( SELECT T1.business_id FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.tax_code = 'H24' AND T1.type = 'Complaint' GROUP BY T1.business_id HAVING COUNT(T1.business_id) > 5 ) T3
food_inspection
What is the average score of the establishments owned by the owner with the highest number of establishments?
average score refers avg(score); owner with the highest number of establishments refers to owner_name where MAX(COUNT(business_id));
SELECT AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id GROUP BY T2.owner_name ORDER BY COUNT(T2.business_id) DESC LIMIT 1
food_inspection
Among the top 5 owners with highest number of establishments, which owner has the highest number of high risk violations? Give the name of the owner.
5 owners with highest number of establishments refer to owner_name where MAX(COUNT(business_id)) LIMIT 5; the highest number of high risk violations refers to MAX(COUNT(risk_category = 'High Risk'));
SELECT T4.owner_name FROM violations AS T3 INNER JOIN businesses AS T4 ON T3.business_id = T4.business_id INNER JOIN ( SELECT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id GROUP BY T2.owner_name ORDER BY COUNT(T1.business_id) DESC LIMIT 5 ) AS T5 ON T4.owner_name = T5.owner_name WHERE T3.risk_category = 'High Risk' GROUP BY T4.owner_name ORDER BY COUNT(T3.risk_category) DESC LIMIT 1
food_inspection
Which establishment has the highest number of inspections done? Give the name of the establishment and calculate for its average score per inspection.
establishment refers to business_id; the highest number of inspections refers to MAX(COUNT(business_id)); avg(score);
SELECT T2.name, AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id GROUP BY T2.name ORDER BY COUNT(T2.business_id) DESC LIMIT 1
food_inspection
How many eateries had low risk for violation with unpermitted food facility description?
eateries represent business; low risk for violation refers to risk_category = 'Low Risk';
SELECT COUNT(DISTINCT business_id) FROM violations WHERE risk_category = 'Low Risk' AND description = 'Unpermitted food facility'
food_inspection
Provide eateries' IDs, risk categories and descriptions with violation ID of 103101.
eateries' IDs refer to business_id; violation ID of 103101 refers to violation_type_id = '103101';
SELECT business_id, risk_category, description FROM violations WHERE violation_type_id = '103101'
food_inspection
Mention the violation type ID and description of high risk category for STARBUCKS.
STARBUCKS is the name of the business; high risk category refers to risk_category = 'High Risk';
SELECT DISTINCT T1.violation_type_id, T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'STARBUCKS' AND T1.risk_category = 'High Risk'
food_inspection
Provide eateries' IDs, names and addresses which were inspected on 30th July, 2016.
eateries' IDs inspected on 30th July, 2016 refer to business_id where business_id is not null and date = '2016-07-30';
SELECT DISTINCT T2.business_id, T2.name, T2.address FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.date = '2016-07-30'
food_inspection
Provide the names, risk categories and descriptions for the eateries with violation type ID of 103111.
eateries refer to business_id;
SELECT T2.name, T1.risk_category, T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.violation_type_id = '103111'
food_inspection
What was the inspection type when El Aji Peruvian Restaurant got highest inspection score?
El Aji Peruvian Restaurant is the name of the business; highest inspection score refers to MAX(score);
SELECT T1.type FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'El Aji Peruvian Restaurant' ORDER BY T1.score DESC LIMIT 1
food_inspection
Who were the owners of eateries which had highest health hazard by improper cooking time or temperatures?
owners of eateries refer to owner_name; highest health hazard by improper cooking time or temperatures refers to risk_category = 'High Risk' and description = 'Improper cooking time or temperatures';
SELECT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' AND T1.description = 'Improper cooking time or temperatures'
food_inspection
List the names and business certificates of the eateries which got inspection score under 50.
eateries which got inspection score under 50 refer to business_id where score < 50;
SELECT T2.name, T2.business_id FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score < 50
food_inspection
How many of the businesses are located at 1825 POST St #223, San Francisco?
1825 POST St #223 refers to address = '1825 POST St #223', San Francisco is the name of the city;
SELECT COUNT(business_id) FROM businesses WHERE address = '1825 POST St #223' AND city = 'SAN FRANCISCO'
food_inspection
List down the owner's name with a zip code 94104.
zip code 94104 refers to owner_zip = '94104';
SELECT DISTINCT owner_name FROM businesses WHERE owner_zip = '94104'
food_inspection
What is the total number of businesses with a tax code H25?
SELECT COUNT(tax_code) FROM businesses WHERE tax_code = 'H25'
food_inspection
List owner's name of businesses with a 100 score.
owner's name of businesses refers to owner_name;
SELECT DISTINCT T2.owner_name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100
food_inspection
Among the businesses with score that ranges from 70 to 80, list their violation type ID and risk category.
businesses with score that ranges from 70 to 80 refer to business_id where score between 80 and 90;
SELECT DISTINCT T1.violation_type_id, T1.risk_category FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id INNER JOIN inspections AS T3 ON T2.business_id = T3.business_id WHERE T3.score BETWEEN 70 AND 80
food_inspection
List the tax code and inspection type of the business named "Rue Lepic".
"Rue Lepic" is the name of the business;
SELECT DISTINCT T3.tax_code, T2.type FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN businesses AS T3 ON T2.business_id = T3.business_id WHERE T3.name = 'Rue Lepic'
food_inspection
Among the owners from Cameron Park, what is the business name of the business with a score of 100?
Cameron Park is a name of city;
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.owner_city = 'Cameron Park' AND T1.score = 100
food_inspection
List the business' name and risk category of businesses with a score greater than the 80% of average score of all businesses.
score greater than the 80% of average score of all businesses refers to score > MULTIPLY(0.8, avg(score) from inspections);
SELECT DISTINCT T1.name, T3.risk_category FROM businesses AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN violations AS T3 ON T1.business_id = T3.business_id WHERE T2.score > 0.8 * ( SELECT AVG(score) FROM inspections )
craftbeer
Which distinct state makes beer that has the least amount of bitterness?
SELECT DISTINCT T2.state, T1.ibu FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T1.ibu IS NOT NULL AND T1.ibu = ( SELECT MIN(ibu) FROM beers )
craftbeer
Where in New York can you locate the brewery that makes the bitterest beer? List both the brewery's name and the name of the city.
The more IBU, the more bitter the beer is, bitterest means highest IBU.
SELECT T2.name, T2.city FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.state = 'NY' ORDER BY T1.ibu DESC LIMIT 1
craftbeer
What is the average alcohol content per 12-ounce beer bottle produced by Boston Beer Company?
SELECT AVG(T1.abv) FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.name = 'Boston Beer Company' AND T1.ounces = 12