Chinastark/bird_dataset huggingface dataset:
Database: food_inspection
Note: Tiramisu Kitchen is the name of the business; high risks violations refer to risk_category = 'High Risk';
Question: How many high risks violations did the Tiramisu Kitchen violate?
SQL: SELECT count(violations.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.name = 'Tiramisu Kitchen' AND violations.risk_category = 'High Risk'
Database: food_inspection
Note: 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;
Question: How many establishments with the tax code H24 have complaint inspections of 5 or more?
SQL: SELECT count(*) FROM ( SELECT inspections.business_id FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.tax_code = 'H24' AND inspections.type = 'Complaint' GROUP BY inspections.business_id HAVING count(inspections.business_id) > 5 ) t3
Database: food_inspection
Note: establishments have the same meaning as businesses; contaminated or adulterated food refers to violations where description = 'Contaminated or adulterated food'; date = '2013';
Question: In 2013, what are the names of the establishments with contaminated or adulterated food?
SQL: SELECT businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE strftime('%Y', violations.`date`) = '2013' AND violations.description = 'Contaminated or adulterated food'
Database: food_inspection
Note: establishment has the same meaning as business; score of 90 or more refers to score ≥ 90; year(date) = 2015;
Question: Among the establishments with a postal code of 94102, how many establishments have a score of 90 or more in 2015?
SQL: SELECT count(DISTINCT businesses.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id INNER JOIN inspections ON businesses.business_id = inspections.business_id WHERE strftime('%Y', violations.`date`) = '2015' AND businesses.postal_code = '94102' AND inspections.score > 90
Database: food_inspection
Note: establishment has the same meaning as business; score of 90 or more refers to score ≥ 90; year(date) = 2015; ; met all required standards for 4 consecutive years refers to COUNT(year(date)) = 4 where score = 100;
Question: What are the names of the establishments that met all the required standards for 4 consecutive years?
SQL: 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 INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score = 100 ) AS t3 ) AS t4 GROUP BY t4.name, date(t4.years || '-01-01', '-' || (t4.rownumber - 1) || ' years') HAVING count(t4.years) = 4
Database: food_inspection
Note: average inspection score refers to avg(score); establishment owned by Yiu Tim Chan refers to business_id where owner_name = 'Yiu Tim Chan'; Between 2014 to 2016 refers to year(date) between 2014 and 2016; address = '808 Pacific Ave'; city = 'San Francisco';
Question: Between 2014 to 2016, what is the average inpsection score of the establishment owned by Yiu Tim Chan in 808 Pacific Ave, San Francisco?
SQL: SELECT avg(inspections.score) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE strftime('%Y', inspections.`date`) BETWEEN '2014' AND '2016' AND businesses.owner_name = 'Yiu Tim Chan' AND businesses.address = '808 Pacific Ave' AND businesses.city = 'San Francisco'
Database: food_inspection
Note: average score refers avg(score); owner with the highest number of establishments refers to owner_name where MAX(COUNT(business_id));
Question: What is the average score of the establishments owned by the owner with the highest number of establishments?
SQL: SELECT avg(inspections.score) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id GROUP BY businesses.owner_name ORDER BY count(businesses.business_id) DESC LIMIT 1
Database: food_inspection
Note: establishment with the highest number of low risk violations refers to business_id where MAX(COUNT(risk_category = 'Low Risk')); year(date) = 2014;
Question: What is the name of the establishment with the highest number of low risk violations in 2014?
SQL: SELECT 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' GROUP BY businesses.name ORDER BY count(businesses.business_id) DESC LIMIT 1
Database: food_inspection
Note: 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'));
Question: 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.
SQL: SELECT businesses.owner_name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id INNER JOIN ( SELECT businesses.owner_name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id GROUP BY businesses.owner_name ORDER BY count(violations.business_id) DESC LIMIT 5 ) AS t5 ON businesses.owner_name = t5.owner_name WHERE violations.risk_category = 'High Risk' GROUP BY businesses.owner_name ORDER BY count(violations.risk_category) DESC LIMIT 1
Database: food_inspection
Note: establishment refers to business_id; the highest number of inspections refers to MAX(COUNT(business_id)); avg(score);
Question: Which establishment has the highest number of inspections done? Give the name of the establishment and calculate for its average score per inspection.
SQL: SELECT businesses.name, avg(inspections.score) FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id GROUP BY businesses.name ORDER BY count(businesses.business_id) DESC LIMIT 1
Database: food_inspection
Note: eateries got highest inspection score in 2013 refer to business_id from inspections where score = 100 and year(date) = 2013;
Question: How many eateries got highest inspection in 2013?
SQL: SELECT count(DISTINCT business_id) FROM inspections WHERE strftime('%Y', `date`) = '2013' AND score = ( SELECT max(score) FROM inspections WHERE strftime('%Y', `date`) = '2013' )
Database: food_inspection
Note: eateries' IDs refer to business_id; structural inspection type refers to inspections WHERE type = 'Structural Inspection'; in February 2016 refers to year(date) = 2016 and month(date) = 2;
Question: List down the eateries' IDs with structural inspection type in February 2016.
SQL: SELECT business_id FROM inspections WHERE TYPE = 'Structural Inspection' AND `date` LIKE '2016-02%'
Database: food_inspection
Note: eateries represent business; low risk for violation refers to risk_category = 'Low Risk';
Question: How many eateries had low risk for violation with unpermitted food facility description?
SQL: SELECT count(DISTINCT business_id) FROM violations WHERE risk_category = 'Low Risk' AND description = 'Unpermitted food facility'
Database: food_inspection
Note: eateries' IDs refer to business_id; violation ID of 103101 refers to violation_type_id = '103101';
Question: Provide eateries' IDs, risk categories and descriptions with violation ID of 103101.
SQL: SELECT business_id, risk_category, description FROM violations WHERE violation_type_id = '103101'
Database: food_inspection
Note: eateries represent business; highest score in inspection refers to score = 100;
Question: When did eateries from San Bruno city get highest score in inspection?
SQL: SELECT inspections.`date` FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.city = 'SAN BRUNO' ORDER BY inspections.score DESC LIMIT 1
Database: food_inspection
Note: ART's CAFÉ is the name of the business; moderate risk category refers to risk_category = 'Moderate Risk';
Question: Describe the inspection types and violation descriptions under moderate risk category for ART's CAFÉ.
SQL: SELECT DISTINCT inspections.type, violations.description FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'ART''S CAFÉ' AND violations.risk_category = 'Moderate Risk'
Database: food_inspection
Note: STARBUCKS is the name of the business; high risk category refers to risk_category = 'High Risk';
Question: Mention the violation type ID and description of high risk category for STARBUCKS.
SQL: SELECT DISTINCT violations.violation_type_id, violations.description FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.name = 'STARBUCKS' AND violations.risk_category = 'High Risk'
Database: food_inspection
Note: eateries with tax code AA refer to business_id where tax_code = 'AA';
Question: List the inspection dates, scores and inspection types for the eateries with tax code AA.
SQL: SELECT inspections.`date`, inspections.score, inspections.type FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.tax_code = 'AA'
Database: food_inspection
Note: eateries' IDs inspected on 30th July, 2016 refer to business_id where business_id is not null and date = '2016-07-30';
Question: Provide eateries' IDs, names and addresses which were inspected on 30th July, 2016.
SQL: SELECT DISTINCT businesses.business_id, businesses.name, businesses.address FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.date = '2016-07-30'
Database: food_inspection
Note: eateries under Jade Chocolates LLC refer to business_id where owner_name = 'Jade Chocolates LLC';
Question: Describe the violation dates, risk categories, descriptions and names of the eateries under Jade Chocolates LLC.
SQL: SELECT violations.`date`, violations.risk_category, violations.description, businesses.name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.owner_name = 'Jade Chocolates LLC'
Database: food_inspection
Note: eateries refer to business_id;
Question: Provide the names, risk categories and descriptions for the eateries with violation type ID of 103111.
SQL: SELECT businesses.name, violations.risk_category, violations.description FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.violation_type_id = '103111'
Database: food_inspection
Note: eateries with high risk category refer to business_id where risk_category = 'High Risk'; 3rd June, 2014 refers to date = '2014-06-03';
Question: Among violations on 3rd June, 2014, describe any 5 names, located cities and tax codes of the eateries with high risk category.
SQL: SELECT DISTINCT businesses.name, businesses.city, businesses.tax_code FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' AND violations.`date` = '2014-06-03' LIMIT 5
Database: food_inspection
Note: El Aji Peruvian Restaurant is the name of the business; highest inspection score refers to MAX(score);
Question: What was the inspection type when El Aji Peruvian Restaurant got highest inspection score?
SQL: SELECT inspections.type FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'El Aji Peruvian Restaurant' ORDER BY inspections.score DESC LIMIT 1
Database: food_inspection
Note: 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';
Question: Who were the owners of eateries which had highest health hazard by improper cooking time or temperatures?
SQL: SELECT businesses.owner_name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' AND violations.description = 'Improper cooking time or temperatures'
Database: food_inspection
Note: eateries which had reinspection on 2nd February, 2015 refer to business_id where date = '2015-02-02' and type = 'Reinspection/Followup';
Question: List the eateries' names and addresses which had reinspection on 2nd February, 2015.
SQL: SELECT businesses.name, businesses.address FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.`date` = '2015-02-02' AND inspections.type = 'Reinspection/Followup'
Database: food_inspection
Note: eateries which got inspection score under 50 refer to business_id where score < 50;
Question: List the names and business certificates of the eateries which got inspection score under 50.
SQL: SELECT businesses.name, businesses.business_id FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score < 50
Database: food_inspection
Note: 1825 POST St #223 refers to address = '1825 POST St #223', San Francisco is the name of the city;
Question: How many of the businesses are located at 1825 POST St #223, San Francisco?
SQL: SELECT count(business_id) FROM businesses WHERE address = '1825 POST St #223' AND city = 'SAN FRANCISCO'
Database: food_inspection
Note: zip code 94104 refers to owner_zip = '94104';
Question: List down the owner's name with a zip code 94104.
SQL: SELECT DISTINCT owner_name FROM businesses WHERE owner_zip = '94104'
Database: food_inspection
Question: What is the total number of businesses with a tax code H25?
SQL: SELECT count(tax_code) FROM businesses WHERE tax_code = 'H25'
Database: food_inspection
Note: in 2014 refers to year(date) = 2014; risk_category = 'Low Risk';
Question: In the violations in 2014, how many of them have a low risk category?
SQL: SELECT count(risk_category) FROM violations WHERE strftime('%Y', `date`) = '2014' AND risk_category = 'Low Risk'
Database: food_inspection
Note: business owned by San Francisco Madeleine, Inc. refers to business_id where owner_name = 'San Francisco Madeleine, Inc.';
Question: Give the business ID and risk category of the business owned by San Francisco Madeleine, Inc.
SQL: SELECT DISTINCT businesses.business_id, violations.risk_category FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.owner_name = 'San Francisco Madeleine, Inc.'
Database: food_inspection
Note: owner's name of businesses refers to owner_name;
Question: List owner's name of businesses with a 100 score.
SQL: SELECT DISTINCT businesses.owner_name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score = 100
Database: food_inspection
Note: businesses with a high risk category refer to business_id where risk_category = 'High Risk';
Question: Among the businesses within the postal code 94117, what is total number of businesses with a high risk category?
SQL: SELECT count(DISTINCT businesses.business_id) FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.postal_code = 94117 AND violations.risk_category = 'High Risk'
Database: food_inspection
Note: businesses with score that ranges from 70 to 80 refer to business_id where score between 80 and 90;
Question: Among the businesses with score that ranges from 70 to 80, list their violation type ID and risk category.
SQL: SELECT DISTINCT violations.violation_type_id, violations.risk_category FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id INNER JOIN inspections ON businesses.business_id = inspections.business_id WHERE inspections.score BETWEEN 70 AND 80
Database: food_inspection
Note: "Rue Lepic" is the name of the business;
Question: List the tax code and inspection type of the business named "Rue Lepic".
SQL: SELECT DISTINCT businesses.tax_code, inspections.type FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.name = 'Rue Lepic'
Database: food_inspection
Note: businesses that violates 103157 refer to business_id where violation_type_id = 103157; date = '2016-05-27'; unscheduled inspection refers to type = 'Routine - Unscheduled';
Question: In businesses that violates 103157 on May 27, 2016 , what is the name of the business that has an unscheduled inspection?
SQL: SELECT DISTINCT businesses.name FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE violations.`date` = '2016-05-27' AND violations.violation_type_id = 103157 AND inspections.type = 'Routine - Unscheduled'
Database: food_inspection
Note: owner refers to owner_name; high risk violation of 103109 and described as unclean or unsanitary food contact surfaces refers to risk_category = 'High Risk' where violation_type_id = 103109 and description = 'Unclean or unsanitary food contact surfaces';
Question: Who is the owner of the business that has a high risk violation of 103109 and described as unclean or unsanitary food contact surfaces?
SQL: SELECT DISTINCT businesses.owner_name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.risk_category = 'High Risk' AND violations.violation_type_id = 103109 AND violations.description = 'Unclean or unsanitary food contact surfaces'
Database: food_inspection
Note: Cameron Park is a name of city;
Question: Among the owners from Cameron Park, what is the business name of the business with a score of 100?
SQL: SELECT DISTINCT businesses.name FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.owner_city = 'Cameron Park' AND inspections.score = 100
Database: food_inspection
Note: business ID from 30 to 50 refers to business_id between 30 and 50; address = '747 IRVING St'; city = 'San Francisco';
Question: List the violation type ID of business with business ID from 30 to 50 and located at 747 IRVING St, San Francisco.
SQL: SELECT DISTINCT violations.violation_type_id FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE businesses.business_id BETWEEN 30 AND 50 AND businesses.address = '747 IRVING St' AND businesses.city = 'San Francisco'
Database: food_inspection
Note: business that violates 103156 on June 12, 2014 refers to business_id where violation_type_id = 103156 and date = '2014-06-12';
Question: What is the owner's name of the of the business that violates 103156 on June 12, 2014?
SQL: SELECT DISTINCT businesses.owner_name FROM violations INNER JOIN businesses ON violations.business_id = businesses.business_id WHERE violations.violation_type_id = 103156 AND violations.`date` = '2014-06-12'
Database: food_inspection
Note: the highest score MAX(score); Silicon Valley is located in 'SAN FRANCISCO';
Question: In businesses with an owner address 500 California St, 2nd Floor of Silicon Valley, list the type of inspection of the business with the highest score.
SQL: SELECT inspections.type FROM inspections INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE businesses.owner_address = '500 California St, 2nd Floor' AND businesses.owner_city = 'SAN FRANCISCO' ORDER BY inspections.score DESC LIMIT 1
Database: food_inspection
Note: unscheduled inspections refer to type = 'Routine - Unschedule'; year(date) = 2016;
Question: Among the violations in 2016, how many of them have unscheduled inspections?
SQL: SELECT count(inspections.business_id) FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id WHERE strftime('%Y', violations.`date`) = '2016' AND inspections.type = 'Routine - Unscheduled'
Database: food_inspection
Note: score greater than the 80% of average score of all businesses refers to score > MULTIPLY(0.8, avg(score) from inspections);
Question: List the business' name and risk category of businesses with a score greater than the 80% of average score of all businesses.
SQL: SELECT DISTINCT businesses.name, violations.risk_category FROM businesses INNER JOIN inspections ON businesses.business_id = inspections.business_id INNER JOIN violations ON businesses.business_id = violations.business_id WHERE inspections.score > 0.8 * ( SELECT avg(score) FROM inspections )
Database: food_inspection
Note: DIVIDE(COUNT(business_id where risk_category = 'Low Risk', score < 95 and postal_code = 94110), COUNT(business_id where score < 95 and postal_code = 94110)) as percentage;
Question: In businesses with a score lower than 95 and located around the postal code of 94110, what is the percentage of businesses with a risk category of low risk?
SQL: SELECT cast(sum(CASE WHEN violations.risk_category = 'Low Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / count(violations.risk_category) FROM violations INNER JOIN inspections ON violations.business_id = inspections.business_id INNER JOIN businesses ON inspections.business_id = businesses.business_id WHERE inspections.score < 95 AND businesses.postal_code = 94110
Database: craftbeer
Question: Which distinct state makes beer that has the least amount of bitterness?
SQL: SELECT DISTINCT breweries.state, beers.ibu FROM beers INNER JOIN breweries ON beers.brewery_id = breweries.id WHERE beers.ibu IS NOT NULL AND beers.ibu = ( SELECT min(ibu) FROM beers )
Database: craftbeer
Note: The more ibu, the more bitter the beer is, bitterest means highest ibu.;
Question: 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.
SQL: SELECT breweries.name, breweries.city FROM beers INNER JOIN breweries ON beers.brewery_id = breweries.id WHERE breweries.state = 'NY' ORDER BY beers.ibu DESC LIMIT 1
Database: craftbeer
Question: What is the average alcohol content per 12-ounce beer bottle produced by Boston Beer Company?
SQL: SELECT avg(beers.abv) FROM beers INNER JOIN breweries ON beers.brewery_id = breweries.id WHERE breweries.name = 'Boston Beer Company' AND beers.ounces = 12
Database: craftbeer
Note: Percent allotted = count(American Adjunct Lager beer styles) / count(styles) * 100%;
Question: Of all the beer styles produced by Stevens Point Brewery, how many percent do they allot for American Adjunct Lager?
SQL: SELECT cast(sum(iif(beers.style = 'American Adjunct Lager', 1, 0)) AS REAL) * 100 / count(beers.brewery_id) FROM beers INNER JOIN breweries ON beers.brewery_id = breweries.id WHERE breweries.name = 'Stevens Point Brewery'
Database: craftbeer
Note: The more ibu, the more bitter the beer is, most bitter means highest ibu; The less ibu, the less bitter the beer is, least bitter means lowest ibu;
Question: Which city and state produces the most and least bitter beer, and what is the difference in bitterness between the two? List also the names of the beer.
SQL: SELECT breweries.state, breweries.city, beers.name, beers.ibu FROM breweries INNER JOIN beers ON breweries.id = beers.brewery_id GROUP BY breweries.state, breweries.city, beers.name, beers.ibu HAVING max(ibu) AND min(ibu) LIMIT 2
Database: craftbeer
Note: Percentage of the state of Wisconsin produces American Blonde Ale could be computed by count(breweries in Wisconsin producing American Blonde Ale) / count(all breweries);
Question: When compared to the total number of breweries in the US producing American Blonde Ale, how many in the state of Wisconsin produces American Blonde Ale? Indicate your answer in percentage (%).
SQL: SELECT cast(sum(iif(breweries.state = 'WI', 1, 0)) AS REAL) * 100 / count(beers.id) FROM beers INNER JOIN breweries ON beers.brewery_id = breweries.id WHERE beers.style = 'American Blonde Ale'