Chinastark/bird_dataset huggingface dataset:
Database: public_review_platform
Note: opening times of 7AM and closing times of 8PM refer to business_hours where opening_time = '7AM' and closing_time = '8PM'; active business refers to business_id where active = 'true';
Question: List active business ids with opening times of 7AM and closing times of 8PM.
SQL: SELECT DISTINCT business.business_id 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 business ON business_hours.business_id = business.business_id WHERE business.active = 'true' AND business_hours.opening_time = '7AM' AND business_hours.closing_time = '8PM'
Database: public_review_platform
Note: rated highest refers to MAX(stars); category_name = 'Stadiums & Arenas';
Question: How many businesses with the category named Stadiums & Arenas are rated highest?
SQL: SELECT count(business_categories.business_id) FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business ON business_categories.business_id = business.business_id WHERE categories.category_name = 'Stadiums & Arenas' AND business.stars = ( SELECT max(stars) FROM business )
Database: public_review_platform
Note: rating more than 2 refers to stars > 2;
Question: How many category id have low review count and rating more than 2?
SQL: SELECT count(DISTINCT categories.category_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 business.review_count = 'Low' AND business.stars > 2
Database: public_review_platform
Note: opening hours before 7AM refer to opening_time < '7AM'; businesses refer to business_id;
Question: Which businesses with the category name Accessories have opening hours before 7AM?
SQL: SELECT business_hours.business_id FROM business_hours INNER JOIN business_categories ON business_hours.business_id = business_categories.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id WHERE categories.category_name = 'Accessories' AND substr(business_hours.opening_time, -4, 2) * 1 < 7 AND business_hours.opening_time LIKE '%AM'
Database: public_review_platform
Note: active businesses in Arizona refer to business_id where state = 'Arizona' and active = 'true'; work after 12PM refer to opening_time > '12PM';
Question: Among the active businesses in Arizona, how many businesses work after 12PM?
SQL: SELECT count(DISTINCT business.business_id) 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.state = 'AZ' AND business_hours.opening_time > '12PM'
Database: public_review_platform
Note: name of business refers to category_name;
Question: Please provide the name of businesses with user id "16328".
SQL: SELECT categories.category_name 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 tips.user_id = 16328
Database: public_review_platform
Note: businesses have the category named food refer to business_id where category_name = 'Food'; DIVIDE(COUNT(business_id where category_name = 'Food' and stars < 2), COUNT(business_id where category_name = 'Food')) as percentage;
Question: How many businesses have the category named food? List those businesses and find the percentage of businesses with less than 2 stars.
SQL: SELECT business.business_id, cast((( SELECT count(business_id) FROM business WHERE stars < 2 ) - ( SELECT count(business_id) FROM business WHERE stars > 2 )) AS REAL) * 100 / ( SELECT count(stars) FROM business ) FROM business_categories INNER JOIN categories ON business_categories.category_id = categories.category_id INNER JOIN business ON business_categories.business_id = business.business_id WHERE categories.category_name = 'Food'
Database: public_review_platform
Note: DIVIDE(COUNT(business_id where category_name = 'Food' and opening_time = '7AM' and closing_time = '8PM'), COUNT(business_id where opening_time = '7AM' and closing_time = '8PM')) as percentage;
Question: Calculate the percentage of businesses with the category name food that are open from 7AM to 8PM in the businesses with the same time.
SQL: SELECT cast(sum(CASE WHEN categories.category_name = 'Food' THEN 1 ELSE 0 END) AS REAL) * 100 / count(categories.category_name) FROM business_categories INNER JOIN business ON business_categories.business_id = business.business_id INNER JOIN categories ON business_categories.category_id = categories.category_id
Database: public_review_platform
Note: number of running business refers to COUNT(business_id) where active = 'true'; each review count includes review_count = 'High', review_count = 'Medium', review_count = 'Low';
Question: Write down the number of running business with each review count in Cave Creek city.
SQL: SELECT sum(CASE WHEN review_count = 'High' THEN 1 ELSE 0 END) AS high , sum(CASE WHEN review_count = 'Medium' THEN 1 ELSE 0 END) AS medium , sum(CASE WHEN review_count = 'Low' THEN 1 ELSE 0 END) AS low FROM business WHERE city = 'Cave Creek' AND active = 'true'
Database: public_review_platform
Note: avg(user_id) where user_yelping_since_year BETWEEN '2005' AND '2014';
Question: Calculate the yearly average user who started using Yelp from the year of 2005 to 2014.
SQL: SELECT avg(user_id) FROM users WHERE user_yelping_since_year >= 2005 AND user_yelping_since_year <= 2015
Database: public_review_platform
Note: DIVIDE(COUNT(business_id where review_count = 'Low' and active = 'true'), COUNT(business_id where review_count = 'Low' and active = 'false'));
Question: What is the active and inactive ratio of the business with the review count of low.
SQL: SELECT cast(sum(CASE WHEN active = 'true' THEN 1 ELSE 0 END) AS REAL) / sum(CASE WHEN active = 'false' THEN 1 ELSE 0 END) AS radio FROM business WHERE review_count = 'Low'
Database: public_review_platform
Note: year_id = '2006';
Question: List any five of user ID who became elite user in 2006.
SQL: SELECT user_id FROM elite WHERE year_id = 2006 LIMIT 5
Database: public_review_platform
Note: category that starts with alphabet "P" refers to category_name like 'P%';
Question: Write down the any five of ID and name of category that starts with alphabet "P".
SQL: SELECT category_id, category_name FROM categories WHERE category_name LIKE 'P%' LIMIT 5
Database: public_review_platform
Note: ;
Question: Provide the list of user ID along with review star of which has the review length of medium with business ID of 35.
SQL: SELECT user_id, review_stars FROM reviews WHERE business_id = 15 AND review_length = 'Medium'
Database: public_review_platform
Question: List down the business ID and attribute value of the attribute name of "payment_types_visa".
SQL: SELECT business_attributes.business_id, business_attributes.attribute_value FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id WHERE attributes.attribute_name = 'payment_types_visa'
Database: public_review_platform
Note: ID refers to business_id; category of "Diagnostic Imaging" refers to category_name = 'Diagnostic Imaging';
Question: Describe ID and active status of the business under category of "Diagnostic Imaging".
SQL: SELECT business_categories.business_id, business.active 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 = 'Diagnostic Imaging'
Database: public_review_platform
Note: year of joining Yelp refers to user_yelping_since_year; great experience refers to reviews where review_stars = 5;
Question: Mention the user ID and their year of joining Yelp who had great experience on business ID 143.
SQL: SELECT users.user_id, users.user_yelping_since_year FROM reviews INNER JOIN users ON reviews.user_id = users.user_id WHERE reviews.business_id = 143 AND reviews.review_stars = 5
Database: public_review_platform
Note: when join Yelp refers to user_yelping_since_year; compliment_type = 'profile'; number_of_compliments = 'Uber';
Question: Among the user ID with number in compliment of uber on profile, list any 5 user ID and the year when they join Yelp.
SQL: SELECT users.user_id, users.user_yelping_since_year FROM compliments INNER JOIN users_compliments ON compliments.compliment_id = users_compliments.compliment_id INNER JOIN users ON users_compliments.user_id = users.user_id WHERE compliments.compliment_type = 'profile' AND users_compliments.number_of_compliments = 'Uber' LIMIT 5
Database: public_review_platform
Note: business which received the most likes refers to business_id where MAX(likes);
Question: List the user ID, business ID with review length of the business which received the most likes in tips.
SQL: SELECT tips.user_id, tips.business_id, reviews.review_length FROM tips INNER JOIN reviews ON tips.business_id = reviews.business_id ORDER BY tips.likes DESC LIMIT 1
Database: public_review_platform
Note: from 2005 to 2014 refers to year_id BETWEEN 2005 AND 2014; compliment_type = 'photos';
Question: Among the elite users of 10 consecutive year from 2005 to 2014, list down the user ID and their number of compliment on photos.
SQL: SELECT users_compliments.user_id, users_compliments.number_of_compliments FROM compliments INNER JOIN users_compliments ON compliments.compliment_id = users_compliments.compliment_id INNER JOIN elite ON users_compliments.user_id = elite.user_id WHERE elite.year_id BETWEEN 2005 AND 2014 AND compliments.compliment_type = 'photos'
Database: public_review_platform
Note: Sunday refers to day_of_week = 'Sunday' where day_id = 1; opened from 9AM to 9PM refers to business_hours where opening_time = '9AM' and closing_time = '9PM'; DIVIDE(COUNT(opening_time = '9AM' and closing_time = '9PM' and day_of_week = 'Sunday'), COUNT(opening_time = NOT NULL and closing_time = NOT NULL and day_of_week = 'Sunday')) as percentage;
Question: Calculate the percentage of business which opened on Sunday from 9AM to 9PM based on the number of business opened on Sunday.
SQL: SELECT cast(sum(CASE WHEN business_hours.opening_time = '9AM' AND business_hours.closing_time = '9PM' THEN 1 ELSE 0 END) AS REAL) * 100 / count(days.day_id) FROM days INNER JOIN business_hours ON days.day_id = business_hours.day_id WHERE days.day_of_week = 'Sunday'
Database: public_review_platform
Note: running refers to active = 'true'; opening day of a week means days of the week when business is open;
Question: Write down the ID and opening day of a week for the business which are running in Black Canyon City.
SQL: SELECT business_hours.business_id, 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 = 'Black Canyon City' AND business.active = 'true'
Database: public_review_platform
Note: user who joined Yelp in 2004 refers to user_id where user_yelping_since_year = 2014; user_average_stars = 5;
Question: Within the user who joined Yelp in 2004, explore the user ID with average star of 5 and it's review length on the business.
SQL: SELECT reviews.user_id, reviews.review_length FROM users INNER JOIN reviews ON users.user_id = reviews.user_id WHERE users.user_yelping_since_year = 2004 AND users.user_average_stars = 5
Database: public_review_platform
Note: review of 4 star and above refers to stars > 4; DIVIDE(SUM(stars > 4), COUNT(business_id)) = 0.65;
Question: Which business ID received the review of 4 star and above by 65% of user? Describe their active status and city.
SQL: SELECT DISTINCT business.business_id, business.city FROM reviews INNER JOIN business ON reviews.business_id = business.business_id WHERE reviews.review_stars >= 4 AND ( SELECT cast(( SELECT count(DISTINCT reviews.user_id) FROM reviews INNER JOIN business ON reviews.business_id = business.business_id WHERE reviews.review_stars >= 4 ) AS REAL) * 100 / ( SELECT count(user_id) FROM users ) > 65 )
Database: public_review_platform
Note: running business refers to business where active = 'true';
Question: Calculate the difference between running business in Glendale City and Mesa City.
SQL: SELECT sum(CASE WHEN city = 'Glendale' THEN 1 ELSE 0 END) - sum(CASE WHEN city = 'Mesa' THEN 1 ELSE 0 END) AS diff FROM business WHERE active = 'true'
Database: public_review_platform
Note: short comment refers to tip_length = 'Short'; users who joined in 2010 refer to user_id where user_yelping_since_year = 2010;
Question: How many likes did short comment left by users who joined in 2010 get?
SQL: SELECT sum(tips.likes) FROM users INNER JOIN tips ON users.user_id = tips.user_id WHERE users.user_yelping_since_year = 2010
Database: public_review_platform
Note: average ratings of 3 refer to user_average_stars = 3; kind of tip length they mostly left refers to tip_length where MAX(COUNT(user_id));
Question: For users with average ratings of 3, what kind of tip length they mostly left?
SQL: SELECT tips.tip_length FROM users INNER JOIN tips ON users.user_id = tips.user_id WHERE users.user_average_stars = 3 GROUP BY tips.tip_length ORDER BY count(tips.tip_length) DESC LIMIT 1
Database: public_review_platform
Note: short reviews refer to tip_length = 'Short';
Question: Sum up the likes get by short reviews on businesses located in City Goodyear.
SQL: SELECT sum(tips.likes) AS likes FROM business INNER JOIN tips ON business.business_id = tips.business_id WHERE business.city = 'Goodyear'
Database: public_review_platform
Note: businesses with long length tips refer to business_id where tip_length = 'Long';
Question: For businesses with long length reviews, which state are they located?
SQL: SELECT DISTINCT business.state FROM business INNER JOIN tips ON business.business_id = tips.business_id WHERE tips.tip_length = 'Long'
Database: public_review_platform
Note: how much time does this business open refers to SUBTRACT(closing_time, opening_time); DIVIDE(SUM(SUBTRACT(closing_time, opening_time)), SUM(business.business_id));
Question: How much time do businesses in El Mirage City, AZ State operate in average daily?
SQL: SELECT sum(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 = 'El Mirage' AND business.state = 'AZ'
Database: public_review_platform
Note: closing day refers to SUBTRACT(days.day_id, business_hours.day_id);
Question: List down the closing day of businesses located at SC State.
SQL: SELECT days.day_id - business_hours.day_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.state = 'SC'
Database: public_review_platform
Note: category of businesses refers to category_name; stars ratings are 5 refers to stars = 5;
Question: List down the category of businesses whose stars ratings are 5.
SQL: SELECT DISTINCT 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 = 5
Database: public_review_platform
Note: with attribute of beer and wine refers to attribute_value = 'beer_and_wine';
Question: What are the states of businesses with attribute of beer and wine located?
SQL: SELECT DISTINCT business.state FROM business_attributes INNER JOIN business ON business_attributes.business_id = business.business_id WHERE business_attributes.attribute_value = 'beer_and_wine'
Database: public_review_platform
Note: user's compliment in photo refers to compliment_type = 'photo'; photo has medium in number refers to number_of_compliments = 'Medium';
Question: How many user's compliment in photo has medium in number?
SQL: SELECT count(users_compliments.user_id) FROM compliments INNER JOIN users_compliments ON compliments.compliment_id = users_compliments.compliment_id WHERE compliments.compliment_type = 'photos' AND users_compliments.number_of_compliments = 'Medium'
Database: public_review_platform
Note: "Wi-Fi" attribute refers to attribute_name = 'Wi-Fi' AND attribute_value = 'true';
Question: Among businesses with "Wi-Fi" attribute, which businesses id are located at SC State?
SQL: SELECT business.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 attributes.attribute_name = 'Wi-Fi' AND business_attributes.attribute_value = 'true' AND business.state = 'SC'
Database: public_review_platform
Note: "ambience_romantic" attribute refers to attribute_name = 'ambience_romantic' AND attribute_value = 'true';
Question: Sum up the number of business with "ambience_romantic" attribute.
SQL: SELECT count(business_attributes.business_id) FROM attributes INNER JOIN business_attributes ON attributes.attribute_id = business_attributes.attribute_id WHERE attributes.attribute_name = 'ambience_romantic' AND business_attributes.attribute_value = 'true'
Database: public_review_platform
Note: "Good for Kids" attribute refers to attribute_name = 'Good for Kids' AND attribute_value = 'true'; Calculation = DIVIDE(SUM(attribute_name = 'Good for Kids' AND attribute_value = 'true')), SUM(business_id) * 100;
Question: What is the percentage of businesses with "Good for Kids" attribute over the other attributes?
SQL: SELECT cast(sum(CASE WHEN attribute_name = 'Good for Kids' THEN 1 ELSE 0 END) AS REAL) * 100 / 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'
Database: public_review_platform
Note: businesses are not closed refers to active = 'true';
Question: How many businesses are not closed in the city of Mesa?
SQL: SELECT count(business_id) FROM business WHERE city = 'Mesa' AND active = 'true'
Database: public_review_platform
Note: stars = 2 means bad experience; stars = 1 means terrible experience; customers had a bad or terrible experience refers to stars = 2 OR stars = 1;
Question: In how many businesses have customers had a bad or terrible experience?
SQL: SELECT count(business_id) FROM business WHERE stars IN (1, 2)
Database: public_review_platform
Note: ID of businesses refers to business_id; reviews with the lowest veracity refers to review_count = 'Low' AND stars > 3; Paradise Valley is a city;
Question: List by ID the businesses with the reviews with the lowest veracity of Paradise Valley.
SQL: SELECT business_id FROM business WHERE stars > 3 AND city = 'Paradise Valley' AND review_count = 'Low'
Database: public_review_platform
Note: businesses have more than 1 attribute refers to COUNT(attribute_value) > 1;
Question: How many businesses have more than 1 attribute?
SQL: SELECT count(business_id) FROM business_attributes WHERE attribute_value > 1
Database: public_review_platform
Note: how much time does this business open refers to SUBTRACT(closing_time, opening_time); every day of the week refers to day_id BETWEEN 1 AND 7;
Question: How many businesses are opened the same number of hours every day of the week?
SQL: SELECT count(business_id) FROM business_hours WHERE opening_time = '8AM' AND closing_time = '6PM'
Database: public_review_platform
Note: businesses that still open refers to active = 'true'; business received an uber rating on the funny vote refers to review_votes_funny = 'Uber';
Question: How many reviews of businesses that are still open received an uber rating on the funny vote?
SQL: SELECT count(business.business_id) FROM business INNER JOIN reviews ON business.business_id = reviews.business_id WHERE reviews.review_votes_funny = 'Uber' AND business.active = 'true'
Database: public_review_platform
Note: do not have fans refers to user_fans = 'None'; high number of compliment refers to number_of_compliments = 'High';
Question: How many of the users who use a high number of compliments do not have any fans?
SQL: SELECT count(users.user_id) FROM users_compliments INNER JOIN users ON users_compliments.user_id = users.user_id WHERE users_compliments.number_of_compliments = 'High' AND users.user_fans = 'None'
Database: public_review_platform
Note: the most common type of compliments refers to MAX(COUNT(compliment_type));
Question: What is the most common type of compliments that a user has received from other users?
SQL: SELECT compliments.compliment_type FROM users_compliments INNER JOIN compliments ON users_compliments.compliment_id = compliments.compliment_id GROUP BY compliments.compliment_type ORDER BY count(compliments.compliment_type) DESC LIMIT 1
Database: public_review_platform
Note: more likes mean this tip is more valuable; the most likes refers to MAX(likes); stars refers to users_average_stars;
Question: How many stars does each of the 3 top users with the most likes in their reviews have?
SQL: SELECT users.user_average_stars FROM tips INNER JOIN users ON tips.user_id = users.user_id GROUP BY users.user_id ORDER BY sum(tips.likes) DESC LIMIT 3
Database: public_review_platform
Note: categories refers to category_name;
Question: In which categories does the only business located in the city of Arcadia appear?
SQL: SELECT categories.category_name 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 business.city = 'Arcadia'
Database: public_review_platform
Note: day_of_week = 'Sunday'; open on Sunday refers to day_id = 1;
Question: List by their id all businesses that are open on Sunday.
SQL: SELECT business_hours.business_id FROM business_hours INNER JOIN days ON business_hours.day_id = days.day_id WHERE business_hours.day_id = 1
Database: public_review_platform
Note: music_karaoke attribute refers to attribute_name = 'music_karaoke' AND attribute_value = 'true'; businesses are closed refers to active = 'false';
Question: How many businesses with music_karaoke attribute are closed?
SQL: SELECT count(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 attributes.attribute_name = 'music_karaoke' AND business.active = 'false' AND business_attributes.attribute_value IN ('none', 'no', 'false')
Database: public_review_platform
Note: open businesses refers to active = 'true'; long review refers to review_length = 'Long';
Question: How many open businesses in the City of Phoenix have users left a long review?
SQL: SELECT count(DISTINCT business.business_id) FROM reviews INNER JOIN business ON reviews.business_id = business.business_id WHERE reviews.review_length = 'Long' AND business.active = 'true' AND business.city = 'Phoenix'
Database: public_review_platform
Note: low cool vote for user refers to user_votes_cool = 'Low';  low cool vote for review refers to review_votes_cool = 'Low';
Question: How many users who have received a low cool vote have also received at least 1 low cool vote for some of their reviews?
SQL: SELECT count(DISTINCT users.user_id) FROM users INNER JOIN reviews ON users.user_id = reviews.user_id WHERE users.user_votes_cool = 'Low' AND reviews.review_votes_cool = 'Low'
Database: public_review_platform
Note: long tip refers to tip_length = 'Long'; 2 likes refers to likes = 2; high number of fans refers to user_fans = 'High';
Question: How many users with a long tip and 2 likes for their tip have a high number of fans?
SQL: SELECT count(DISTINCT users.user_id) FROM users INNER JOIN tips ON users.user_id = tips.user_id WHERE tips.tip_length = 'Long' AND tips.likes = 2 AND users.user_fans = 'High'