Chinastark/bird_dataset huggingface dataset:
Database: public_review_platform
Note: since year 2005 refers to year_id Between 2005 and 2014; increment percentage = Divide(Count(user_id(year_id < 2014)), Count (user_id(year_id = 2015))) * 100;
Question: Calculate the increment percentage of elite user for each year since year 2005.
SQL: SELECT cast(count(CASE WHEN year_id < 2014 THEN 1 ELSE NULL END) AS REAL) * 100 / count(CASE WHEN year_id = 2005 THEN 1.0 ELSE NULL END) AS INCREMENT FROM elite
Database: public_review_platform
Note: year with yelp = Subtract ('%Y'(CURRENT TIME), user_yelping_since_year);
Question: How many business have been reviewed by user ID 3 and how long have this user been with Yelp?
SQL: SELECT count(reviews.business_id) , strftime('%Y', 'now') - users.user_yelping_since_year FROM reviews INNER JOIN users ON reviews.user_id = users.user_id WHERE reviews.user_id = 3
Database: public_review_platform
Note: yearly average review = Divide( Count(business_id), Subtract('%Y'(CURRENT_TIME), user_yelping_since_year));
Question: What is the yearly average review done by user ID 3?
SQL: SELECT count(review_stars) / (strftime('%Y', 'now') - users.user_yelping_since_year) FROM users INNER JOIN reviews ON users.user_id = reviews.user_id WHERE users.user_id = 3
Database: public_review_platform
Note: average review = Divide(Count(user_id), Count(business_id));
Question: What is the average number of review received by each business given that the user is an elite?
SQL: SELECT cast(count(reviews.user_id) AS REAL) / count(DISTINCT reviews.business_id) FROM reviews INNER JOIN elite ON reviews.user_id = elite.user_id
Database: public_review_platform
Note: elite user for consecutively 5 years or more refers to user_id COUNT(year_id) > 5; Average star = AVG(likes);
Question: List out the user who is an elite user for consecutively 5 years or more and what is the user average star? How many likes does this user gets?
SQL: SELECT users.user_average_stars, count(tips.likes) FROM elite INNER JOIN users ON elite.user_id = users.user_id INNER JOIN tips ON tips.user_id = users.user_id GROUP BY elite.user_id HAVING count(elite.user_id) > 5
Database: public_review_platform
Note: "Hotel & Travel" is the category_name; most review refers to Max(Count(category_id)); Average star per user = Divide (Sum (review_stars), Count(user_id));
Question: Find out which hotel and travel business having the most review? Calculate the standard deviation of the review star for this business.
SQL: SELECT categories.category_id FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN reviews ON reviews.business_id = business_categories.business_id WHERE categories.category_name = 'Hotels & Travel' GROUP BY categories.category_id ORDER BY count(categories.category_id) DESC LIMIT 1
Database: public_review_platform
Note: highest review count refers to review_count = 'Uber'; average business review stars = Divide (Sum(review_stars), Count(user_id));
Question: What is the correlation between the review starts and business stars?
SQL: SELECT cast(sum(reviews.review_stars) AS REAL) / count(business.business_id) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id
Database: public_review_platform
Note: active refers to active = 'true';
Question: How many of the businesses are active?
SQL: SELECT count(business_id) FROM business WHERE active LIKE 'True'
Database: public_review_platform
Note: "Phoenix" is the city; low review count refers to review_count = 'Low';
Question: List down the business ID with a low review count in Phoenix.
SQL: SELECT business_id FROM business WHERE city LIKE 'Phoenix' AND review_count LIKE 'Low'
Database: public_review_platform
Note: active business refers to active = 'true'; 'AZ' is the state; high review count refers to review_count = 'High';
Question: What is the total number of active business in AZ with a high review count?
SQL: SELECT count(business_id) FROM business WHERE state LIKE 'AZ' AND review_count LIKE 'High' AND active LIKE 'True'
Database: public_review_platform
Note: star range from 3 to 4 refers to stars >= 3 AND stars < 5; 'Tempe' is the name of city;
Question: List down the business ID with a star range from 3 to 4, located at Tempe.
SQL: SELECT business_id FROM business WHERE city LIKE 'Tempe' AND stars BETWEEN 3 AND 4
Database: public_review_platform
Note: user yelping since 2010 to 2012 refers to user_yelping_since_year >= '2010' AND user_yelping_since_year < '2013'; low fans refers to user_fans = 'Low';
Question: In users yelping since 2010 to 2012, how many of them has an low fans?
SQL: SELECT count(user_id) FROM users WHERE user_yelping_since_year BETWEEN 2010 AND 2012 AND user_fans LIKE 'Low'
Database: public_review_platform
Note: "60776" is the user_id;
Question: What is the review length of user 60776 to business with business ID 1?
SQL: SELECT review_length FROM reviews WHERE user_id = 60776 AND business_id = 1
Database: public_review_platform
Note: "Scottsdale" is the name of city; high review count refers to review_count = 'High'; attribute of the business refers to attribute_name;
Question: Among the businesses in Scottsdale, list the attribute of the business with a high review count.
SQL: SELECT attributes.attribute_name FROM business INNER JOIN business_attributes ON business.business_id = business_attributes.business_id INNER JOIN attributes ON business_attributes.attribute_id = attributes.attribute_id WHERE business.review_count LIKE 'High' AND business.city LIKE 'Scottsdale' GROUP BY attributes.attribute_name
Database: public_review_platform
Note: "Automotive" is the category of business; star rating below 3 refers to stars < 3;
Question: In businesses with a category of automotive, how many of them has an star rating below 3?
SQL: SELECT count(business.business_id) FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE categories.category_name LIKE 'Automotive' AND business.stars < 3
Database: public_review_platform
Note: active business refers to active = 'true'; 'Pets' is the category_name;
Question: List the active business ID and its stars of the businesses fall under the category of Pets.
SQL: SELECT business.business_id, business.stars FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE business.active LIKE 'TRUE' AND categories.category_name LIKE 'Pets'
Database: public_review_platform
Note: highest star rating Max(stars); attribute of business refers to attribute_name;
Question: What is the attribute of the business with highest star rating?
SQL: SELECT attributes.attribute_name FROM business INNER JOIN business_attributes ON business.business_id = business_attributes.business_id INNER JOIN attributes ON business_attributes.attribute_id = attributes.attribute_id ORDER BY business.stars DESC LIMIT 1
Database: public_review_platform
Note: short review length refers to review_length = 'Short'; highest review stars refers to Max(review_stars); business ID from 5 to 10 refers to business_id BETWEEN 5 AND 10; category of business refers to category_name;
Question: What is the category of the business with short review length and highest review stars within business ID from 5 t0 10?
SQL: SELECT categories.category_name FROM reviews INNER JOIN business ON reviews.business_id = business.business_id INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE reviews.review_length LIKE 'Short' AND business.business_id BETWEEN 5 AND 10 ORDER BY reviews.review_stars DESC LIMIT 1
Database: public_review_platform
Note: active business refers to active = 'true'; 'Wi-Fi' is the attribute_name; medium review count refers to review_count = 'Medium';
Question: Count the active businesses that has an attribute of Wi-Fi with medium review count.
SQL: SELECT count(business.business_id) FROM business INNER JOIN business_attributes ON business.business_id = business_attributes.business_id INNER JOIN attributes ON business_attributes.attribute_id = attributes.attribute_id WHERE attributes.attribute_name LIKE 'Wi-Fi' AND business.active LIKE 'TRUE' AND business.review_count LIKE 'Medium'
Database: public_review_platform
Note: "Gilbert" is the name of city; highest star rating refers to Max(stars);
Question: What is the closing and opening time of businesses located at Gilbert with highest star rating?
SQL: SELECT business_hours.closing_time, business_hours.opening_time FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id WHERE business.city LIKE 'Gilbert' ORDER BY business.stars DESC LIMIT 1
Database: public_review_platform
Note: active business refers to active = 'true': 'Mesa' is the name of city; 'AZ' is the state; low review count refers to review_count = 'Low'; category refers to category_name;
Question: Among the active businesses located at Mesa, AZ, list the category and attributes of business with a low review count.
SQL: SELECT categories.category_name FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE business.review_count = 'Low' AND business.city = 'Mesa' AND business.active = 'true' AND business.state = 'AZ'
Database: public_review_platform
Note: inactive business refers to active = 'FALSE'; 'AZ' is the state; category refers to category_name;
Question: List the categories of inactive businesses in AZ.
SQL: SELECT categories.category_name FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE business.active LIKE 'FALSE' AND business.state LIKE 'AZ'
Database: public_review_platform
Note: 9 am refers to opening_time = '9AM'; 9 pm refers to closing_time = '9PM'; every Saturday refers to day_of_week = 'Saturday'; location refers to city;
Question: Find the location of businesses that has business hours from 9 am to 9 pm every Saturday.
SQL: SELECT business.city FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.closing_time LIKE '9PM' AND business_hours.opening_time LIKE '9AM' AND days.day_of_week LIKE 'Saturday' GROUP BY business.city
Database: public_review_platform
Note: inactive business refers to active = 'FALSE'; 'AZ' is the state; 'Phoenix' is the name of city; medium review count refers to review_count = 'Medium'; 3.5 stars refers to stars = 3.5;
Question: What is the attribute value of an inactive business with a medium review count and 3.5 stars which is located at Phoenix, AZ?
SQL: SELECT business_attributes.attribute_value FROM business INNER JOIN business_attributes ON business.business_id = business_attributes.business_id INNER JOIN attributes ON business_attributes.attribute_id = attributes.attribute_id WHERE business.state LIKE 'AZ' AND business.review_count LIKE 'Medium' AND business.active LIKE 'FALSE' AND business.city LIKE 'Phoenix' AND business.stars = 3.5
Database: public_review_platform
Note: active business refers to active = 'true'; 'Surprise' is the name of city;  low review count refers to review_count = 'Low';
Question: What is the opening time of the active businesses in Surprise that has a low review count.
SQL: SELECT business_hours.opening_time FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business.city LIKE 'Surprise' AND business.active LIKE 'TRUE' AND business.review_count LIKE 'Low' GROUP BY business_hours.opening_time
Database: public_review_platform
Note: "Local Services" is the category_name; less than 3 stars refers to stars < 3; percentage = Divide(Count(business_id(stars < 3)), Count(business_id)) * 100;
Question: Among the businesses with a category of Local Services, what is the percentage of the business with less than 3 stars?
SQL: SELECT cast(sum(CASE WHEN business.stars < 3 THEN 1 ELSE 0 END) AS REAL) * 100 / count(business.stars) AS "percentage" FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE categories.category_name LIKE 'Local Services'
Database: public_review_platform
Note: active business refers to active = 'true';  'Scottsdale' is the name of city; stars greater than the 60% of average age of star rating refers to stars  > avg(stars) * 60%;
Question: List the closing time and day of week of active businesses in Scottsdale with stars greater than the 60% of average age of star rating.
SQL: SELECT business_hours.closing_time, days.day_of_week FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business.city LIKE 'Scottsdale' AND business.active LIKE 'TRUE' AND business.stars > 0.6 * ( SELECT avg(business.stars) FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business.city LIKE 'Scottsdale' AND business.active LIKE 'TRUE' )
Database: public_review_platform
Note: in 2004 refers to user_yelping_since_year = 2004; no follower refers to user_fans = 'None';
Question: How many users have no followers in 2014?
SQL: SELECT count(user_id) FROM users WHERE user_yelping_since_year = 2004 AND user_fans LIKE 'None'
Database: public_review_platform
Note: less than 5 low compliment refers to number_of_compliments < 5;
Question: List at least 5 users that has received less than 5 low compliments from other users.
SQL: SELECT user_id FROM users_compliments WHERE number_of_compliments LIKE 'Low' GROUP BY user_id ORDER BY count(number_of_compliments) > 5 LIMIT 5
Database: public_review_platform
Note: 4 as an average rating refers to user_average_stars = 4;
Question: List at least 10 users ID that has 4 as an average ratings of all reviews sent.
SQL: SELECT count(user_id) FROM users WHERE user_average_stars = 4 LIMIT 10
Database: public_review_platform
Note: 10 am refers to opening_time = '10AM'; 12 pm refers to closing_time = '12PM'; on Sunday refers to day_of_week = 'Sunday';
Question: What city does the business have a business hour from 10 am to 12 pm on Sunday?
SQL: SELECT business.city FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.opening_time LIKE '10AM' AND business_hours.closing_time LIKE '12PM' AND days.day_of_week LIKE 'Sunday'
Database: public_review_platform
Note: opened for 24 hours refers to attribute_name = 'Open 24 Hours' AND attribute_value = 'true';
Question: How many businesses are opened for 24 hours?
SQL: SELECT count(business_attributes.business_id) FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id WHERE business_attributes.attribute_value LIKE 'TRUE' AND attributes.attribute_name LIKE 'Open 24 Hours'
Database: public_review_platform
Note: "Good for Groups" and "Good for Dancing" are attribute_name; active business refers to active = true';
Question: List at least 5 active business ID that are good for groups and dancing.
SQL: SELECT business_attributes.business_id FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id INNER JOIN business ON business_attributes.business_id = business.business_id WHERE business_attributes.attribute_value LIKE 'TRUE' AND attributes.attribute_name LIKE 'Good for Dancing' AND attributes.attribute_name LIKE 'Good for Groups' LIMIT 5
Database: public_review_platform
Note: active business refers to active = 'true'; 'Ahwatukee' is the name of city; open in Sunday refers to day_of_week = 'Sunday';
Question: Among the active businesses in Ahwatukee, which of them are still open in Sunday?
SQL: SELECT business.business_id FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business.city LIKE 'Ahwatukee' AND business.active LIKE 'TRUE' AND days.day_of_week LIKE 'Sunday'
Database: public_review_platform
Note: active business refers to active = 'true'; not in Arizona refers to state ! = 'AZ'; category refers to category_name;
Question: List the categories of all active businesses that were not in Arizona.
SQL: SELECT categories.category_name FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE business.active LIKE 'TRUE' AND business.state NOT LIKE 'AZ'
Database: public_review_platform
Note: high review count refers to review_count = 'High'; received 2 stars refers to stars = 2; category refers to category_name;
Question: List the category of the business with high review count but received 2 stars.
SQL: SELECT categories.category_name FROM business INNER JOIN business_categories ON business.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE business.stars = 2 AND business.review_count LIKE 'High'
Database: public_review_platform
Note: romantic ambiance refers to attribute_name = 'ambience_romantic' AND attribute_value = 'true';
Question: How many businesses have a romantic ambiance?
SQL: SELECT count(business_attributes.business_id) FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id WHERE business_attributes.attribute_value = 'true' AND attributes.attribute_name = 'ambience_romantic'
Database: public_review_platform
Note: 1 pm refers to opening_time = '1PM'; 6 pm refers to closing_time = '6PM'; on Saturday refers to day_of_week = 'Saturday';
Question: List the city of the business where they open from 1 pm to 6 pm on Saturday.
SQL: SELECT business.city FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.closing_time LIKE '6PM' AND business_hours.opening_time LIKE '1PM' AND days.day_of_week LIKE 'Saturday'
Database: public_review_platform
Note: fans and followers refers to user_fans; most likes of their comments refer to Max(likes);
Question: What is the total number of fans or followers who received most likes of their comments in the business?
SQL: SELECT count(users.user_fans) FROM users INNER JOIN tips ON users.user_id = tips.user_id ORDER BY count(tips.likes) DESC LIMIT 1
Database: public_review_platform
Note: 12 am refers to opening_time = '12AM'; 1 am refers to closing_time = '1AM'; on Saturday refers to day_of_week = 'Saturday';
Question: What city does the business came from where they received a high volume of check-ins from 12 am to 1 am on Saturday.
SQL: SELECT business.city FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.closing_time = '1AM' AND business_hours.opening_time = '12AM' AND days.day_of_week = 'Saturday'
Database: public_review_platform
Note: "Shopping Centers" is the category_name; high review count refers to review_count = 'High';
Question: How many businesses have shopping centers and received high review count?
SQL: SELECT count(business_categories.business_id) FROM categories INNER JOIN business_categories ON categories.category_id = business_categories.category_id INNER JOIN business ON business_categories.business_id = business.business_id WHERE categories.category_name = 'Shopping Centers' AND business.review_count = 'High'
Database: public_review_platform
Note: business that accept insurance refers to attribute_name = 'Accepts Insurance' AND attribute_value = 'true';
Question: How many businesses accept insurance?
SQL: SELECT count(business_attributes.business_id) FROM business_attributes INNER JOIN attributes ON business_attributes.attribute_id = attributes.attribute_id WHERE attributes.attribute_name = 'Accepts Insurance' AND business_attributes.attribute_value = 'true'
Database: public_review_platform
Note: "South Carolina" and "California" are both state; average review stars from users = Divide((Sum(review_stars(state = 'SC')) + Sum(review_stars(state = 'CA'))), Sum(stars));
Question: Calculate the average review star from users in businesses located in South Carolina and California state.
SQL: SELECT 1.0 * (( SELECT sum(business.stars) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.state = 'SC' ) + ( SELECT sum(business.stars) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.state = 'CA' )) / ( SELECT sum(business.stars) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id ) AS reslut
Database: public_review_platform
Note: 10 am refers to opening_time = '10AM'; 9 pm refers to closing_time = '9PM'; 'Monday' and 'Tuesday' are both day_of_week; difference number of business = Subtract(Count(business_id(day_of_week = 'Monday')), Count(business_id(day_of_week = 'Tuesday')));
Question: Compare and get the difference of the number of businesses that are open in Monday and Tuesday from 10 am to 9 pm.
SQL: SELECT sum(CASE WHEN days.day_of_week = 'Monday' THEN 1 ELSE 0 END) - sum(CASE WHEN days.day_of_week = 'Tuesday' THEN 1 ELSE 0 END) AS diff FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.opening_time = '10AM' AND business_hours.closing_time = '9PM'
Database: public_review_platform
Note: ID number refers to attribute_id;
Question: State the ID number for the attribute named "Accepts Insurance"?
SQL: SELECT attribute_id FROM attributes WHERE attribute_name = 'Accepts Insurance'
Database: public_review_platform
Note: actively running business refers to active = 'true'; 'Phoenix' is the name of city;
Question: How many actively running Yelp businesses are there located in "Phoenix" city?
SQL: SELECT count(business_id) FROM business WHERE active = 'true' AND city = 'Phoenix'
Database: public_review_platform
Note: "4" stars refers to stars = '4'; 'Mesa' is the name of city;
Question: Give the number of "4" stars Yelp businesses in "Mesa" city.
SQL: SELECT count(business_id) FROM business WHERE stars = 4 AND city = 'Mesa'
Database: public_review_platform
Note: "Gilbert" is the name of city; high review count refers to review_count = 'High';
Question: Provide the number of Yelp businesses in "Gilbert" which got a" high" review count.
SQL: SELECT count(business_id) FROM business WHERE review_count = 'High' AND city = 'Gilbert'
Database: public_review_platform
Note: actively running business refers to active = 'true'; 'Gilbert' is the name of city; most review refers to review_count = 'Uber';
Question: Which actively running Yelp business in "Gilbert" has got the most reviews? Give the business id.
SQL: SELECT DISTINCT business.business_id FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.active = 'true' AND business.city = 'Gilbert' AND business.review_count = 'Uber'
Database: public_review_platform
Note: "Tempe" is the name of city; long review refers to review_length = 'Long';
Question: For the Yelp business in "Tempe" city which got "3.5" stars and review count as "Uber", how many "long" reviews did it get?
SQL: SELECT count(reviews.review_length) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.city = 'Tempe' AND business.stars = '3.5' AND business.review_count = 'Uber' AND reviews.review_length = 'Long'