problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: Between Deering and Near West districts, which district reported the most number of crime incidents that happened in a library?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: How many arrests have been made due to forcible entry burglary that took place in a day care center?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: What is the name of the district with the highest number of domestic violence cases?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: In the least populated community, what is the most common location of all the reported crime incidents?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: How many violation of laws are there where no arrest has been made?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: What is the precise coordinate of the location where simple assault incidents happened the most in Chatham?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: In the South side community, what is the name of the community with the most reported incidents of unlawful taking, carrying, leading, or riding away of property from the possession or constructive possession of another person?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_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 T3.side = 'South' AND T1.description = 'The unlawful taking, carrying, leading, or riding away of property FROM the possession or constructive possession of another person.' GROUP BY T3.community_area_name ORDER BY COUNT(T1.fbi_code_no) DESC LIMIT 1
Write SQL query to solve given problem: How many crime against society were reported in Englewood?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Please list any three community areas with a population of more than 50,000.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT community_area_name FROM Community_Area WHERE population > 50000 LIMIT 3
Write SQL query to solve given problem: What are the communities that are grouped together on the central side?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT community_area_name FROM Community_Area WHERE side = 'Central'
Write SQL query to solve given problem: What is the difference between the number of communities that are located on the north and south sides with a population of more than 30,000?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT SUM(CASE WHEN side = 'South ' THEN 1 ELSE 0 END) - SUM(CASE WHEN side = 'North' THEN 1 ELSE 0 END) AS DIFF FROM Community_Area WHERE population > 300000
Write SQL query to solve given problem: Please list all of the contact information for the police district Near West.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT phone, fax, tty, twitter FROM District WHERE district_name = 'Near West'
Write SQL query to solve given problem: Who is responsible for crime cases in district Lincoln?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT commander FROM District WHERE district_name = 'Lincoln'
Write SQL query to solve given problem: What is the general and specific description of incident 275?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT primary_description, secondary_description FROM IUCR WHERE iucr_no = 275
Write SQL query to solve given problem: What is the percentage of severe cases that are related to sexual assault?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: What are the neighborhoods that are located in the North Center community area?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: How many neighborhoods can be found in the Forest Glen community area?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: What is the total population of the neighborhoods Avondale Gardens, Irving Park, Kilbourn Park, Merchant Park, Old Irving Park, and The Villa?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT SUM(T2.population) AS sum FROM Neighborhood AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no WHERE T1.neighborhood_name = 'Avondale Gardens' OR T1.neighborhood_name = 'Irving Park' OR T1.neighborhood_name = 'Kilbourn Park' OR T1.neighborhood_name = 'Merchant Park' OR T1.neighborhood_name = 'Old Irving Park' OR T1.neighborhood_name = 'The Villa'
Write SQL query to solve given problem: How many crime cases have been classified as "Weapons Violation" by the FBI?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Please list any three criminal sexual assault cases against persons where the criminals have been arrested.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Please state the district name where incident number JB106545 took place.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: What is the general description for case number JB106010?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Please name three communities that experience the fraud incident.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_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
Write SQL query to solve given problem: What was the major type of crime that happened in the Rogers Park community area?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: At which district did the multiple homicide case number JB120039 occurred?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: What is the percentage of crime cases that have been classified as "drug abuse" by the FBI and happened on the street?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Provide the ward number with the highest population.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT ward_no FROM Ward ORDER BY Population DESC LIMIT 1
Write SQL query to solve given problem: What is the beat and location description of the case JB112212?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT beat, location_description FROM Crime WHERE case_number = 'JB112212'
Write SQL query to solve given problem: Give the FBI code for the crime described by "The killing of one human being by another.". Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT fbi_code_no FROM FBI_Code WHERE description = 'The killing of one human being by another.'
Write SQL query to solve given problem: Provide at least 5 ward office addresses associated with the crimes that happened in the community of Montclare.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: List down the district's commander associated with the crime that happened at the yard and has a beat of 532.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: What is the neighborhood name in the community area of Lake View?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Name the neighborhood of the community area in crime with report number 23843?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: What is the FBI description of the crime for report number 23778?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: List down the report number of crimes associated with the district commander named Jill M. Stevens.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Among the crimes happened in the neighborhood called "Avalon Park", what is the percentage of crimes that happened inside the house?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: What is the full name of the alderman of ward no.21?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT alderman_first_name, alderman_last_name, alderman_name_suffix FROM Ward WHERE ward_no = 21
Write SQL query to solve given problem: What is the ward ID of the most crowded ward?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT ward_no FROM Ward ORDER BY Population DESC LIMIT 1
Write SQL query to solve given problem: How many incidents have the general description of "ASSAULT" in the IUCR classification?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT COUNT(*) FROM IUCR WHERE primary_description = 'ASSAULT'
Write SQL query to solve given problem: How many incidents are considered "severe" in the IUCR classification?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT COUNT(*) FROM IUCR WHERE index_code = 'I'
Write SQL query to solve given problem: Among the crimes with no arrest made, how many of them happened in the ward represented by alderman Pat Dowell?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Which alderman represents the ward with the most number of crimes in January, 2018? Please give his or her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Among the crimes in the ward with the most population, how many of them are cases of domestic violence?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
SELECT COUNT(T1.ward_no) AS num FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.domestic = 'TRUE' ORDER BY T1.Population = ( SELECT Population FROM Ward ORDER BY Population DESC LIMIT 1 )
Write SQL query to solve given problem: Please list the location coordinates of all the incidents that had happened in the ward represented by alderman Pat Dowell.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: The ward represented by which alderman had more incidents in January, 2018, Pat Dowell or Sophia King?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Please list the case numbers of all the incidents with the generic description of "BATTERY" in the IUCR classification.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Among the incidents with the generic description of "BATTERY" in the IUCR classification, how many of them do not have arrests made?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Among the incidents in January, 2018, how many of them were stated "against Property" in the FBI classification?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: District commander Robert A. Rubio was responsible for how many incidents in January, 2018?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: Which district commander was responsible for more incidents in January, 2018, Robert A. Rubio or Glenn White?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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
Write SQL query to solve given problem: Please list the blocks where all the incidents in the district commanded by Robert A. Rubio took place.. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: What is the average number of incidents per month in 2018 in the ward with the most population?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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%' )
Write SQL query to solve given problem: Among all the incidents with no arrest made, what is the percentage of them having a generic description of "BATTERY" in the IUCR classification?. Keep the solution inside sql tag ```sql [SQL-Query] ```
chicago_crime
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'
Write SQL query to solve given problem: How many restaurants' owners are in California?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(owner_state) FROM businesses WHERE owner_state = 'CA'
Write SQL query to solve given problem: How many restaurants have met all requirements in the inspection?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(score) FROM inspections WHERE score = 100
Write SQL query to solve given problem: Among the inspections carried out in 2016, how many of them are routine?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(`date`) FROM inspections WHERE STRFTIME('%Y', `date`) = '2016' AND type = 'Routine - Unscheduled'
Write SQL query to solve given problem: Please list the names of all the restaurants that have met all requirements in one inspection.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100
Write SQL query to solve given problem: Among the restaurants being inspected in 2016, how many of them are in San Francisco?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(DISTINCT T2.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2016' AND T2.city IN ('San Francisco', 'SAN FRANCISCO', 'SF', 'S.F.')
Write SQL query to solve given problem: What was the type of inspection Tiramisu Kitchen had on 2014/1/14?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T1.type FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = '2014-01-14' AND T2.name = 'Tiramisu Kitchen'
Write SQL query to solve given problem: How many low risk violations were found in the inspection on 2014/1/14 for Tiramisu Kitchen?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(T1.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = '2014-01-14' AND T2.name = 'Tiramisu Kitchen' AND T1.risk_category = 'Low Risk'
Write SQL query to solve given problem: Please list the names of the restaurants that had a low risk violation in inspections in 2014.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT DISTINCT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2014' AND T1.risk_category = 'Low Risk'
Write SQL query to solve given problem: What is the description of the low risk violation of Tiramisu Kitchen on 2014/1/14?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = '2014-01-14' AND T2.name = 'Tiramisu Kitchen' AND T1.risk_category = 'Low Risk'
Write SQL query to solve given problem: Please list the descriptions of all the high risk violations of Tiramisu Kitchen.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: How many routine inspections did Tiramisu Kitchen have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: Among the routine inspections of Tiramisu Kitchen, how many of them have a score of over 70?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: Which restaurant had more low risk violation in inspections, Tiramisu Kitchen or OMNI S.F. Hotel - 2nd Floor Pantry?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: How many high risk violations do the restaurants in San Francisco have in total?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: Which restaurant has the highest total number of high risk violations?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: What is the average scores of Tiramisu Kitchen in all inspections?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: Which business had the most number of inspections? Give the Id number for that business.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT business_id FROM inspections GROUP BY business_id ORDER BY COUNT(business_id) DESC LIMIT 1
Write SQL query to solve given problem: Tell the Id number of the business with the most number of violations.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT business_id FROM violations GROUP BY business_id ORDER BY COUNT(business_id) DESC LIMIT 1
Write SQL query to solve given problem: Give the name of the business which met all the required standards during the unscheduled routine inspection on 2016/9/28.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100 AND T1.`date` = '2016-09-28' AND T1.type = 'Routine - Unscheduled'
Write SQL query to solve given problem: Which business had the most number of high risk violations? Give the name of the business.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: How many kinds of violations did "Stacks Restaurant" have on 2016/10/4?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(DISTINCT T1.violation_type_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Stacks Restaurant' AND T1.`date` = '2016-10-04'
Write SQL query to solve given problem: Give the description of the moderate risk violation which "Chez Fayala, Inc." had on 2016/7/1.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Chez Fayala, Inc.' AND T1.`date` = '2016-07-01' AND T1.risk_category = 'Moderate Risk'
Write SQL query to solve given problem: Which business had the lowest score for the unscheduled routine inspection on 2016/9/26? Give the name of the business.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE score = ( SELECT MIN(score) FROM inspections WHERE `date` = '2016-09-26' AND type = 'Routine - Unscheduled' ) AND T1.`date` = '2016-09-26' AND T1.type = 'Routine - Unscheduled'
Write SQL query to solve given problem: Provide the name of the business which had the most number of inspections because of complaint.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: How many unscheduled routine inspections did "Soma Restaurant And Bar" have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: Give the address of the business with the most number of the low risk violations.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = ( SELECT MIN(`date`) FROM violations WHERE risk_category = 'Low Risk' AND description = 'Permit license or inspection report not posted' ) AND T1.risk_category = 'Low Risk' AND T1.description = 'Permit license or inspection report not posted'
Write SQL query to solve given problem: For the business which got the most number of violations, how many inspections did it have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: For the business whose business certificate number is 304977, how many violations did it have on 2013/10/7?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(T1.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.business_certificate = '304977' AND T1.`date` = '2013-10-07'
Write SQL query to solve given problem: What is the average score for "Chairman Bao" in all its unscheduled routine inspections?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: What percentage of the violations for "Melody Lounge" are moderate risks?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: How many eateries are located in Hayward?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(business_id) FROM businesses WHERE city = 'HAYWARD'
Write SQL query to solve given problem: How many establishments have an inspection score of no more than 50?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(DISTINCT business_id) FROM inspections WHERE score < 50
Write SQL query to solve given problem: How many eateries applied in 2012?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(business_id) FROM businesses WHERE STRFTIME('%Y', application_date) = '2012'
Write SQL query to solve given problem: How many foodborne illness investigations were done in 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(business_id) FROM inspections WHERE STRFTIME('%Y', `date`) = '2014' AND type = 'Foodborne Illness Investigation'
Write SQL query to solve given problem: How many owners have 5 or more establishments?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(T1.owner_name) FROM ( SELECT owner_name FROM businesses GROUP BY owner_name HAVING COUNT(owner_name) > 5 ) T1
Write SQL query to solve given problem: What are the names of the establishments that met all of the required standards in 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2013' AND T1.score = 100
Write SQL query to solve given problem: In 2016, which city has the highest number of establishments with the highest health and safety hazards?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T2.city FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2016' AND T1.risk_category = 'High Risk' GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1
Write SQL query to solve given problem: What is the name of the establishment with the lowest inspection score of all time?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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 )
Write SQL query to solve given problem: How many high risks violations did the Tiramisu Kitchen violate?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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'
Write SQL query to solve given problem: How many establishments with the tax code H24 have complaint inspections of 5 or more?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
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
Write SQL query to solve given problem: In 2013, what are the names of the establishments with contaminated or adulterated food?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2013' AND T1.description = 'Contaminated or adulterated food'
Write SQL query to solve given problem: Among the establishments with a postal code of 94102, how many establishments have a score of 90 or more in 2015?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT COUNT(DISTINCT T2.business_id) 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 STRFTIME('%Y', T1.`date`) = '2015' AND T2.postal_code = '94102' AND T3.score > 90
Write SQL query to solve given problem: What are the names of the establishments that met all the required standards for 4 consecutive years?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT DISTINCT T4.name FROM ( SELECT T3.name, T3.years, row_number() OVER (PARTITION BY T3.name ORDER BY T3.years) AS rowNumber FROM ( SELECT DISTINCT name, STRFTIME('%Y', `date`) AS years FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100 ) AS T3 ) AS T4 GROUP BY T4.name, date(T4.years || '-01-01', '-' || (T4.rowNumber - 1) || ' years') HAVING COUNT(T4.years) = 4
Write SQL query to solve given problem: Between 2014 to 2016, what is the average inpsection score of the establishment owned by Yiu Tim Chan in 808 Pacific Ave, San Francisco?. Keep the solution inside sql tag ```sql [SQL-Query] ```
food_inspection
SELECT AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) BETWEEN '2014' AND '2016' AND T2.owner_name = 'Yiu Tim Chan' AND T2.address = '808 Pacific Ave' AND T2.city = 'San Francisco'