db_id
stringclasses
68 values
question
stringlengths
24
325
evidence
stringlengths
0
580
SQL
stringlengths
23
728
public_review_platform
Does Yelp business No."11825" have a "parking lot"?
business No."11825" refers to business_id = '12476'; have a "parking lot" refers to attribute_value = 'parking_lot'
SELECT T1.attribute_value FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.business_id = 11825 AND T2.attribute_name = 'parking_lot'
public_review_platform
Is the payment in mastercard possible for the Yelp business No."12476"?
Yelp business No."12476" refers to business_id = '12476'; payment in mastercard refers to attribute_value = 'payment_types_mastercard'
SELECT T1.attribute_value FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.business_id = 12476 AND T2.attribute_name = 'payment_types_mastercard'
public_review_platform
What is the percentage for the Yelp businesses in "Pets" category of all businesses?
businesses in "Pets" category refers to category_name = 'Pets'; percentage refers to DIVIDE(COUNT(category_name = 'Pets'), COUNT(business_id)) * 100%
SELECT CAST(SUM(CASE WHEN T2.category_name = 'Pets' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.category_name) FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
public_review_platform
How many times is the number of "Women's Clothing" Yelp businesses to "Men's Clothing"?
"Women's Clothing" Yelp businesses refers to  category_name = 'Women''s Clothing'; "Men's Clothing" refers to category_name = 'Men''s Clothing'; times refers to DIVIDE(COUNT(category_name = 'Women''s Clothing'), COUNT(category_name = 'Men''s Clothing'))
SELECT CAST(SUM(CASE WHEN T2.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) AS TIMES FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
public_review_platform
Write down the ID, active status and city of the business which are in CA state.
the ID refers to business_id; active status refers to active; active = 'true' means the business is still running; active = 'false' means the business is closed or not running now
SELECT business_id, active, city FROM Business WHERE state = 'CA' AND active = 'true'
public_review_platform
Calculate the percentage of running business among all business.
running business refers to active = 'true'; percentage refers to DIVIDE(COUNT(active = 'true'), COUNT(business_id)) * 100%
SELECT CAST(SUM(CASE WHEN active = 'true' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(business_id) FROM Business
public_review_platform
Among all attribute names, list down the ID and attribute name which start with "music".
attribute name which start with "music" refers to attribute_name LIKE 'music%'
SELECT attribute_id, attribute_name FROM Attributes WHERE attribute_name LIKE 'music%'
public_review_platform
Between 2006 and 2007, which year ID had the greater number in elite user?
2006 and 2007 refers to BETWEEN 2006 AND 2007; greater number in elite user refers to count(user_id)
SELECT year_id FROM Elite WHERE year_id IN (2006, 2007) GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1
public_review_platform
Based on all user compliments, find the percentage of low number of compliments on all compliments ID.
low number of compliments refers to number_of_compliments = 'Low'; percentage refers to DIVIDE(COUNT(number_of_compliments = 'Low'), COUNT(user_id)) * 100
SELECT CAST(SUM(CASE WHEN number_of_compliments = 'Low' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(user_id) FROM Users_compliments
public_review_platform
List down the business ID and user ID who got uber for cool votes.
got uber for cool votes refers to review_votes_cool = 'Uber'
SELECT business_id, user_id FROM Reviews WHERE review_votes_cool = 'Uber'
public_review_platform
Write the user ID, business ID and tips length of who started using Yelp since 2004 and had high followers.
started using Yelp since 2004 refers to user_yelping_since_year = '2004'; had high followers refers to user_fans = 'High'
SELECT T1.user_id, T2.business_id, T2.tip_length FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2004 AND T1.user_fans = 'High'
public_review_platform
Among the review votes of funny and cool hit uber with long review length, describe the business ID, active status, user ID and user year of joining Yelp.
review votes of funny refers to review_votes_funny = 'Uber'; cool hit uber refers to review_votes_cool = 'Uber'; user year of joining Yelp refers to user_yelping_since_year
SELECT T1.business_id, T1.active, T3.user_id, T3.user_yelping_since_year FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id INNER JOIN Users AS T3 ON T2.user_id = T3.user_id WHERE T2.review_votes_cool = 'Uber' AND T2.review_votes_funny = 'Uber' AND T2.review_length = 'Long'
public_review_platform
Under the attribute name of "music_playlist", describe the attribute ID, business ID, city and inactive status.
active status refers to active; active = 'true' means the business is still running; active = 'false' means the business is inactive or not running now
SELECT T1.attribute_id, T2.business_id, T3.city FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name = 'music_playlist' AND T3.active = 'false'
public_review_platform
Calculate the percentage of business with attribute name of "Accepts Credit Cards".
percentage refers to DIVIDE(COUNT(attribute_name = 'Accepts Credit Cards'), COUNT(business_id))*100%
SELECT CAST(SUM(CASE WHEN T1.attribute_name = 'Accepts Credit Cards' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.attribute_name) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id
public_review_platform
Among the stopped businesses in San Tan Valley city, list down the user ID and review length of who had great experience.
stop businesses refers to active = 'false'; great experience refers to review_stars = 5
SELECT T2.user_id, T2.review_length FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'San Tan Valley' AND T1.active = 'false' AND T2.review_stars = 5
public_review_platform
Mention the user average star, elite year and the compliment type of user ID 6027 whereby number of compliments reach uber.
number of compliments reach uber refers to number_of_compliments = 'Uber'; elite year refers to year_id; user average star refers to user_average_stars
SELECT T2.user_average_stars, T1.year_id, T4.compliment_type, T3.number_of_compliments FROM Elite AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id INNER JOIN Users_Compliments AS T3 ON T2.user_id = T3.user_id INNER JOIN Compliments AS T4 ON T3.compliment_id = T4.compliment_id INNER JOIN Years AS T5 ON T1.year_id = T5.year_id WHERE T3.number_of_compliments = 'Uber' AND T3.user_id = 6027
public_review_platform
Under the category name of "Coffee & Tea", mention any 5 business ID , their state and city.
SELECT T2.business_id, T3.state, T3.city FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Coffee & Tea' LIMIT 5
public_review_platform
For the business with great experience existed in Sun Lakes city, provide the user ID who gave review on it and user followers.
with great experience refers to stars = 5
SELECT T3.user_id, T3.user_fans FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id INNER JOIN Users AS T3 ON T2.user_id = T3.user_id WHERE T1.city = 'Sun Lakes' AND T1.stars = 5
public_review_platform
Compare the number of business between the category of "Men's Clothing" and "Women's Clothing".
category of "Men's Clothing" refers to category_name = 'Men''s Clothing'; "Women's Clothing" refers to category_name = 'Women''s Clothing'
SELECT SUM(CASE WHEN T1.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS diff FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id
public_review_platform
Among highest quality user of under ID 100, mention compliment type which got highest compliment number and user's followers.
highest quality user refers to number_of_compliments = 'Uber'; user of under ID 100 refers to user_id < 100 ;
SELECT T1.compliment_type, T3.user_fans FROM Compliments AS T1 INNER JOIN Users_Compliments AS T2 ON T1.compliment_id = T2.compliment_id INNER JOIN Users AS T3 ON T2.user_id = T3.user_id WHERE T2.number_of_compliments = 'Uber' AND T2.user_id < 100
public_review_platform
List all the businesses that closed at 8PM.
closed at 8PM refers to closing_time = '8PM';
SELECT DISTINCT business_id FROM Business_Hours WHERE closing_time = '8PM'
public_review_platform
How many 2 stars rated business located in Phoenix, Arizona?
located in Phoenix refers to city = 'Phoenix'; Arizona refers to state = 'AZ'
SELECT COUNT(business_id) FROM Business WHERE city = 'Phoenix' AND state = 'AZ' AND stars = 2
public_review_platform
How many businesses in Tempe are rated as 'Wonderful experience?
in Tempe refers to city = 'Tempe'; rated as 'Wonderful experience refers to stars > 3
SELECT COUNT(business_id) FROM Business WHERE city = 'Phoenix' AND stars > 3
public_review_platform
Find the percentage of 5 stars rated business.
percentage refers to DIVIDE(COUNT(stars = 5), COUNT(business_id)) * 100%
SELECT CAST(SUM(CASE WHEN stars = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(stars) FROM Business
public_review_platform
Calculate difference between business that have the highest number of reviews and business that have the lowest number of reviews.
highest number of reviews refers to SUBTRACT(MAX(COUNT(business_id), MIN(COUNT(business_id))))
SELECT ( SELECT COUNT(business_id) FROM Reviews GROUP BY business_id ORDER BY COUNT(business_id) DESC LIMIT 1 ) - ( SELECT COUNT(business_id) FROM Reviews GROUP BY business_id ORDER BY COUNT(business_id) ASC LIMIT 1 ) AS DIFF
public_review_platform
List all the tires businesses that are opened everyday.
tires businesses refers to category_name = 'Tires'; opened everyday refers to COUNT(distinct opening_time) = 7;
SELECT DISTINCT T2.business_id FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id INNER JOIN Business_Hours AS T4 ON T3.business_id = T4.business_id WHERE T1.category_name = 'Tires' GROUP BY T2.business_id HAVING COUNT(day_id) = 7
public_review_platform
Which users become an elite in 2012?
in 2012 refers to actual_year = 2012;
SELECT DISTINCT T1.user_id FROM Elite AS T1 INNER JOIN Years AS T2 ON T1.year_id = T2.year_id WHERE T2.actual_year = 2012
public_review_platform
List the business ID of shopping business that have 4 stars ratings.
shopping business refers to category_name = 'Shopping'; 4 stars ratings refers to stars = 4
SELECT T1.business_id FROM Business AS T1 INNER JOIN Business_Categories AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T2.category_id = T3.category_id WHERE T3.category_name = 'Shopping' AND T1.stars = 4
public_review_platform
How many business have low check-in on Sunday at 10AM?
on Sunday refers to day_of_week = 'Sunday'; low check-in at 10AM refers to label_time_10 = 'Low'
SELECT COUNT(T2.business_id) FROM Days AS T1 INNER JOIN Checkins AS T2 ON T1.day_id = T2.day_id WHERE T1.day_of_week = 'Sunday' AND T2.label_time_10 = 'Low'
public_review_platform
How many businesses in Glendale are reviewed by user with the ID of 20241?
in Glendale refers to city = 'Glendale'
SELECT COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Glendale' AND T2.user_id = 20241
public_review_platform
State the locations of all Pet Services business.
location refers to city; Pet Services business refers to category_name = 'Pet Services'
SELECT T1.city FROM Business AS T1 INNER JOIN Business_Categories AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T2.category_id = T3.category_id WHERE T3.category_name = 'Pet Services'
public_review_platform
How many photos type compliment given from users with high cool votes?
photos type compliment refers to compliment_type = 'photos'; high cool votes refers to review_votes_cool = 'High'
SELECT COUNT(T1.user_id) FROM Users AS T1 INNER JOIN Users_Compliments AS T2 ON T1.user_id = T2.user_id INNER JOIN Compliments AS T3 ON T2.compliment_id = T3.compliment_id INNER JOIN Reviews AS T4 ON T1.user_id = T4.user_id WHERE T3.compliment_type = 'photos' AND T4.review_votes_cool = 'High'
public_review_platform
How many closed businesses that have more than 10 attributes?
closed refers to active = 'false'; more than 10 attributes refers to count(attribute_id) > 10
SELECT COUNT(*) FROM Business WHERE business_id IN ( SELECT T1.business_id FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id WHERE T1.active = 'false' GROUP BY T1.business_id HAVING COUNT(DISTINCT T2.attribute_id) > 10 )
public_review_platform
List the business located in Mesa that have alcohol attribute.
in Mesa refers to city = 'Mesa'; alcohol attribute refers to attribute_name = 'Alcohol'
SELECT T1.business_id FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id INNER JOIN Attributes AS T3 ON T2.attribute_id = T3.attribute_id WHERE T1.city = 'Mesa' AND T3.attribute_name = 'Alcohol'
public_review_platform
Based on business in Phoenix, calculate the percentage of business with low funny votes.
in Chandelier refers to city = 'Chandelier'; percentage = divide(count(business_id where review_votes_funny = 'Low'), count(business_id)); business with low funny votes refers to review_votes_funny = 'Low'
SELECT CAST(SUM(CASE WHEN T2.review_votes_funny = 'Low' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Phoenix'
public_review_platform
What is the ratio between business in shopping category and business in pets category?
ratio = divide(count(business_id where category_name = 'Shopping'), count(business_id where category_name = 'Pets'))
SELECT CAST(SUM(CASE WHEN T2.category_name = 'Shopping' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.category_name = 'Pets' THEN 1 ELSE 0 END) AS radio FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
public_review_platform
How many businesses are registered in the database under 'Banks & Credit Unions' category?
category refers to category_name
SELECT COUNT(T2.business_id) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id WHERE T1.category_name = 'Banks & Credit Unions'
public_review_platform
How many active businesses from Casa Grande are registered in the database?
active business refers to active = 'true'; Casa Grande refers to city = 'Casa Grande'
SELECT COUNT(business_id) FROM Business WHERE active = 'true' AND city = 'Casa Grande'
public_review_platform
What time does the business with ID no.12 open on Monday?
open time refers to opening_time; on Monday refers to day_of_week = 'Monday'; business with ID no. refers to business_id
SELECT T1.opening_time FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id WHERE T1.business_id = 12 AND T2.day_of_week = 'Monday'
public_review_platform
How many businesses that are registered in the database can be attributed to 'Good for Kids'?
can be attributed to 'Good for Kids' refers to attribute_name = 'Good for Kids' and attribute_value = 'true'
SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.attribute_name = 'Good for Kids' AND T2.attribute_value = 'true'
public_review_platform
Identify the most popular and appealing active business in Gilbert based on users' reviews.
most popular and appealing refers to review_count = 'High' and max(stars); active business refers to active = 'true'; in Gilbert refers to city = 'Gilbert'
SELECT business_id FROM Business WHERE city = 'Gilbert' AND active = 'true' AND review_count = 'High' ORDER BY stars DESC LIMIT 1
public_review_platform
Find the 5-star business in Ahwatukee, AZ and identify it's business category.
5-star refers to stars = 5; in Ahwatukee refers to city = 'Ahwatukee'; business category refers to category_name
SELECT T1.business_id, T3.category_name FROM Business AS T1 INNER JOIN Business_Categories AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T2.category_id = T3.category_id WHERE T1.city = 'Ahwatukee' AND T1.stars = 5
public_review_platform
Among all closed businesses in Avondale, AZ what percent have obtained a 'wonderful experience' rating of the business.
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%
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'
public_review_platform
Identify the user who has been yelping since 2004. Is he or she an Yelp Elite member?
has been yelping since 2004 refers to user_yelping_since_year = 2004
SELECT DISTINCT T2.user_id FROM Users AS T1 INNER JOIN Elite AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2004
public_review_platform
Identify the percent of long reviews among all 5-star reviews given to businesses by the Yelp users.
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
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
public_review_platform
How many short tips were left for the business with ID no.2?
short tip refers to tip_length = 'Short'; business category refers to category_name
SELECT COUNT(business_id) FROM Tips WHERE business_id = 2 AND tip_length = 'Short'
public_review_platform
Among all the users who received the high number of compliments, what percent received the 'cute' type of compliment.
high number of compliments refers to number_of_compliments = 'High'; percentage = divide(count(user_id where compliment_type = 'cute'), count(user_id))*100%
SELECT CAST(SUM(CASE WHEN T1.compliment_type = 'cute' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.user_id) FROM Compliments AS T1 INNER JOIN Users_Compliments AS T2 ON T1.compliment_id = T2.compliment_id WHERE T2.number_of_compliments = 'High'
public_review_platform
Mention the number of businesses that have no any attribute.
have no attribute refers to attribute_value in( 'none', 'no', 'false')
SELECT COUNT(business_id) FROM Business_Attributes WHERE attribute_value IN ('none', 'no', 'false')
public_review_platform
List out city name of businesses which have medium length of review.
medium length of review refers to review_length = 'Medium'
SELECT DISTINCT T1.city FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T2.review_length = 'Medium'
public_review_platform
Among the businesses which have short length of review, which one located in Phoenix?
short length of review refers to review_length = 'Short'; in Phoenix refers to city = 'Phoenix'
SELECT DISTINCT T1.business_id FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Phoenix' AND T2.review_length = 'Short'
public_review_platform
Among the users whose fan is medium, how many users received high compliments from other users.
is medium refers to user_fans = 'Medium'; high compliments refers to number_of_compliments = 'High'
SELECT COUNT(T1.user_id) FROM Users AS T1 INNER JOIN Users_Compliments AS T2 ON T1.user_id = T2.user_id WHERE T2.number_of_compliments = 'High' AND T1.user_fans = 'Medium'
public_review_platform
Among the users who received low compliments from other users, which users joined Yelp in 2012?
low compliments refers to number_of_compliments = 'Low'; joined Yelp in 2012 refers to user_yelping_since_year = 2012
SELECT DISTINCT T2.user_id FROM Users AS T1 INNER JOIN Users_Compliments AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2012 AND T2.number_of_compliments = 'Low'
public_review_platform
Among the businesses without attribute, how many businesses located in Gilbert?
without attribute refers to attribute_value = 'None'; in Gilbert refers to city = 'Gilbert'
SELECT COUNT(T2.business_id) FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T2.city = 'Gilbert' AND T1.attribute_value IN ('None', 'no', 'false')
public_review_platform
Among the businesses with average rating, how many business has attribute of full_bar.
average rating refers to avg(stars); attribute of full_bar refers to attribute_value = 'full_bar'
SELECT COUNT(T1.business_id) FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.attribute_value = 'full_bar'
public_review_platform
List out the state of businesses which have opening time at 1AM.
state refers to city
SELECT DISTINCT T1.state FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T2.opening_time = '1AM'
public_review_platform
List out the category name of business id 5.
SELECT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id WHERE T2.business_id = 5
public_review_platform
List out the user id that has compliment type of photos.
compliment type of photos refers to compliment_type = 'photos'
SELECT T2.user_id FROM Compliments AS T1 INNER JOIN Users_Compliments AS T2 ON T1.compliment_id = T2.compliment_id WHERE T1.compliment_type = 'photos'
public_review_platform
State the state of businesses which have closing time at 12AM.
state refers to city
SELECT DISTINCT T1.state FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T2.closing_time = '12AM'
public_review_platform
Among the businesses which have attribute of beer_and_wine, how many business located in Peoria?
attribute of beer_and_wine refers to attribute_value = 'beer_and_wine'; in Peoria refers to city = 'Peoria'
SELECT COUNT(T1.business_id) FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T2.city = 'Peoria' AND T1.attribute_value = 'beer_and_wine'
public_review_platform
Among the users who received high compliments from other users, which users joined Yelp earliest?
high compliments refers to number_of_compliments = ' High'; joined Yelp earliest refers to min(user_yelping_since_year)
SELECT T2.user_id FROM Users AS T1 INNER JOIN Users_Compliments AS T2 ON T1.user_id = T2.user_id WHERE T2.number_of_compliments = 'High' AND T1.user_yelping_since_year = ( SELECT MIN(user_yelping_since_year) FROM Users )
public_review_platform
Which business ID has the most reviews?
the most reviews refer to MAX(user_id);
SELECT business_id FROM Reviews GROUP BY business_id ORDER BY COUNT(user_id) DESC LIMIT 1
public_review_platform
Which year has the most elite users?
year has the most elite users refers to year_id with MAX(user_id);
SELECT year_id FROM Elite GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1
public_review_platform
How many 5 star businesses have uber review votes for funny?
businesses refer to business_id; review_stars = 5.0; review_votes_funny = 'uber';
SELECT COUNT(business_id) FROM Reviews WHERE review_stars = 5 AND review_votes_funny = 'Uber'
public_review_platform
How many users have uber review votes for funny from the fans?
users refer to user_id; review_votes_funny = 'uber';
SELECT COUNT(DISTINCT user_id) FROM Reviews WHERE review_votes_funny = 'Uber'
public_review_platform
Find out which business ID are opened all the time.
opened all the time refers to Business_Hours where day_id BETWEEN 1 and 7 and opening_time = closing_time;
SELECT DISTINCT business_id FROM Business_Hours WHERE day_id >= 1 AND day_id < 8 AND opening_time = closing_time
public_review_platform
Does the length of the tip influence the number of likes for hotel and travel business category?
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';
SELECT T3.tip_length, SUM(T3.likes) AS likes FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Tips AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Hotels & Travel' GROUP BY T3.tip_length
public_review_platform
What is the ratio of good to bad business star for a businesses that are opened all the time?
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));
SELECT CAST(SUM(CASE WHEN T1.stars BETWEEN 3.5 AND 5 THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.stars BETWEEN 1 AND 2.5 THEN 1 ELSE 0 END) AS ratio FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id
public_review_platform
How many businesses in Arizona having an average review less than 3 stars?
businesses in Arizona refer to business_id where state = 'Arizona'; average review less than 3 stars refers to AVG(review_stars) < 3.0;
SELECT COUNT(business_id) FROM Business WHERE business_id IN ( SELECT DISTINCT T1.business_id FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.state = 'AZ' GROUP BY T1.business_id HAVING SUM(T2.review_stars) / COUNT(T2.user_id) < 3 )
public_review_platform
What is the percentage of user not becoming an elite user?
DIVIDE(SUBTRACT(COUNT(user_id), COUNT(Elite.user_id)), COUNT(user_id)) as percentage;
SELECT CAST((( SELECT COUNT(user_id) FROM Users ) - ( SELECT COUNT(DISTINCT user_id) FROM Elite )) AS REAL) * 100 / ( SELECT COUNT(user_id) FROM Users )
public_review_platform
What are the most common compliments types received by user with uber number of fans?
the most common compliments types refer to MAX(COUNT(compliment_id)); user_fans = 'uber';
SELECT DISTINCT T3.compliment_type FROM Users AS T1 INNER JOIN Users_Compliments AS T2 ON T1.user_id = T2.user_id INNER JOIN Compliments AS T3 ON T2.compliment_id = T3.compliment_id WHERE T1.user_fans = 'Uber'
public_review_platform
What is the average year needed by a user with uber fans to become an elite user?
AVG(user_yelping_since_year) where user_fans = 'uber';
SELECT CAST(SUM(T2.year_id - T1.user_yelping_since_year) AS REAL) / COUNT(T1.user_id) FROM Users AS T1 INNER JOIN Elite AS T2 ON T1.user_id = T2.user_id WHERE T1.user_fans = 'Uber'
public_review_platform
What is the average year for a user to be upgraded to elite user?
AVG(user_yelping_since_year) where user_id from Elite;
SELECT CAST(SUM(T2.year_id - T1.user_yelping_since_year) AS REAL) / COUNT(T1.user_id) FROM Users AS T1 INNER JOIN Elite AS T2 ON T1.user_id = T2.user_id
public_review_platform
How many business are opened for more than 8 hour in Mesa and what is the percentage of the active businesses?
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;
SELECT CAST(SUM(CASE WHEN T1.active = 'true' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.business_id) AS ACT FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Mesa'
public_review_platform
How many active businesses are opened during late afternoon in the Phoenix city? List out the top 3 categories name for these businesses.
opened during late afternoon refers to Business_Hours where opening_time ≥ '5PM'; active businesses refer to business_id where active = 'true';
SELECT DISTINCT T4.category_name FROM Business_Hours AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id INNER JOIN Business_Categories AS T3 ON T2.business_id = T3.business_id INNER JOIN Categories AS T4 ON T3.category_id = T4.category_id WHERE T2.active = 'true' AND T2.city = 'Phoenix' AND T1.opening_time >= '5PM' LIMIT 3
public_review_platform
Which user has done the most review on a business attributed to delivery?
the most reviews refer to MAX(business_id) where attribute_name = 'Delivery';
SELECT T3.user_id FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Reviews AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name = 'Delivery' GROUP BY T3.user_id ORDER BY COUNT(T2.business_id) DESC LIMIT 1
public_review_platform
How many business ids have opening hours from 8AM to 6PM?
opening hours from 8AM to 6PM refer to Business_Hours where opening_time = '8AM' and closing_time = '6PM';
SELECT DISTINCT business_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM'
public_review_platform
Provide business ids with opening hours 10AM on Saturday.
opening hours 10AM on Saturday refer to Business_Hours where opening_time = '10AM' and day_id = 6;
SELECT DISTINCT business_id FROM Business_Hours WHERE day_id = 6 AND opening_time = '10AM'
public_review_platform
Indicate the business id and days which are opened from 8AM to 6PM.
opened from 8AM to 6PM refers to Business_Hours where opening_time = '8AM' and closing_time = '6PM'; days refer to day_id;
SELECT DISTINCT day_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM'
public_review_platform
How many businesses id are rated more than 4?
rated more than 4 refers to stars > 4;
SELECT COUNT(business_id) FROM Business WHERE stars > 4
public_review_platform
What are the categories of businesses that have opening time on Sunday?
categories of businesses refer to category_name; Sunday refers to day_of_week where day_id = 1;
SELECT DISTINCT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T2.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T4.day_of_week = 'Sunday' AND T3.opening_time <> ''
public_review_platform
Please indicate the opening day of businesses whose category is pets.
category is pets refers to category_name = 'Pets'; opening day refers to day_id from Business_Hours and opening_time;
SELECT DISTINCT T4.day_of_week FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T1.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T2.category_name = 'Pets'
public_review_platform
Please indicate the closing hours and business days of the businesses with the category named Doctors.
closing hours refer to closing_time; business days refer to day_id from Business_Hours;
SELECT DISTINCT T3.opening_time, T3.day_id FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T1.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T2.category_name = 'Doctors'
public_review_platform
Among the working days from Monday to Saturday, which businesses with the category names work the most days?
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));
SELECT T2.category_name FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T1.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id GROUP BY T2.category_name ORDER BY COUNT(T3.day_id) DESC LIMIT 1
public_review_platform
Please indicate the business id have the closing time with the category of Arts & Entertainment on Sunday.
Sunday refers to day_of_week = 'Sunday' where day_id = 1; category of Arts & Entertainment refers to category_name = 'Arts & Entertainment';
SELECT T1.business_id, T3.closing_time FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T1.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T2.category_name = 'Arts & Entertainment' AND T4.day_of_week = 'Sunday'
public_review_platform
In businesses with a category of "DJs", how many businesses are rated less than 5?
category of "DJs" refers to category_name = 'DJs'; rated less than 5 refers to stars < 5; businesses refer to business_id;
SELECT COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Business_Categories AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T2.category_id = T3.category_id WHERE T3.category_name = 'DJs' AND T1.stars < 5
public_review_platform
List active business ids with opening times of 7AM and closing times of 8PM.
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';
SELECT DISTINCT T4.business_id FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T2.business_id = T3.business_id INNER JOIN Business AS T4 ON T3.business_id = T4.business_id WHERE T4.active = 'true' AND T3.opening_time = '7AM' AND T3.closing_time = '8PM'
public_review_platform
How many businesses with the category named Stadiums & Arenas are rated highest?
rated highest refers to MAX(stars); category_name = 'Stadiums & Arenas';
SELECT COUNT(T1.business_id) FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id WHERE T2.category_name = 'Stadiums & Arenas' AND T3.stars = ( SELECT MAX(stars) FROM Business )
public_review_platform
How many category id have low review count and rating more than 2?
rating more than 2 refers to stars > 2;
SELECT COUNT(DISTINCT T1.category_id) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T3.review_count = 'Low' AND T3.stars > 2
public_review_platform
Among the active businesses in Arizona, how many businesses work after 12PM?
active businesses in Arizona refer to business_id where state = 'Arizona' and active = 'true'; work after 12PM refer to opening_time > '12PM';
SELECT COUNT(DISTINCT T2.business_id) FROM Business_Hours AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id INNER JOIN Business_Categories AS T3 ON T2.business_id = T3.business_id INNER JOIN Categories AS T4 ON T3.category_id = T4.category_id WHERE T2.active = 'true' AND T2.state = 'AZ' AND T1.opening_time > '12PM'
public_review_platform
Please provide the name of businesses with user id "16328".
name of business refers to category_name;
SELECT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Tips AS T3 ON T2.business_id = T3.business_id WHERE T3.user_id = 16328
public_review_platform
How many businesses have the category named food? List those businesses and find the percentage of businesses with less than 2 stars.
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;
SELECT T3.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 AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id WHERE T2.category_name = 'Food'
public_review_platform
Calculate the percentage of businesses with the category name food that are open from 7AM to 8PM in the businesses with the same time.
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;
SELECT CAST(SUM(CASE WHEN T3.category_name = 'Food' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T3.category_name) FROM Business_Categories AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T1.category_id = T3.category_id
public_review_platform
Write down the number of running business with each review count in Cave Creek city.
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';
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'
public_review_platform
Calculate the yearly average user who started using Yelp from the year of 2005 to 2014.
avg(user_id) where user_yelping_since_year BETWEEN '2005' AND '2014';
SELECT AVG(user_id) FROM Users WHERE user_yelping_since_year >= 2005 AND user_yelping_since_year <= 2015
public_review_platform
What is the active and inactive ratio of the business with the review count of low.
DIVIDE(COUNT(business_id where review_count = 'Low' and active = 'true'), COUNT(business_id where review_count = 'Low' and active = 'false'));
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'
public_review_platform
List any five of user ID who became elite user in 2006.
year_id = '2006';
SELECT user_id FROM Elite WHERE year_id = 2006 LIMIT 5
public_review_platform
Write down the any five of ID and name of category that starts with alphabet "P".
category that starts with alphabet "P" refers to category_name like 'P%';
SELECT category_id, category_name FROM Categories WHERE category_name LIKE 'P%' LIMIT 5
public_review_platform
Provide the list of user ID along with review star of which has the review length of medium with business ID of 35.
;
SELECT user_id, review_stars FROM Reviews WHERE business_id = 15 AND review_length = 'Medium'
public_review_platform
List down the business ID and attribute value of the attribute name of "payment_types_visa".
SELECT T2.business_id, T2.attribute_value FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.attribute_name = 'payment_types_visa'
public_review_platform
Describe ID and active status of the business under category of "Diagnostic Imaging".
ID refers to business_id; category of "Diagnostic Imaging" refers to category_name = 'Diagnostic Imaging';
SELECT T2.business_id, T3.active FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Diagnostic Imaging'