problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: What is the category of businesses with highest star rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT 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 ORDER BY T1.stars DESC LIMIT 1 |
Write SQL query to solve given problem: What is the category of the business with medium review length and highest review stars within business ID from 6 t0 9?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T4.category_name FROM Reviews 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 T1.review_length LIKE 'Medium' AND T2.business_id BETWEEN 6 AND 9 ORDER BY T1.review_stars DESC LIMIT 1 |
Write SQL query to solve given problem: Count the active businesses that has an attribute of caters with low review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(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 T3.attribute_name LIKE 'Caters' AND T1.review_count LIKE 'Low' AND T1.active LIKE 'TRUE' |
Write SQL query to solve given problem: What is the closing and opening time of businesses located at Tempe with highest star rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.closing_time, T2.opening_time FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city LIKE 'Tempe' ORDER BY T1.stars DESC LIMIT 1 |
Write SQL query to solve given problem: Among the active businesses located at Chandler, AZ, list the category and atrributes of business with a medium review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.category_name, T5.attribute_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id INNER JOIN Business_Attributes AS T4 ON T1.business_id = T4.business_id INNER JOIN Attributes AS T5 ON T4.attribute_id = T5.attribute_id WHERE T1.active LIKE 'TRUE' AND T1.state LIKE 'AZ' AND T1.city LIKE 'Chandler' AND T1.review_count LIKE 'Medium' |
Write SQL query to solve given problem: List the categories of active businesses in Surprise, AZ.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.category_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.active LIKE 'TRUE' AND T1.state LIKE 'AZ' AND T1.city LIKE 'Surprise' GROUP BY T3.category_name |
Write SQL query to solve given problem: Find the location of businesses that have business hours from 8 am to 9 pm every Friday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city 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 T2.closing_time LIKE '9PM' AND T2.opening_time LIKE '8AM' AND T3.day_of_week LIKE 'Friday' GROUP BY T1.city |
Write SQL query to solve given problem: What is the attribute value of an active business with a high review count and 3 stars which is located at Mesa, AZ?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.attribute_value 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.state LIKE 'AZ' AND T1.review_count LIKE 'High' AND T1.active LIKE 'TRUE' AND T1.city LIKE 'Mesa' AND T1.stars = 3 |
Write SQL query to solve given problem: What is the opening time of the active businesses in Chandler that has a medium review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT T2.opening_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 LIKE 'Chandler' AND T1.active LIKE 'TRUE' AND T1.review_count LIKE 'Medium' |
Write SQL query to solve given problem: Among the businesses with a category of Accessories, what is the percentage of the business with less than 4 stars?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN T1.stars < 4 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.stars) AS "percentage" FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T3.category_name LIKE 'Accessories' |
Write SQL query to solve given problem: List the closing time and day of week of active businesses in Tempe with stars greater than the 70% of average age of star rating.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.closing_time, 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 LIKE 'Tempe' AND T1.active LIKE 'TRUE' AND T1.stars > 0.7 * ( SELECT AVG(T1.stars) 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 LIKE 'Tempe' AND T1.active LIKE 'TRUE' ) |
Write SQL query to solve given problem: How many active businesses are located at Phoenix, Arizona?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE city LIKE 'Phoenix' AND active LIKE 'True' |
Write SQL query to solve given problem: How many businesses are with high review count?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE review_count LIKE 'High' |
Write SQL query to solve given problem: How many businesses ID sell beer and wine?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business_Attributes WHERE attribute_id = 1 AND attribute_value = 'beer_and_wine' |
Write SQL query to solve given problem: How many attributes ID owned by business ID 2?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(attribute_id) FROM Business_Attributes WHERE business_id = 2 |
Write SQL query to solve given problem: How many users received high compliment type in photo?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T1.user_id) FROM Users_Compliments AS T1 INNER JOIN Compliments AS T2 ON T1.compliment_id = T2.compliment_id WHERE T1.number_of_compliments LIKE 'High' AND T2.compliment_id = 1 |
Write SQL query to solve given problem: How many businesses in Phoenix, Arizona is attributed to waiter service?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(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 LIKE 'Phoenix' AND T3.attribute_name LIKE 'waiter_service' AND T2.attribute_id = 2 |
Write SQL query to solve given problem: Find out which business is opened for 24/7 and list out what is the business attribute.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T5.attribute_name FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id INNER JOIN Business_Attributes AS T4 ON T3.business_id = T4.business_id INNER JOIN Attributes AS T5 ON T4.attribute_id = T5.attribute_id WHERE T2.day_id LIKE '1' AND '2' AND '3' AND '4' AND '5' AND '6' AND '7' AND T1.opening_time = T1.closing_time GROUP BY T5.attribute_name |
Write SQL query to solve given problem: Which business in fashion category has the most review?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.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 Reviews AS T4 ON T3.business_id = T4.business_id WHERE T1.category_name LIKE 'Fashion' AND T1.category_id = 7 GROUP BY T3.business_id ORDER BY COUNT(T4.user_id) DESC LIMIT 1 |
Write SQL query to solve given problem: List out which business category that are most likely to have average good review in Arizona?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT T4.category_name FROM Reviews 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.state LIKE 'AZ' AND T1.review_stars >= 3 |
Write SQL query to solve given problem: What is the ratio of having the best to worse elite user in 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN T1.user_average_stars = 1 THEN 1 ELSE 0 END) AS REAL) / COUNT(T2.user_id) , SUM(CASE WHEN T1.user_average_stars = 5 THEN 1 ELSE 0 END) * 1.0 / COUNT(T2.user_id) FROM Users AS T1 INNER JOIN Elite AS T2 ON T1.user_id = T2.user_id WHERE T2.year_id = 2013 |
Write SQL query to solve given problem: Calculate the increment percentage of elite user for each year since year 2005.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(COUNT(CASE WHEN year_id < 2014 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(CASE WHEN year_id = 2005 THEN 1.0 ELSE NULL END) AS increment FROM Elite |
Write SQL query to solve given problem: How many business have been reviewed by user ID 3 and how long have this user been with Yelp?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T1.business_id) , strftime('%Y', 'now') - T2.user_yelping_since_year FROM Reviews AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.user_id = 3 |
Write SQL query to solve given problem: What is the yearly average review done by user ID 3?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(review_stars) / (strftime('%Y', 'now') - T1.user_yelping_since_year) FROM Users AS T1 INNER JOIN Reviews AS T2 ON T1.user_id = T2.user_id WHERE T1.user_id = 3 |
Write SQL query to solve given problem: What is the average number of review received by each business given that the user is an elite?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(COUNT(T1.user_id) AS REAL) / COUNT(DISTINCT T1.business_id) FROM Reviews AS T1 INNER JOIN Elite AS T2 ON T1.user_id = T2.user_id |
Write SQL query to solve given problem: List out the user who is an elite user for consecutively 5 years or more and what is the user average star? How many likes does this user gets?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.user_average_stars, COUNT(T3.likes) FROM Elite AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id INNER JOIN Tips AS T3 ON T3.user_id = T2.user_id GROUP BY T1.user_id HAVING COUNT(T1.user_id) > 5 |
Write SQL query to solve given problem: Find out which hotel and travel business having the most review? Calculate the standard deviation of the review star for this business.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.category_id FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Reviews AS T3 ON T3.business_id = T1.business_id WHERE T2.category_name = 'Hotels & Travel' GROUP BY T2.category_id ORDER BY COUNT(T2.category_id) DESC LIMIT 1 |
Write SQL query to solve given problem: What is the correlation between the review starts and business stars?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(T2.review_stars) AS REAL) / COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id |
Write SQL query to solve given problem: How many of the businesses are active?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE active LIKE 'True' |
Write SQL query to solve given problem: List down the business ID with a low review count in Phoenix.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id FROM Business WHERE city LIKE 'Phoenix' AND review_count LIKE 'Low' |
Write SQL query to solve given problem: What is the total number of active business in AZ with a high review count?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND review_count LIKE 'High' AND active LIKE 'True' |
Write SQL query to solve given problem: List down the business ID with a star range from 3 to 4, located at Tempe.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id FROM Business WHERE city LIKE 'Tempe' AND stars BETWEEN 3 AND 4 |
Write SQL query to solve given problem: In users yelping since 2010 to 2012, how many of them has an low fans?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(user_id) FROM Users WHERE user_yelping_since_year BETWEEN 2010 AND 2012 AND user_fans LIKE 'Low' |
Write SQL query to solve given problem: What is the review length of user 60776 to business with business ID 1?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT review_length FROM Reviews WHERE user_id = 60776 AND business_id = 1 |
Write SQL query to solve given problem: Among the businesses in Scottsdale, list the attribute of the business with a high review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.attribute_name 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.review_count LIKE 'High' AND T1.city LIKE 'Scottsdale' GROUP BY T3.attribute_name |
Write SQL query to solve given problem: In businesses with a category of automotive, how many of them has an star rating below 3?. 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 ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T3.category_name LIKE 'Automotive' AND T1.stars < 3 |
Write SQL query to solve given problem: List the active business ID and its stars of the businesses fall under the category of Pets.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.business_id, T1.stars FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.active LIKE 'TRUE' AND T3.category_name LIKE 'Pets' |
Write SQL query to solve given problem: What is the attribute of the business with highest star rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.attribute_name 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 ORDER BY T1.stars DESC LIMIT 1 |
Write SQL query to solve given problem: What is the category of the business with short review length and highest review stars within business ID from 5 t0 10?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T4.category_name FROM Reviews 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 T1.review_length LIKE 'Short' AND T2.business_id BETWEEN 5 AND 10 ORDER BY T1.review_stars DESC LIMIT 1 |
Write SQL query to solve given problem: Count the active businesses that has an attribute of Wi-Fi with medium review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(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 T3.attribute_name LIKE 'Wi-Fi' AND T1.active LIKE 'TRUE' AND T1.review_count LIKE 'Medium' |
Write SQL query to solve given problem: What is the closing and opening time of businesses located at Gilbert with highest star rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.closing_time, T2.opening_time FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city LIKE 'Gilbert' ORDER BY T1.stars DESC LIMIT 1 |
Write SQL query to solve given problem: Among the active businesses located at Mesa, AZ, list the category and attributes of business with a low review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT 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.review_count = 'Low' AND T1.city = 'Mesa' AND T1.active = 'true' AND T1.state = 'AZ' |
Write SQL query to solve given problem: List the categories of inactive businesses in AZ.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.category_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.active LIKE 'FALSE' AND T1.state LIKE 'AZ' |
Write SQL query to solve given problem: Find the location of businesses that has business hours from 9 am to 9 pm every Saturday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city 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 T2.closing_time LIKE '9PM' AND T2.opening_time LIKE '9AM' AND T3.day_of_week LIKE 'Saturday' GROUP BY T1.city |
Write SQL query to solve given problem: What is the attribute value of an inactive business with a medium review count and 3.5 stars which is located at Phoenix, AZ?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.attribute_value 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.state LIKE 'AZ' AND T1.review_count LIKE 'Medium' AND T1.active LIKE 'FALSE' AND T1.city LIKE 'Phoenix' AND T1.stars = 3.5 |
Write SQL query to solve given problem: What is the opening time of the active businesses in Surprise that has a low review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.opening_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 LIKE 'Surprise' AND T1.active LIKE 'TRUE' AND T1.review_count LIKE 'Low' GROUP BY T2.opening_time |
Write SQL query to solve given problem: Among the businesses with a category of Local Services, what is the percentage of the business with less than 3 stars?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN T1.stars < 3 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.stars) AS "percentage" FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T3.category_name LIKE 'Local Services' |
Write SQL query to solve given problem: List the closing time and day of week of active businesses in Scottsdale with stars greater than the 60% of average age of star rating.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.closing_time, 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 LIKE 'Scottsdale' AND T1.active LIKE 'TRUE' AND T1.stars > 0.6 * ( SELECT AVG(T1.stars) 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 LIKE 'Scottsdale' AND T1.active LIKE 'TRUE' ) |
Write SQL query to solve given problem: How many users have no followers in 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(user_id) FROM Users WHERE user_yelping_since_year = 2004 AND user_fans LIKE 'None' |
Write SQL query to solve given problem: List at least 5 users that has received less than 5 low compliments from
other users.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT user_id FROM Users_Compliments WHERE number_of_compliments LIKE 'Low' GROUP BY user_id ORDER BY COUNT(number_of_compliments) > 5 LIMIT 5 |
Write SQL query to solve given problem: List at least 10 users ID that has 4 as an average ratings of all reviews sent.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(user_id) FROM Users WHERE user_average_stars = 4 LIMIT 10 |
Write SQL query to solve given problem: What city does the business have a business hour from 10 am to 12 pm on Sunday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city 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 T2.opening_time LIKE '10AM' AND T2.closing_time LIKE '12PM' AND T3.day_of_week LIKE 'Sunday' |
Write SQL query to solve given problem: How many businesses are opened for 24 hours?. 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 T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Open 24 Hours' |
Write SQL query to solve given problem: List at least 5 active business ID that are good for groups and dancing.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T2.business_id 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 T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Good for Dancing' AND T1.attribute_name LIKE 'Good for Groups' LIMIT 5 |
Write SQL query to solve given problem: Among the active businesses in Ahwatukee, which of them are still open in Sunday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.business_id 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 LIKE 'Ahwatukee' AND T1.active LIKE 'TRUE' AND T3.day_of_week LIKE 'Sunday' |
Write SQL query to solve given problem: List the categories of all active businesses that were not in Arizona.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.category_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.active LIKE 'TRUE' AND T1.state NOT LIKE 'AZ' |
Write SQL query to solve given problem: List the category of the business with high review count but received 2 stars.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.category_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.stars = 2 AND T1.review_count LIKE 'High' |
Write SQL query to solve given problem: How many businesses have a romantic ambiance?. 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 T2.attribute_value = 'true' AND T1.attribute_name = 'ambience_romantic' |
Write SQL query to solve given problem: List the city of the business where they open from 1 pm to 6 pm on Saturday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city 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 T2.closing_time LIKE '6PM' AND T2.opening_time LIKE '1PM' AND T3.day_of_week LIKE 'Saturday' |
Write SQL query to solve given problem: What is the total number of fans or followers who received most likes of their comments in the business?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T1.user_fans) FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id ORDER BY COUNT(T2.likes) DESC LIMIT 1 |
Write SQL query to solve given problem: What city does the business came from where they received a high volume of check-ins from 12 am to 1 am on Saturday.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city 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 T2.closing_time = '1AM' AND T2.opening_time = '12AM' AND T3.day_of_week = 'Saturday' |
Write SQL query to solve given problem: How many businesses have shopping centers and received high review count?. 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 INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Shopping Centers' AND T3.review_count = 'High' |
Write SQL query to solve given problem: How many businesses accept insurance?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T1.business_id) FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_name = 'Accepts Insurance' AND T1.attribute_value = 'true' |
Write SQL query to solve given problem: Calculate the average review star from users in businesses located in South Carolina and California state.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT 1.0 * (( SELECT SUM(T1.stars) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.state = 'SC' ) + ( SELECT SUM(T1.stars) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.state = 'CA' )) / ( SELECT SUM(T1.stars) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id ) AS reslut |
Write SQL query to solve given problem: Compare and get the difference of the number of businesses that are open in Monday and Tuesday from 10 am to 9 pm.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT SUM(CASE WHEN T3.day_of_week = 'Monday' THEN 1 ELSE 0 END) - SUM(CASE WHEN T3.day_of_week = 'Tuesday' THEN 1 ELSE 0 END) AS DIFF 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 T2.opening_time = '10AM' AND T2.closing_time = '9PM' |
Write SQL query to solve given problem: State the ID number for the attribute named "Accepts Insurance"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT attribute_id FROM Attributes WHERE attribute_name = 'Accepts Insurance' |
Write SQL query to solve given problem: How many actively running Yelp businesses are there located in "Phoenix" city?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE active = 'true' AND city = 'Phoenix' |
Write SQL query to solve given problem: Give the number of "4" stars Yelp businesses in "Mesa" city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE stars = 4 AND city = 'Mesa' |
Write SQL query to solve given problem: Provide the number of Yelp businesses in "Gilbert" which got a" high" review count.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(business_id) FROM Business WHERE review_count = 'High' AND city = 'Gilbert' |
Write SQL query to solve given problem: Which actively running Yelp business in "Gilbert" has got the most reviews? Give the business id.. 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.active = 'true' AND T1.city = 'Gilbert' AND T1.review_count = 'Uber' |
Write SQL query to solve given problem: For the Yelp business in "Tempe" city which got "3.5" stars and review count as "Uber", how many "long" reviews did it get?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T2.review_length) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Tempe' AND T1.stars = '3.5' AND T1.review_count = 'Uber' AND T2.review_length = 'Long' |
Write SQL query to solve given problem: How is the "noise level" for the only Yelp business in “Mesa” which got a "Uber" review count?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T3.attribute_name 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 T1.review_count = 'Uber' AND T3.attribute_name = 'Noise Level' |
Write SQL query to solve given problem: Is the Yelp business No. 14033 good for supper?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.attribute_value FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_name = 'good_for_dinner' AND T1.business_id = 14033 |
Write SQL query to solve given problem: How long is the Yelp business No. 15098 opened on Monday?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT SUBSTR(T1.closing_time, 1, 2) + 12 - SUBSTR(T1.opening_time, 1, 2) AS YYSJ FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id WHERE T2.day_of_week = 'Monday' AND T1.business_id = 15098 |
Write SQL query to solve given problem: For the Yelp businesses which received a "5" star review with "uber" number of votes for funny, which one is located in "Phoenix"? Give the business ID.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT 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_stars = 5 AND T2.review_votes_funny = 'Uber' |
Write SQL query to solve given problem: Which city is the business that got a "medium" length tip with "3" likes located in?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT T1.city FROM Business AS T1 INNER JOIN Tips AS T2 ON T1.business_id = T2.business_id WHERE T2.tip_length = 'Medium' AND T2.likes = 3 |
Write SQL query to solve given problem: For the user who joined Yelp in "2010", with an average of "4.5" stars review and has got uber number of fans, how many "funny" compliments has he/she received from other users?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T2.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 WHERE T1.user_yelping_since_year = 2010 AND T1.user_average_stars = 4.5 AND T1.user_fans = 'Uber' AND T3.compliment_type = 'funny' |
Write SQL query to solve given problem: How many "cool" type compliments does user No. 41717 get?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT COUNT(T2.number_of_compliments) FROM Compliments AS T1 INNER JOIN Users_Compliments AS T2 ON T1.compliment_id = T2.compliment_id WHERE T1.compliment_type = 'cool' AND T2.user_id = 41717 |
Write SQL query to solve given problem: Does Yelp business No."11825" have a "parking lot"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Is the payment in mastercard possible for the Yelp business No."12476"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: What is the percentage for the Yelp businesses in "Pets" category of all businesses?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: How many times is the number of "Women's Clothing" Yelp businesses to "Men's Clothing"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Write down the ID, active status and city of the business which are in CA state.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id, active, city FROM Business WHERE state = 'CA' AND active = 'true' |
Write SQL query to solve given problem: Calculate the percentage of running business among all business.. 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) * 100 / COUNT(business_id) FROM Business |
Write SQL query to solve given problem: Among all attribute names, list down the ID and attribute name which start with "music".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT attribute_id, attribute_name FROM Attributes WHERE attribute_name LIKE 'music%' |
Write SQL query to solve given problem: Between 2006 and 2007, which year ID had the greater number in elite user?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT year_id FROM Elite WHERE year_id IN (2006, 2007) GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1 |
Write SQL query to solve given problem: Based on all user compliments, find the percentage of low number of compliments on all compliments ID.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT CAST(SUM(CASE WHEN number_of_compliments = 'Low' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(user_id) FROM Users_compliments |
Write SQL query to solve given problem: List down the business ID and user ID who got uber for cool votes.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT business_id, user_id FROM Reviews WHERE review_votes_cool = 'Uber' |
Write SQL query to solve given problem: Write the user ID, business ID and tips length of who started using Yelp since 2004 and had high followers.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Under the attribute name of "music_playlist", describe the attribute ID, business ID, city and inactive status.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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' |
Write SQL query to solve given problem: Calculate the percentage of business with attribute name of "Accepts Credit Cards".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Among the stopped businesses in San Tan Valley city, list down the user ID and review length of who had great experience.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Mention the user average star, elite year and the compliment type of user ID 6027 whereby number of compliments reach uber.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Under the category name of "Coffee & Tea", mention any 5 business ID , their state and city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Describe category name which had above 10% in comparing with all business and categories.. 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 GROUP BY T2.category_id HAVING COUNT(T2.business_id) > ( SELECT COUNT(T3.business_id) FROM Business_Categories AS T3 ) * 0.1 |
Write SQL query to solve given problem: For the business with great experience existed in Sun Lakes city, provide the user ID who gave review on it and user followers.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Compare the number of business between the category of "Men's Clothing" and "Women's Clothing".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: Among highest quality user of under ID 100, mention compliment type which got highest compliment number and user's followers.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | 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 |
Write SQL query to solve given problem: List all the businesses that closed at 8PM.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | public_review_platform | SELECT DISTINCT business_id FROM Business_Hours WHERE closing_time = '8PM' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.