input
stringlengths
122
2.7k
output
stringlengths
24
805
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_co...
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';
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ ...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Please write me a SQL statement that answers the following question: What is the ratio between business in shopping category and business in pe...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Please write me a SQL statement that answers the following question: How many businesses are registered in the database under 'Banks & Credit U...
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';
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: How many active businesses from Casa Grande are registered in the database? [/INST] [/I...
SELECT COUNT(business_id) FROM Business WHERE active = 'true' AND city = 'Casa Grande';
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: What time does the business with ID no.12 open on Mon...
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';
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Please write me a SQL statement that answers the following question: How many businesses that are registered in the...
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';
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: Identify the most popular and appealing active business in Gilbert based on users' revi...
SELECT business_id FROM Business WHERE city = 'Gilbert' AND active = 'true' AND review_count = 'High' ORDER BY stars DESC LIMIT 1;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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;
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: Among all closed businesses in Avondale, AZ what percent have obtained a 'wonderful exp...
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';
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please wr...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Please write me a SQL statement that answers the following question: Identify the percent of long r...
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;
[INST] Here is a database schema: Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please write me a SQL statement that answers the followin...
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;
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Please write me a SQL statement that answers the following question: How many short tips were left for the business with ID no.2? [/INST] [/INST]
SELECT COUNT(business_id) FROM Tips WHERE business_id = 2 AND tip_length = 'Short';
[INST] Here is a database schema: Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please write me a SQL statement that answers the followin...
SELECT user_id FROM Users WHERE user_average_stars = 5 ORDER BY user_yelping_since_year ASC LIMIT 1;
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ T...
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);
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Please write me a SQL statement that answers the following question: Among all the users who received the high ...
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';
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Please write me a SQL statement that answers the following question: Mention the number of businesses that have no any attribute. [/INST] [/INST]
SELECT COUNT(business_id) FROM Business_Attributes WHERE attribute_value IN ('none', 'no', 'false');
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: What are the opening and closing time of business id 1 for day id 2? [/INST] [/INST]
SELECT opening_time, closing_time FROM Business_Hours WHERE business_id = 1 AND day_id = 2;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ ...
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';
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: What is the closing time of business id 4 on Sunday? ...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ ...
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';
[INST] Here is a database schema: Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_re...
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';
[INST] Here is a database schema: Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_re...
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';
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following q...
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');
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following q...
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';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the fol...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Please write me a SQL statement that answers the following question: List out the category name of business id 5. [/INST] [/INST]
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;
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Please write me a SQL statement that answers the following question: List out the user id that has compliment t...
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';
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_cou...
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;
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following q...
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';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the fol...
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';
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following q...
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';
[INST] Here is a database schema: Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_re...
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 );
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Please write me a SQL statement that answers the following question: Which business ID has the most...
SELECT business_id FROM Reviews GROUP BY business_id ORDER BY COUNT(user_id) DESC LIMIT 1;
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Please write me a SQL statement that answers the following question: Which year has the most elite users? [/INST] [/INST]
SELECT year_id FROM Elite GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Please write me a SQL statement that answers the following question: How many 5 star businesses hav...
SELECT COUNT(business_id) FROM Reviews WHERE review_stars = 5 AND review_votes_funny = 'Uber';
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Please write me a SQL statement that answers the following question: How many users have uber revie...
SELECT COUNT(DISTINCT user_id) FROM Reviews WHERE review_votes_funny = 'Uber';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: Which business ID have the shortest business operating hours? [/INST] [/INST]
SELECT business_id FROM Business_Hours ORDER BY closing_time - opening_time LIMIT 1;
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: Find out which business ID are opened all the time. [/INST] [/INST]
SELECT DISTINCT business_id FROM Business_Hours WHERE day_id >= 1 AND day_id < 8 AND opening_time = closing_time;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Please write me a SQL statement that answers the follo...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEX...
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';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the fol...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_v...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ ...
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 );
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please wr...
SELECT CAST((( SELECT COUNT(user_id) FROM Users ) - ( SELECT COUNT(DISTINCT user_id) FROM Elite )) AS REAL) * 100 / ( SELECT COUNT(user_id) FROM Users );
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_vot...
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';
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please wr...
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';
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please wr...
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;
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the fol...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] prima...
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_t...
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_vo...
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;
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEX...
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;
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: How many business ids have opening hours from 8AM to 6PM? [/INST] [/INST]
SELECT DISTINCT business_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: Provide business ids with opening hours 10AM on Saturday. [/INST] [/INST]
SELECT DISTINCT business_id FROM Business_Hours WHERE day_id = 6 AND opening_time = '10AM';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: Indicate the business id and days which are opened from 8AM to 6PM. [/INST] [/INST]
SELECT DISTINCT day_id FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM';
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: How many businesses id are rated more than 4? [/INST] [/INST]
SELECT COUNT(business_id) FROM Business WHERE stars > 4;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] clo...
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 <> '';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] clo...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] clo...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] clo...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] clo...
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 = 'Sun...
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] prima...
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...
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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 );
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that an...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] prima...
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_...
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Please write me a SQL statement that answers the follo...
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;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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...
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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;
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: Write down the number of running business with each review count in Cave Creek city. [/...
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';
[INST] Here is a database schema: Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_count [ TEXT ] user_fans [ TEXT ] Please write me a SQL statement that answers the followin...
SELECT AVG(user_id) FROM Users WHERE user_yelping_since_year >= 2005 AND user_yelping_since_year <= 2015;
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: What is the active and inactive ratio of the business with the review count of low. [/I...
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';
[INST] Here is a database schema: Elite : user_id [ INTEGER ] year_id [ INTEGER ] Please write me a SQL statement that answers the following question: List any five of user ID who became elite user in 2006. [/INST] [/INST]
SELECT user_id FROM Elite WHERE year_id = 2006 LIMIT 5;
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Please write me a SQL statement that answers the following question: Write down the any five of ID and name of category that starts with alphabet "P". [/INST] [/INST]
SELECT category_id, category_name FROM Categories WHERE category_name LIKE 'P%' LIMIT 5;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Please write me a SQL statement that answers the following question: Provide the list of user ID al...
SELECT user_id, review_stars FROM Reviews WHERE business_id = 15 AND review_length = 'Medium';
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Please write me a SQL statement that answers the following question: List down the business ID and attribute value ...
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';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
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';
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEX...
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;
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_vot...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Please wri...
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;
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Elite : user_id [ INTEGER ] year_id [ INTEGER ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Please write me a SQL statement that answers the following ques...
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';
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of business which opened on ...
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';
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ T...
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';
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEX...
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;
[INST] Here is a database schema: Reviews : business_id [ INTEGER ] user_id [ INTEGER ] review_stars [ INTEGER ] review_votes_funny [ TEXT ] review_votes_useful [ TEXT ] review_votes_cool [ TEXT ] review_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ ...
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) *...
[INST] Here is a database schema: Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the difference between running business in Glendale City and Mesa City. [/INS...
SELECT SUM(CASE WHEN city = 'Glendale' THEN 1 ELSE 0 END) - SUM(CASE WHEN city = 'Mesa' THEN 1 ELSE 0 END) AS diff FROM Business WHERE active = 'true';
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_cou...
SELECT SUM(T2.likes) FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2010;
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Users : user_id [ INTEGER ] primary_key user_yelping_since_year [ INTEGER ] user_average_stars [ TEXT ] user_votes_funny [ TEXT ] user_votes_useful [ TEXT ] user_votes_cool [ TEXT ] user_review_cou...
SELECT T2.tip_length FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id WHERE T1.user_average_stars = 3 GROUP BY T2.tip_length ORDER BY COUNT(T2.tip_length) DESC LIMIT 1;
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question...
SELECT SUM(T2.likes) AS likes FROM Business AS T1 INNER JOIN Tips AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'Goodyear';
[INST] Here is a database schema: Tips : business_id [ INTEGER ] user_id [ INTEGER ] likes [ INTEGER ] tip_length [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following question...
SELECT DISTINCT T1.state FROM Business AS T1 INNER JOIN Tips AS T2 ON T1.business_id = T2.business_id WHERE T2.tip_length = 'Long';
[INST] Here is a database schema: Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the fol...
SELECT SUM(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 = 'El Mirage' AND T1.state = 'AZ';
[INST] Here is a database schema: Days : day_id [ INTEGER ] primary_key day_of_week [ TEXT ] Business_Hours : business_id [ INTEGER ] day_id [ INTEGER ] opening_time [ TEXT ] closing_time [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ T...
SELECT T3.day_id - T2.day_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.state = 'SC';
[INST] Here is a database schema: Categories : category_id [ INTEGER ] primary_key category_name [ TEXT ] Business_Categories : business_id [ INTEGER ] category_id [ INTEGER ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write m...
SELECT DISTINCT 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.stars = 5;
[INST] Here is a database schema: Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_count [ TEXT ] Please write me a SQL statement that answers the following q...
SELECT DISTINCT T2.state FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.attribute_value = 'beer_and_wine';
[INST] Here is a database schema: Compliments : compliment_id [ INTEGER ] primary_key compliment_type [ TEXT ] Users_Compliments : compliment_id [ INTEGER ] user_id [ INTEGER ] number_of_compliments [ TEXT ] Please write me a SQL statement that answers the following question: How many user's compliment in photo has me...
SELECT COUNT(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' AND T2.number_of_compliments = 'Medium';
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Business : business_id [ INTEGER ] primary_key active [ TEXT ] city [ TEXT ] state [ TEXT ] stars [ REAL ] review_co...
SELECT T3.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 T1.attribute_name = 'Wi-Fi' AND T2.attribute_value = 'true' AND T3.state = 'SC';
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Please write me a SQL statement that answers the following question: Sum up the number of business with "ambience_r...
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 = 'ambience_romantic' AND T2.attribute_value = 'true';
[INST] Here is a database schema: Attributes : attribute_id [ INTEGER ] primary_key attribute_name [ TEXT ] Business_Attributes : attribute_id [ INTEGER ] business_id [ INTEGER ] attribute_value [ TEXT ] Please write me a SQL statement that answers the following question: What is the percentage of businesses with "Goo...
SELECT CAST(SUM(CASE WHEN attribute_name = 'Good for Kids' THEN 1 ELSE 0 END) AS REAL) * 100 / 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';