Chinastark/bird_dataset huggingface dataset:
Database: public_review_platform
Note: closed business refers to active = 'false'; in Avondale refers to city = 'Avondale'; 'wonderful experience' rating refers to stars > 3; percentage = divide(count(business_id where stars > 3), count(business_id))*100%;
Question: Among all closed businesses in Avondale, AZ what percent have obtained a 'wonderful experience' rating of the business.
SQL: SELECT cast(sum(CASE WHEN stars > 3 THEN 1 ELSE 0 END) AS REAL) * 100 / count(stars) FROM business WHERE city = 'Avondale' AND active = 'false'
Database: public_review_platform
Note: has been yelping since 2004 refers to user_yelping_since_year = 2004;
Question: Identify the user who has been yelping since 2004. Is he or she an Yelp Elite member?
SQL: SELECT DISTINCT elite.user_id FROM users INNER JOIN elite ON users.user_id = elite.user_id WHERE users.user_yelping_since_year = 2004
Database: public_review_platform
Note: percentage = divide(count(business_id where review_length = 'Long' and review_stars = 5), count(business_id)) * 100%; long reviews refers to review_length = 'Long'; 5-star review refers to review_stars = 5;
Question: Identify the percent of long reviews among all 5-star reviews given to businesses by the Yelp users.
SQL: SELECT cast(sum(CASE WHEN review_length = 'Long' THEN 1 ELSE 0 END) AS REAL) * 100 / count(review_length) FROM reviews WHERE review_stars = 5
Database: public_review_platform
Note: average ratings of at least 4 refers to user_average_stars >= 4; no fans or followers refers to user_fans = 'None'; percentage = divide(count(user_id where user_average_stars >= 4 and user_fans = 'None'), sum(user_id where user_average_stars >= 4))*100%;
Question: Among all the users with the average ratings of at least 4 and above of all reviews, calculate the percent that have no fans or followers.
SQL: SELECT cast(sum(CASE WHEN user_fans = 'None' THEN 1 ELSE 0 END) AS REAL) * 100 / count(user_id) FROM users WHERE user_average_stars >= 4
Database: public_review_platform
Note: short tip refers to tip_length = 'Short'; business category refers to category_name;
Question: How many short tips were left for the business with ID no.2?
SQL: SELECT count(business_id) FROM tips WHERE business_id = 2 AND tip_length = 'Short'
Database: public_review_platform
Note: Yelp user refers to user_id; average 5-star rating refers to user_average_stars = 5; yelping the longest refers to min(user_yelping_since_year);
Question: Find the Yelp user with the average 5-star rating of all reviews who has been yelping the longest.
SQL: SELECT user_id FROM users WHERE user_average_stars = 5 ORDER BY user_yelping_since_year ASC LIMIT 1
Database: public_review_platform
Note: operating hours refers to opening_time closing_time on day_id; in Black Canyon city refers to city = 'Black Canyon city'; greater than average refers to review_count > AVG(T1.review_count);
Question: Identify the operating hours of businesses in Black Canyon City with review count greater than average.
SQL: SELECT business_hours.opening_time, business_hours.closing_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 = 'Black Canyon City' GROUP BY business_hours.business_id HAVING business.review_count > avg(business.review_count)
Database: public_review_platform
Note: high number of compliments refers to number_of_compliments = 'High'; percentage = divide(count(user_id where compliment_type = 'cute'), count(user_id))*100%;
Question: Among all the users who received the high number of compliments, what percent received the 'cute' type of compliment.
SQL: SELECT cast(sum(CASE WHEN compliments.compliment_type = 'cute' THEN 1 ELSE 0 END) AS REAL) * 100 / count(users_compliments.user_id) FROM compliments INNER JOIN users_compliments ON compliments.compliment_id = users_compliments.compliment_id WHERE users_compliments.number_of_compliments = 'High'
Database: public_review_platform
Note: have no attribute refers to attribute_value in( 'none', 'no', 'false');
Question: Mention the number of businesses that have no any attribute.
SQL: SELECT count(business_id) FROM business_attributes WHERE attribute_value IN ('none', 'no', 'false')
Database: public_review_platform
Note: false;
Question: What are the opening and closing time of business id 1 for day id 2?
SQL: SELECT opening_time, closing_time FROM business_hours WHERE business_id = 1 AND day_id = 2
Database: public_review_platform
Note: medium length of review refers to review_length = 'Medium';
Question: List out city name of businesses which have medium length of review.
SQL: SELECT DISTINCT business.city FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE reviews.review_length = 'Medium'
Database: public_review_platform
Note: on Sunday refers to day_of_week = 'Sunday';
Question: What is the closing time of business id 4 on Sunday?
SQL: SELECT business_hours.closing_time FROM days INNER JOIN business_hours ON days.day_id = business_hours.day_id WHERE days.day_of_week = 'Sunday' AND business_hours.business_id = 4
Database: public_review_platform
Note: short length of review refers to review_length = 'Short'; in Phoenix refers to city = 'Phoenix';
Question: Among the businesses which have short length of review, which one located in Phoenix?
SQL: SELECT DISTINCT business.business_id FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.city = 'Phoenix' AND reviews.review_length = 'Short'
Database: public_review_platform
Note: is medium refers to user_fans = 'Medium'; high compliments refers to number_of_compliments = 'High';
Question: Among the users whose fan is medium, how many users received high compliments from other users.
SQL: SELECT count(users.user_id) FROM users INNER JOIN users_compliments ON users.user_id = users_compliments.user_id WHERE users_compliments.number_of_compliments = 'High' AND users.user_fans = 'Medium'
Database: public_review_platform
Note: low compliments refers to number_of_compliments = 'Low'; joined Yelp in 2012 refers to user_yelping_since_year = 2012;
Question: Among the users who received low compliments from other users, which users joined Yelp in 2012?
SQL: SELECT DISTINCT users_compliments.user_id FROM users INNER JOIN users_compliments ON users.user_id = users_compliments.user_id WHERE users.user_yelping_since_year = 2012 AND users_compliments.number_of_compliments = 'Low'
Database: public_review_platform
Note: without attribute refers to attribute_value = 'None'; in Gilbert refers to city = 'Gilbert';
Question: Among the businesses without attribute, how many businesses located in Gilbert?
SQL: SELECT count(business.business_id) FROM business_attributes INNER JOIN business ON business_attributes.business_id = business.business_id WHERE business.city = 'Gilbert' AND business_attributes.attribute_value IN ('None', 'no', 'false')
Database: public_review_platform
Note: average rating refers to avg(stars); attribute of full_bar refers to attribute_value = 'full_bar';
Question: Among the businesses with average rating, how many business has attribute of full_bar.
SQL: SELECT count(business_attributes.business_id) FROM business_attributes INNER JOIN business ON business_attributes.business_id = business.business_id WHERE business_attributes.attribute_value = 'full_bar'
Database: public_review_platform
Note: state refers to city;
Question: List out the state of businesses which have opening time at 1AM.
SQL: SELECT DISTINCT business.state FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id WHERE business_hours.opening_time = '1AM'
Database: public_review_platform
Question: List out the category name of business id 5.
SQL: SELECT categories.category_name FROM categories INNER JOIN business_categories ON categories.category_id = business_categories.category_id WHERE business_categories.business_id = 5
Database: public_review_platform
Note: compliment type of photos refers to compliment_type = 'photos';
Question: List out the user id that has compliment type of photos.
SQL: SELECT users_compliments.user_id FROM compliments INNER JOIN users_compliments ON compliments.compliment_id = users_compliments.compliment_id WHERE compliments.compliment_type = 'photos'
Database: public_review_platform
Note: medium tip length refers to tip_length = 'Medium'; percentage = divide(count(tips where tip_length = 'Medium'), count(tips))*100%; the time when users join Yelp refers to user_yelping_since_year;
Question: Calculate the percentage of medium tip length in the list. List out the time when users of medium tip length join Yelp.
SQL: SELECT cast(sum(CASE WHEN tips.tip_length = 'Medium' THEN 1 ELSE 0 END) AS REAL) * 100 / count(tips.tip_length), users.user_yelping_since_year FROM tips INNER JOIN users ON tips.user_id = users.user_id
Database: public_review_platform
Note: percentage = divide(count(business where city = 'Mesa'), count(business)) * 100%;
Question: Calculate the percentage of businesses who located in Mesa. What is attribute value of these businesses.
SQL: SELECT cast(count(business.city) AS REAL) * 100 / ( SELECT count(business_id) FROM business ), business_attributes.attribute_value FROM business INNER JOIN business_attributes ON business.business_id = business_attributes.business_id WHERE business.city = 'Mesa'
Database: public_review_platform
Note: state refers to city;
Question: State the state of businesses which have closing time at 12AM.
SQL: SELECT DISTINCT business.state FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id WHERE business_hours.closing_time = '12AM'
Database: public_review_platform
Note: attribute of beer_and_wine refers to attribute_value = 'beer_and_wine'; in Peoria refers to city = 'Peoria';
Question: Among the businesses which have attribute of beer_and_wine, how many business located in Peoria?
SQL: SELECT count(business_attributes.business_id) FROM business_attributes INNER JOIN business ON business_attributes.business_id = business.business_id WHERE business.city = 'Peoria' AND business_attributes.attribute_value = 'beer_and_wine'
Database: public_review_platform
Note: high compliments refers to number_of_compliments = ' High'; joined Yelp earliest refers to min(user_yelping_since_year);
Question: Among the users who received high compliments from other users, which users joined Yelp earliest?
SQL: SELECT users_compliments.user_id FROM users INNER JOIN users_compliments ON users.user_id = users_compliments.user_id WHERE users_compliments.number_of_compliments = 'High' AND users.user_yelping_since_year = ( SELECT min(user_yelping_since_year) FROM users )
Database: public_review_platform
Note: the most reviews refer to MAX(user_id);
Question: Which business ID has the most reviews?
SQL: SELECT business_id FROM reviews GROUP BY business_id ORDER BY count(user_id) DESC LIMIT 1
Database: public_review_platform
Note: year has the most elite users refers to year_id with MAX(user_id);
Question: Which year has the most elite users?
SQL: SELECT year_id FROM elite GROUP BY year_id ORDER BY count(user_id) DESC LIMIT 1
Database: public_review_platform
Note: businesses refer to business_id; review_stars = 5.0; review_votes_funny = 'uber';
Question: How many 5 star businesses have uber review votes for funny?
SQL: SELECT count(business_id) FROM reviews WHERE review_stars = 5 AND review_votes_funny = 'Uber'
Database: public_review_platform
Note: users refer to user_id; review_votes_funny = 'uber';
Question: How many users have uber review votes for funny from the fans?
SQL: SELECT count(DISTINCT user_id) FROM reviews WHERE review_votes_funny = 'Uber'
Database: public_review_platform
Note: the shortest business operating hours refer to MIN(SUBTRACT(closing_time, opening_time));
Question: Which business ID have the shortest business operating hours?
SQL: SELECT business_id FROM business_hours ORDER BY closing_time - opening_time LIMIT 1
Database: public_review_platform
Note: opened all the time refers to business_hours where day_id BETWEEN 1 and 7 and opening_time = closing_time;
Question: Find out which business ID are opened all the time.
SQL: SELECT DISTINCT business_id FROM business_hours WHERE day_id >= 1 AND day_id < 8 AND opening_time = closing_time
Database: public_review_platform
Note: the longer the tip_length, the lesser the likes OR the longer the tip length the higher the likes; hotel and travel business category refers to category_name = 'Hotels & Travel';
Question: Does the length of the tip influence the number of likes for hotel and travel business category?
SQL: SELECT tips.tip_length, sum(tips.likes) AS likes FROM categories INNER JOIN business_categories ON categories.category_id = business_categories.category_id INNER JOIN tips ON business_categories.business_id = tips.business_id WHERE categories.category_name = 'Hotels & Travel' GROUP BY tips.tip_length
Database: public_review_platform
Note: users refer to user_id; uber votes for all of the review category refer to review_votes_funny = 'uber' AND review_votes_useful = 'uber' AND review_votes_cool = 'uber';
Question: How many users manage to get uber votes for all of the review category? Find out what are the user average star.
SQL: SELECT count(users.user_id) AS user_ids, users.user_average_stars FROM reviews INNER JOIN users ON reviews.user_id = users.user_id WHERE reviews.review_votes_funny = 'Uber' AND reviews.review_votes_useful = 'Uber' AND reviews.review_votes_cool = 'Uber'
Database: public_review_platform
Note: opened all the time refers to business_hours where day_id BETWEEN 1 and 7 and opening_time = closing_time; ratio can be computed as DIVIDE(COUNT(stars BETWEEN 3.5 and 5), COUNT(stars BETWEEN 1 and 2.5));
Question: What is the ratio of good to bad business star for a businesses that are opened all the time?
SQL: SELECT cast(sum(CASE WHEN business.stars BETWEEN 3.5 AND 5 THEN 1 ELSE 0 END) AS REAL) / sum(CASE WHEN business.stars BETWEEN 1 AND 2.5 THEN 1 ELSE 0 END) AS ratio FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id
Database: public_review_platform
Note: being reviewed the most refers to MAX(user_id); business categories refer to category_name;
Question: List out 10 business ID that are being reviewed the most by users and list out what are top 3 business categories.
SQL: SELECT business_categories.business_id, categories.category_name FROM reviews INNER JOIN business_categories ON reviews.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id GROUP BY business_categories.business_id ORDER BY count(reviews.user_id) DESC LIMIT 10
Database: public_review_platform
Note: businesses in Arizona refer to business_id where state = 'Arizona'; average review less than 3 stars refers to AVG(review_stars) < 3.0;
Question: How many businesses in Arizona having an average review less than 3 stars?
SQL: SELECT count(business_id) FROM business WHERE business_id IN ( SELECT DISTINCT business.business_id FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.state = 'AZ' GROUP BY business.business_id HAVING sum(reviews.review_stars) / count(reviews.user_id) < 3 )
Database: public_review_platform
Note: DIVIDE(SUBTRACT(COUNT(user_id), COUNT(elite.user_id)), COUNT(user_id)) as percentage;
Question: What is the percentage of user not becoming an elite user?
SQL: SELECT cast((( SELECT count(user_id) FROM users ) - ( SELECT count(DISTINCT user_id) FROM elite )) AS REAL) * 100 / ( SELECT count(user_id) FROM users )
Database: public_review_platform
Note: the most common compliments types refer to MAX(COUNT(compliment_id)); user_fans = 'uber';
Question: What are the most common compliments types received by user with uber number of fans?
SQL: SELECT DISTINCT compliments.compliment_type FROM users INNER JOIN users_compliments ON users.user_id = users_compliments.user_id INNER JOIN compliments ON users_compliments.compliment_id = compliments.compliment_id WHERE users.user_fans = 'Uber'
Database: public_review_platform
Note: AVG(user_yelping_since_year) where user_fans = 'uber';
Question: What is the average year needed by a user with uber fans to become an elite user?
SQL: SELECT cast(sum(elite.year_id - users.user_yelping_since_year) AS REAL) / count(users.user_id) FROM users INNER JOIN elite ON users.user_id = elite.user_id WHERE users.user_fans = 'Uber'
Database: public_review_platform
Note: AVG(user_yelping_since_year) where user_id from elite;
Question: What is the average year for a user to be upgraded to elite user?
SQL: SELECT cast(sum(elite.year_id - users.user_yelping_since_year) AS REAL) / count(users.user_id) FROM users INNER JOIN elite ON users.user_id = elite.user_id
Database: public_review_platform
Note: business are opened for more than 8 hours refer to business_id where SUBTRACT(closing_time, opening_time) > 8; DIVIDE(COUNT(business_id where active = 'true' and city = 'Mesa' and SUBTRACT(closing_time, opening_time) > 8), COUNT(business_id where city = 'Mesa' and SUBTRACT(closing_time, opening_time) > 8)) as percentage;
Question: How many business are opened for more than 8 hour in Mesa and what is the percentage of the active businesses?
SQL: SELECT cast(sum(CASE WHEN business.active = 'true' THEN 1 ELSE 0 END) AS REAL) * 100 / count(business.business_id) AS act FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id WHERE business.city = 'Mesa'
Database: public_review_platform
Note: opened during late afternoon refers to business_hours where opening_time ≥ '5PM'; active businesses refer to business_id where active = 'true';
Question: How many active businesses are opened during late afternoon in the Phoenix city? List out the top 3 categories name for these businesses.
SQL: SELECT DISTINCT categories.category_name FROM business_hours INNER JOIN business ON business_hours.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 business.active = 'true' AND business.city = 'Phoenix' AND business_hours.opening_time >= '5PM' LIMIT 3
Database: public_review_platform
Note: the most reviews refer to MAX(business_id) where attribute_name = 'Delivery';
Question: Which user has done the most review on a business attributed to delivery?
SQL: SELECT reviews.user_id FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id INNER JOIN reviews ON business_attributes.business_id = reviews.business_id WHERE attributes.attribute_name = 'Delivery' GROUP BY reviews.user_id ORDER BY count(business_attributes.business_id) DESC LIMIT 1
Database: public_review_platform
Note: avg(user_id) where active = 'true' and SUM(SUBTRACT(closing_time, opening_time)) < 30;
Question: What is the average number of reviews written for active businesses that operate not more than 30 hours a week?
SQL: SELECT avg(reviews.user_id) FROM business INNER JOIN business_hours ON business.business_id = business_hours.business_id INNER JOIN reviews ON business.business_id = reviews.business_id WHERE business.active = 'true' GROUP BY business_hours.closing_time - business_hours.opening_time HAVING sum(business_hours.closing_time - business_hours.opening_time) < 30
Database: public_review_platform
Note: opening hours from 8AM to 6PM refer to business_hours where opening_time = '8AM' and closing_time = '6PM';
Question: How many business ids have opening hours from 8AM to 6PM?
SQL: SELECT DISTINCT business_id FROM business_hours WHERE opening_time = '8AM' AND closing_time = '6PM'
Database: public_review_platform
Note: opening hours 10AM on Saturday refer to business_hours where opening_time = '10AM' and day_id = 6;
Question: Provide business ids with opening hours 10AM on Saturday.
SQL: SELECT DISTINCT business_id FROM business_hours WHERE day_id = 6 AND opening_time = '10AM'
Database: public_review_platform
Note: opened from 8AM to 6PM refers to business_hours where opening_time = '8AM' and closing_time = '6PM'; days refer to day_id;
Question: Indicate the business id and days which are opened from 8AM to 6PM.
SQL: SELECT DISTINCT day_id FROM business_hours WHERE opening_time = '8AM' AND closing_time = '6PM'
Database: public_review_platform
Note: rated more than 4 refers to stars > 4;
Question: How many businesses id are rated more than 4?
SQL: SELECT count(business_id) FROM business WHERE stars > 4
Database: public_review_platform
Note: categories of businesses refer to category_name; Sunday refers to day_of_week where day_id = 1;
Question: What are the categories of businesses that have opening time on Sunday?
SQL: SELECT DISTINCT categories.category_name FROM categories INNER JOIN business_categories ON categories.category_id = business_categories.category_id INNER JOIN business_hours ON business_categories.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE days.day_of_week = 'Sunday' AND business_hours.opening_time <> ''
Database: public_review_platform
Note: category is pets refers to category_name = 'Pets'; opening day refers to day_id from business_hours and opening_time;
Question: Please indicate the opening day of businesses whose category is pets.
SQL: SELECT DISTINCT days.day_of_week FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business_hours ON business_categories.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE categories.category_name = 'Pets'
Database: public_review_platform
Note: closing hours refer to closing_time; business days refer to day_id from business_hours;
Question: Please indicate the closing hours and business days of the businesses with the category named Doctors.
SQL: SELECT DISTINCT business_hours.opening_time, business_hours.day_id FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business_hours ON business_categories.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE categories.category_name = 'Doctors'
Database: public_review_platform
Note: days from Monday to Saturday refer to day_id between 2 and 7; work the most days can be computed as MAX(COUNT(category_name where day_id between 2 and 7));
Question: Among the working days from Monday to Saturday, which businesses with the category names work the most days?
SQL: SELECT categories.category_name FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business_hours ON business_categories.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id GROUP BY categories.category_name ORDER BY count(business_hours.day_id) DESC LIMIT 1
Database: public_review_platform
Note: Sunday refers to day_of_week = 'Sunday' where day_id = 1; category of Arts & Entertainment refers to category_name = 'Arts & Entertainment';
Question: Please indicate the business id have the closing time with the category of Arts & Entertainment on Sunday.
SQL: SELECT business_categories.business_id, business_hours.closing_time FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business_hours ON business_categories.business_id = business_hours.business_id INNER JOIN days ON business_hours.day_id = days.day_id WHERE categories.category_name = 'Arts & Entertainment' AND days.day_of_week = 'Sunday'
Database: public_review_platform
Note: category of "DJs" refers to category_name = 'DJs'; rated less than 5 refers to stars < 5; businesses refer to business_id;
Question: In businesses with a category of "DJs", how many businesses are rated less than 5?
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 = 'DJs' AND business.stars < 5