problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: How many 2 stars rated business located in Phoenix, Arizona?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE city = 'Phoenix' AND state = 'AZ' AND stars = 2 |
Write SQL query to solve given problem: How many businesses in Tempe are rated as 'Wonderful experience?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE city = 'Phoenix' AND stars > 3 |
Write SQL query to solve given problem: List all the users with average star less than 3 stars in 2012. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT user_id FROM Users WHERE user_yelping_since_year = 2012 AND user_average_stars < 3 |
Write SQL query to solve given problem: Find the percentage of 5 stars rated business.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN stars = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(stars) FROM Business |
Write SQL query to solve given problem: Calculate difference between business that have the highest number of reviews and business that have the lowest number of reviews.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List all the tires businesses that are opened everyday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Which users become an elite in 2012?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List the business ID of shopping business that have 4 stars ratings.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many business have low check-in on Sunday at 10AM?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many businesses in Glendale are reviewed by user with the ID of 20241?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: State the locations of all Pet Services business.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many photos type compliment given from users with high cool votes?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many closed businesses that have more than 10 attributes?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 ) |
Write SQL query to solve given problem: List the business located in Mesa that have alcohol attribute.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Based on business in Phoenix, calculate the percentage of business with low funny votes.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: What is the ratio between business in shopping category and business in pets category?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many businesses are registered in the database under 'Banks & Credit Unions' category?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many active businesses from Casa Grande are registered in the database?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE active = 'true' AND city = 'Casa Grande' |
Write SQL query to solve given problem: What time does the business with ID no.12 open on Monday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many businesses that are registered in the database can be attributed to 'Good for Kids'?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Identify the most popular and appealing active business in Gilbert based on users' reviews.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id FROM Business WHERE city = 'Gilbert' AND active = 'true' AND review_count = 'High' ORDER BY stars DESC LIMIT 1 |
Write SQL query to solve given problem: Find the 5-star business in Ahwatukee, AZ and identify it's business category.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Among all closed businesses in Avondale, AZ what percent have obtained a 'wonderful experience' rating of the business.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Identify the user who has been yelping since 2004. Is he or she an Yelp Elite member?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Identify the percent of long reviews among all 5-star reviews given to businesses by the Yelp users.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many short tips were left for the business with ID no.2?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Tips WHERE business_id = 2 AND tip_length = 'Short' |
Write SQL query to solve given problem: Find the Yelp user with the average 5-star rating of all reviews who has been yelping the longest.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT user_id FROM Users WHERE user_average_stars = 5 ORDER BY user_yelping_since_year ASC LIMIT 1 |
Write SQL query to solve given problem: Identify the operating hours of businesses in Black Canyon City with review count greater than average.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.opening_time, T2.closing_time FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city = 'Black Canyon City' GROUP BY t2.business_id HAVING T1.review_count > AVG(T1.review_count) |
Write SQL query to solve given problem: Among all the users who received the high number of compliments, what percent received the 'cute' type of compliment.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Mention the number of businesses that have no any attribute.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business_Attributes WHERE attribute_value IN ('none', 'no', 'false') |
Write SQL query to solve given problem: What are the opening and closing time of business id 1 for day id 2?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT opening_time, closing_time FROM Business_Hours WHERE business_id = 1 AND day_id = 2 |
Write SQL query to solve given problem: List out city name of businesses which have medium length of review.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: What is the closing time of business id 4 on Sunday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.closing_time FROM Days AS T1 INNER JOIN Business_Hours AS T2 ON T1.day_id = T2.day_id WHERE T1.day_of_week = 'Sunday' AND T2.business_id = 4 |
Write SQL query to solve given problem: Among the businesses which have short length of review, which one located in Phoenix?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the users whose fan is medium, how many users received high compliments from other users.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the users who received low compliments from other users, which users joined Yelp in 2012?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the businesses without attribute, how many businesses located in Gilbert?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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') |
Write SQL query to solve given problem: Among the businesses with average rating, how many business has attribute of full_bar.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: List out the state of businesses which have opening time at 1AM.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: List out the category name of business id 5.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List out the user id that has compliment type of photos.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Calculate the percentage of medium tip length in the list. List out the time when users of medium tip length join Yelp.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN T1.tip_length = 'Medium' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.tip_length), T2.user_yelping_since_year FROM Tips AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id |
Write SQL query to solve given problem: Calculate the percentage of businesses who located in Mesa. What is attribute value of these businesses.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(COUNT(T1.city) AS REAL) * 100 / ( SELECT COUNT(business_id) FROM Business ), T2.attribute_value FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Mesa' |
Write SQL query to solve given problem: State the state of businesses which have closing time at 12AM.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the businesses which have attribute of beer_and_wine, how many business located in Peoria?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the users who received high compliments from other users, which users joined Yelp earliest?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 ) |
Write SQL query to solve given problem: Which business ID has the most reviews?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id FROM Reviews GROUP BY business_id ORDER BY COUNT(user_id) DESC LIMIT 1 |
Write SQL query to solve given problem: Which year has the most elite users?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT year_id FROM Elite GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1 |
Write SQL query to solve given problem: How many 5 star businesses have uber review votes for funny?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Reviews WHERE review_stars = 5 AND review_votes_funny = 'Uber' |
Write SQL query to solve given problem: How many users have uber review votes for funny from the fans?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(DISTINCT user_id) FROM Reviews WHERE review_votes_funny = 'Uber' |
Write SQL query to solve given problem: Which business ID have the shortest business operating hours?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id FROM Business_Hours ORDER BY closing_time - opening_time LIMIT 1 |
Write SQL query to solve given problem: Find out which business ID are opened all the time.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT business_id FROM Business_Hours WHERE day_id >= 1 AND day_id < 8 AND opening_time = closing_time |
Write SQL query to solve given problem: Does the length of the tip influence the number of likes for hotel and travel business category?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many users manage to get uber votes for all of the review category? Find out what are the user average star.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T2.user_id) AS USER_IDS, T2.user_average_stars FROM Reviews AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.review_votes_funny = 'Uber' AND T1.review_votes_useful = 'Uber' AND T1.review_votes_cool = 'Uber' |
Write SQL query to solve given problem: What is the ratio of good to bad business star for a businesses that are opened all the time?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List out 10 business ID that are being reviewed the most by users and list out what are top 3 business categories.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.business_id, T3.category_name FROM Reviews 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 GROUP BY T2.business_id ORDER BY COUNT(T1.user_id) DESC LIMIT 10 |
Write SQL query to solve given problem: How many businesses in Arizona having an average review less than 3 stars?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 ) |
Write SQL query to solve given problem: What is the percentage of user not becoming an elite user?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST((( SELECT COUNT(user_id) FROM Users ) - ( SELECT COUNT(DISTINCT user_id) FROM Elite )) AS REAL) * 100 / ( SELECT COUNT(user_id) FROM Users ) |
Write SQL query to solve given problem: What are the most common compliments types received by user with uber number of fans?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: What is the average year needed by a user with uber fans to become an elite user?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: What is the average year for a user to be upgraded to elite user?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many business are opened for more than 8 hour in Mesa and what is the percentage of the active businesses?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many active businesses are opened during late afternoon in the Phoenix city? List out the top 3 categories name for these businesses.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Which user has done the most review on a business attributed to delivery?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: What is the average number of reviews written for active businesses that operate not more than 30 hours a week?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT AVG(T3.user_id) FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Reviews AS T3 ON T1.business_id = T3.business_id WHERE T1.active = 'true' GROUP BY T2.closing_time - T2.opening_time HAVING SUM(T2.closing_time - T2.opening_time) < 30 |
Write SQL query to solve given problem: How many business ids have opening hours from 8AM to 6PM?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT business_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM' |
Write SQL query to solve given problem: Provide business ids with opening hours 10AM on Saturday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT business_id FROM Business_Hours WHERE day_id = 6 AND opening_time = '10AM' |
Write SQL query to solve given problem: Indicate the business id and days which are opened from 8AM to 6PM.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT day_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM' |
Write SQL query to solve given problem: How many businesses id are rated more than 4?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE stars > 4 |
Write SQL query to solve given problem: What are the categories of businesses that have opening time on Sunday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 <> '' |
Write SQL query to solve given problem: Please indicate the opening day of businesses whose category is pets.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Please indicate the closing hours and business days of the businesses with the category named Doctors.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Among the working days from Monday to Saturday, which businesses with the category names work the most days?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Please indicate the business id have the closing time with the category of Arts & Entertainment on Sunday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: In businesses with a category of "DJs", how many businesses are rated less than 5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List active business ids with opening times of 7AM and closing times of 8PM.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: How many businesses with the category named Stadiums & Arenas are rated highest?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 ) |
Write SQL query to solve given problem: How many category id have low review count and rating more than 2?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Which businesses with the category name Accessories have opening hours before 7AM?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.business_id FROM Business_Hours 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 = 'Accessories' AND SUBSTR(T1.opening_time, -4, 2) * 1 < 7 AND T1.opening_time LIKE '%AM' |
Write SQL query to solve given problem: Among the active businesses in Arizona, how many businesses work after 12PM?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Please provide the name of businesses with user id "16328".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many businesses have the category named food? List those businesses and find the percentage of businesses with less than 2 stars.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Calculate the percentage of businesses with the category name food that are open from 7AM to 8PM in the businesses with the same time.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Write down the number of running business with each review count in Cave Creek city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Calculate the yearly average user who started using Yelp from the year of 2005 to 2014.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT AVG(user_id) FROM Users WHERE user_yelping_since_year >= 2005 AND user_yelping_since_year <= 2015 |
Write SQL query to solve given problem: What is the active and inactive ratio of the business with the review count of low.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: List any five of user ID who became elite user in 2006.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT user_id FROM Elite WHERE year_id = 2006 LIMIT 5 |
Write SQL query to solve given problem: Write down the any five of ID and name of category that starts with alphabet "P".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT category_id, category_name FROM Categories WHERE category_name LIKE 'P%' LIMIT 5 |
Write SQL query to solve given problem: Provide the list of user ID along with review star of which has the review length of medium with business ID of 35.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT user_id, review_stars FROM Reviews WHERE business_id = 15 AND review_length = 'Medium' |
Write SQL query to solve given problem: List down the business ID and attribute value of the attribute name of "payment_types_visa".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Describe ID and active status of the business under category of "Diagnostic Imaging".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Mention the user ID and their year of joining Yelp who had great experience on business ID 143.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.user_id, T2.user_yelping_since_year FROM Reviews AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.business_id = 143 AND T1.review_stars = 5 |
Write SQL query to solve given problem: Among the user ID with number in compliment of uber on profile, list any 5 user ID and the year when they join Yelp.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.user_id, T3.user_yelping_since_year 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 T1.compliment_type = 'profile' AND T2.number_of_compliments = 'Uber' LIMIT 5 |
Write SQL query to solve given problem: List the user ID, business ID with review length of the business which received the most likes in tips.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.user_id, T1.business_id, T2.review_length FROM Tips AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id ORDER BY T1.likes DESC LIMIT 1 |
Write SQL query to solve given problem: Among the elite users of 10 consecutive year from 2005 to 2014, list down the user ID and their number of compliment on photos.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.user_id, T2.number_of_compliments FROM Compliments AS T1 INNER JOIN Users_Compliments AS T2 ON T1.compliment_id = T2.compliment_id INNER JOIN Elite AS T3 ON T2.user_id = T3.user_id WHERE T3.year_id BETWEEN 2005 AND 2014 AND T1.compliment_type = 'photos' |
Write SQL query to solve given problem: Calculate the percentage of business which opened on Sunday from 9AM to 9PM based on the number of business opened on Sunday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN T2.opening_time = '9AM' AND T2.closing_time = '9PM' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.day_id) FROM Days AS T1 INNER JOIN Business_Hours AS T2 ON T1.day_id = T2.day_id WHERE T1.day_of_week = 'Sunday' |
Write SQL query to solve given problem: Write down the ID and opening day of a week for the business which are running in Black Canyon City.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.business_id, T3.day_of_week FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city = 'Black Canyon City' AND T1.active = 'true' |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.user_id, T2.review_length FROM Users AS T1 INNER JOIN Reviews AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2004 AND T1.user_average_stars = 5 |
Write SQL query to solve given problem: Which business ID received the review of 4 star and above by 65% of user? Describe their active status and city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT T2.business_id, T2.city FROM Reviews AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.review_stars >= 4 AND ( SELECT CAST(( SELECT COUNT(DISTINCT T1.user_id) FROM Reviews AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.review_stars >= 4 ) AS REAL) * 100 / ( SELECT COUNT(user_id) FROM Users ) > 65 ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.