db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
video_games
Which game platform is the most popular in Europe?
game platform refers to game_platform_id; the most popular refers to max(num_sales); in Europe refers to region_name = 'Europe'
SELECT T.platform_name FROM ( SELECT T4.platform_name, SUM(T2.num_sales) FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id INNER JOIN game_platform AS T3 ON T2.game_platform_id = T3.id INNER JOIN platform AS T4 ON T3.platform_id = T4.id WHERE T1.region_name = 'Europe' ORDER BY T2.num_sales DESC LI...
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
retails
How many parts have a retail price of over 1900?
a retail price of over 1900 refers to p_retailprice > 1900
SELECT COUNT(p_partkey) FROM part WHERE p_retailprice > 1900
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
video_games
List down the game ID of games with genre ID 2.
game ID refers to game.id; genre ID 2 refers to genre_id = 2
SELECT T.id FROM game AS T WHERE T.genre_id = 2
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
What is the role of K Goel in the match ID 335992?
role refers to Role_Desc; K Goel refers to Player_Name = 'K Goel'; match ID 335992 refers to Match_Id = 335992
SELECT T3.Role_Desc FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T2.Player_Id = T1.Player_Id INNER JOIN Rolee AS T3 ON T3.Role_Id = T2.Role_Id WHERE T2.Match_Id = 335992 AND T1.Player_Name = 'K Goel'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
What is the comment of the product "burlywood plum powder puff mint"?
comment refers to p_comment; product "burlywood plum powder puff mint" refers to p_name = 'burlywood plum powder puff mint'
SELECT p_comment FROM part WHERE p_name = 'burlywood plum powder puff mint'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
What is the name of the first book written by J.K Rowling?
"J.K Rowling" is the author_name; first published book refers to book_id where Min(publication_date); name of the book refers to title
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'J.K. Rowling' ORDER BY T1.publication_date ASC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
retails
Please list the names of all the products under the type "promo brushed steel".
product name refers to p_name; type "promo brushed steel" refers to p_type = 'PROMO BRUSHED STEEL'
SELECT p_name FROM part WHERE p_type = 'PROMO BRUSHED STEEL'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
video_games
What are the names of the publishers who published the oldest games?
name of publisher refers to publisher_name; the oldest game refers to min(release_year)
SELECT DISTINCT T3.publisher_name FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN publisher AS T3 ON T2.publisher_id = T3.id ORDER BY T1.release_year LIMIT 1
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
Provide the point of the winning margin in a match between Mumbai Indians and Royal Challengers Bangalore on May 28, 2008.
point of the winning margin refers to Win_Margin; Mumbai Indians refers to Team_Name = 'Mumbai Indians'; Royal Challengers Bangalore refers to Team_Name = 'Royal Challengers Bangalore'; on May 28 2008 refers to Match_Date = '2008-05-28'
SELECT T1.Win_Margin FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 INNER JOIN Team AS T3 ON T3.Team_Id = T1.Team_2 WHERE (T2.Team_Name = 'Mumbai Indians' AND T3.Team_Name = 'Royal Challengers Bangalore' AND T1.Match_Date = '2008-05-28') OR (T2.Team_Name = 'Royal Challengers Bangalore' AND T3.Team_Nam...
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
Calculate percentage of household segment in Indonesia.
household segment refers to c_mktsegment = 'HOUSEHOLD'; Indonesia refers to n_name = 'Indonesia'; percentage = divide(count(c_mktsegment = 'HOUSEHOLD'), count(c_mktsegment)) where n_name = 'Indonesia' * 100%
SELECT CAST(SUM(IIF(T1.c_mktsegment = 'HOUSEHOLD', 1, 0)) AS REAL) * 100 / COUNT(T1.c_mktsegment) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'INDONESIA'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
video_games
Which year has the most number of PC games releases?
year refers to release_year; the most number of releases refers to max(count(game_id))
SELECT T.release_year FROM ( SELECT T2.release_year, COUNT(DISTINCT T3.game_id) FROM platform AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.platform_id INNER JOIN game_publisher AS T3 ON T2.game_publisher_id = T3.id WHERE T1.platform_name = 'PC' GROUP BY T2.release_year ORDER BY COUNT(DISTINCT T3.game_id) DESC LIM...
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
retails
Calculate the percentage of countries that belong to the American region.
the American region refers to r_name = 'America'; percentage = divide(count(n_name where r_name = 'America'), count(n_name)) * 100%
SELECT CAST(SUM(IIF(T1.r_name = 'America', 1, 0)) AS REAL) * 100 / COUNT(T2.n_name) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
What is the full name of the customer who ordered the most books of all time?
customer who ordered the most book refers to customer_id where Max(count(order_id)); full name refers to first_name, last_name
SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
soccer_2016
Among the players born in 1977, what is the percentage of the players with a role as a captain?
born in 1977 refers to DOB LIKE '1977%'; a role as a captain refers to Role_Desc = 'Captain'; percentage = divide(count(Role_Id where Role_Desc = 'Captain'), count(Role_Id)) * 100% where DOB LIKE '1977%'
SELECT CAST(SUM(CASE WHEN T1.Role_Desc = 'Captain' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Role_Id) FROM Rolee AS T1 INNER JOIN Player_Match AS T2 ON T2.Role_Id = T1.Role_Id INNER JOIN Player AS T3 ON T3.Player_Id = T2.Player_Id WHERE T3.DOB LIKE '1977%'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
Please indicate the names of customers whose orders are eligible for 10% discount with order dates between 1/1/1994 and 1/1/1995.
customer name refers to c_name; 10% discount refers to l_discount = 0.1; order dates between 1/1/1994 and 1/1/1995 refers to year(o_orderdate) = 1994 OR o_orderdate = '1995-01-01'
SELECT T3.c_name FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey INNER JOIN customer AS T3 ON T1.o_custkey = T3.c_custkey WHERE T2.l_discount = 0.1 AND STRFTIME('%Y', T1.o_orderdate) BETWEEN 1994 AND 1995
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
What is the name of the publisher who published Agatha Christie's first book?
"Agatha Christie" is the author_name; name of publisher refers to publisher_name; first book refers to Min(publication_date)
SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Agatha Christie' ORDER BY T1.publication_date ASC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
video_games
List the names of all the publishers who published one game only.
name of publisher refers to publisher_name; published one game only refers to count(publisher_id) = 1
SELECT T.publisher_name FROM ( SELECT T2.publisher_name, COUNT(DISTINCT T1.game_id) FROM game_publisher AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id GROUP BY T2.publisher_name HAVING COUNT(DISTINCT T1.game_id) = 1 ) t
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
How many matches were held at the venue named "Newlands"?
the venue named "Newlands" refers to Venue_Name = 'Newlands'
SELECT SUM(CASE WHEN T2.Venue_Name = 'Newlands' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Venue AS T2 ON T2.Venue_Id = T1.Venue_Id
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
How many countries belong to the Algeria region?
the algeria region refers to r_name = 'ALGERIA'
SELECT COUNT(T1.r_name) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T2.n_name = 'ALGERIA'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
How many orders were delivered in 2021?
delivered refers to status_value = 'Delivered'; in 2021 refers to status_date LIKE '2021%'
SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2021'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
video_games
What is the genre ID of the game named 25 to Life?
the game named 25 to Life refers to game_name = '25 to Life'
SELECT T.genre_id FROM game AS T WHERE T.game_name = '25 to Life'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
List the names of the first andthe second teams that played a match with the point of the winning margin lower than the 30% of the average winning margin of the matches held in 2011.
name of the team refers to Team_Name; in 2011 refers to Match_Date LIKE '2011%'; the point of winning margin lower than 30% of the average winning margin refers to Win_Margin < multiply(avg(Win_Margin), 0.3) where Match_Date LIKE '2011%'
SELECT DISTINCT CASE WHEN T1.Win_Margin < ( SELECT AVG(Win_Margin) * 0.3 FROM Match WHERE Match_Date LIKE '2011%' ) THEN T2.Team_Name END, CASE WHEN T1.Win_Margin < ( SELECT AVG(Win_Margin) * 0.3 FROM Match WHERE Match_Date LIKE '2011%' ) THEN T3.Team_Name END FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.T...
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
Among the providers in Argentina, which supplier has an account that is in debt?
Argentina refers to n_name = 'ARGENTINA'; supplier refers to s_name; an account in debt refers to s_acctbal < 0
SELECT T1.s_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 AND T2.n_name = 'ARGENTINA'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
video_games
Provide any five games and release year under the sports genre.
game refers to game_name; under the sports genre refers to genre_name = 'Sports'
SELECT T3.game_name, T1.release_year FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id INNER JOIN genre AS T4 ON T3.genre_id = T4.id WHERE T4.genre_name = 'Sports' LIMIT 5
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
retails
List the phone numbers of suppliers from Japan.
phone number refers to s_phone; Japan refers to n_name = 'JAPAN'
SELECT T1.s_phone FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'JAPAN'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
List all the names of the books written by Danielle Steel.
"Danielle Steel" is the author_name; name of books refers to title
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Danielle Steel'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
video_games
How many games can be played on the Wii platform?
on the Wii platform refers to platform_name = 'Wii'
SELECT COUNT(T1.id) FROM game_platform AS T1 INNER JOIN platform AS T2 ON T1.platform_id = T2.id WHERE T2.platform_name = 'Wii'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
How many overs were there in the first innings of match ID "335996"?
the first innings refers to Innings_No = 1; match ID "335996" refers to Match_Id = 335996
SELECT COUNT(Over_Id) FROM Ball_by_Ball WHERE Match_Id = 335996 AND Innings_No = 1
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
retails
Name customers in India with account balances over $5000.
customer name refers to c_name; India refers to n_name = 'INDIA'; account balance over $5000 refers to c_acctbal > 5000
SELECT T1.c_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal > 5000 AND T2.n_name = 'INDIA'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
books
How many books did A.R. Braunmuller write?
"A.R. Braunmuller" is the author_name
SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'A.R. Braunmuller'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_...
food_inspection_2
What is the establishment's name and employee involved in the inspection ID 44256 on May 5, 2010?
establishment's name refers to dba_name; employee name refers to first_name, last_name; inspection ID 44256 refers to inspection_id = 44256; on May 5, 2010 refers to inspection_date = '2010-05-05'
SELECT T1.dba_name, T3.first_name, T3.last_name FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN employee AS T3 ON T2.employee_id = T3.employee_id WHERE T2.inspection_date = '2010-05-05' AND T2.inspection_id = 44256
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
How many businesses have a romantic ambiance?
romantic ambiance refers to attribute_name = 'ambience_romantic' AND attribute_value = 'true'
SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_value = 'true' AND T1.attribute_name = 'ambience_romantic'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
Provide the inspection ID of the establishment named "PIZZA RUSTICA, INC."
"PIZZA RUSTICA, INC." refers to dba_name = 'PIZZA RUSTICA, INC'
SELECT DISTINCT T2.inspection_id FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.dba_name = 'PIZZA RUSTICA, INC'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Is the Yelp business No. 14033 good for supper?
business no. 14033 refers to business_id = 14033; good for supper refers to attribute_name = 'good_for_dinner'
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
How much is the salary of the employee who has the highest number of inspections done of all time?
the highest number of inspections done refers to max(count(employee_id))
SELECT T1.salary FROM employee AS T1 INNER JOIN ( SELECT employee_id, COUNT(inspection_id) FROM inspection GROUP BY employee_id ORDER BY COUNT(inspection_id) DESC LIMIT 1 ) AS T2 ON T1.employee_id = T2.employee_id
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
How many businesses are opened for 24 hours?
opened for 24 hours refers to attribute_name = 'Open 24 Hours' AND attribute_value = 'true'
SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Open 24 Hours'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
Which business had the highest number of inspections done? Calculate the percentage of passed and failed inspections of the said business.
business name refers to dba_name; the highest number of inspections done max(count(inspection_id)); percentage of passed inspections = divide(sum(inspection_id where results = 'Pass'), total(inspection_id)) * 100%; percentage of failed inspections = divide(sum(inspection_id where results = 'Fail'), total(inspection_id)...
SELECT T2.dba_name , CAST(SUM(CASE WHEN T1.results = 'Pass' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.inspection_id) AS percentagePassed , CAST(SUM(CASE WHEN T1.results = 'Fail' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.inspection_id) FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.lice...
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
What city does the business have a business hour from 10 am to 12 pm on Sunday?
10 am refers to opening_time = '10AM'; 12 pm refers to closing_time = '12PM'; on Sunday refers to day_of_week = 'Sunday'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Among the active businesses in Ahwatukee, which of them are still open in Sunday?
active business refers to active = 'true'; 'Ahwatukee' is the name of city; open in Sunday refers to day_of_week = 'Sunday'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
List the category of the business with high review count but received 2 stars.
high review count refers to review_count = 'High'; received 2 stars refers to stars = 2; category refers to category_name
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
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.
located in "Phoenix" refers to city = 'Phoenix'; received a "5" star review refers to review_stars = '5'; "uber" number of votes for funny refers to review_votes_funny = 'Uber'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
List the city of the business where they open from 1 pm to 6 pm on Saturday.
1 pm refers to opening_time = '1PM'; 6 pm refers to closing_time = '6PM'; on Saturday refers to day_of_week = 'Saturday'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
How long is the Yelp business No. 15098 opened on Monday?
Yelp business No. 15098 refers to business_id = '15098'; Monday refers to day_of_week = 'Monday'
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
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?
in "2010" refers to user_yelping_since_year = '2010'; average of "4.5" stars review refers to user_average_stars = '4.5'; uber number of fans refers to user_average_stars = '4.5'; "funny" compliments refers to compliment_type = 'funny'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
List the categories of all active businesses that were not in Arizona.
active business refers to active = 'true'; not in Arizona refers to state ! = 'AZ'; category refers to category_name
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What are the names of the businesses that passed with conditions in May 2012?
name of business refers to dba_name; passed with conditions refers to results = 'Pass w/ Conditions'; in May 2012 refers to inspection_date like '2012-05%'
SELECT DISTINCT T2.dba_name FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y-%m', T1.inspection_date) = '2012-05' AND T1.results = 'Pass w/ Conditions'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
food_inspection_2
What is the assumed name of the business that has the highest total fine in 2014?
assumed name of business refers to dba_name; the highest total fine refers to max(sum(fine)); in 2014 refers to inspection_date like '2014%'
SELECT T.dba_name FROM ( SELECT T1.dba_name, SUM(T3.fine) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE strftime('%Y', T2.inspection_date) = '2014' GROUP BY T1.dba_name ORDER BY SUM(T3.fine) DESC LIMIT 1 ) AS...
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Which city is the business that got a "medium" length tip with "3" likes located in?
medium length tip refers to tip_length = 'Medium';
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
How much is the total fine given to Ron of Japan Inc in its inspection done on February 2014?
total fine = sum(fine); Ron of Japan Inc refers to dba_name = 'RON OF JAPAN INC'; on February 2014 refers to inspection_date like '2014-02%'
SELECT SUM(T3.fine) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE strftime('%Y-%m', T2.inspection_date) = '2014-02' AND T1.dba_name = 'RON OF JAPAN INC'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
How many businesses have shopping centers and received high review count?
"Shopping Centers" is the category_name; high review count refers to review_count = 'High'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What are the inspection description and inspector's comments in the inspection ID 164795?
inspection description refers to Description; inspector's comment refers to inspector_comment
SELECT T1.Description, T2.inspector_comment FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.inspection_id = 44247
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Does Yelp business No."11825" have a "parking lot"?
business No."11825" refers to business_id = '12476'; have a "parking lot" refers to attribute_value = 'parking_lot'
SELECT T1.attribute_value FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.business_id = 11825 AND T2.attribute_name = 'parking_lot'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
How many restaurants with the highest risk level still passed the inspection?
restaurant refers to facility_type = 'Restaurant'; the highest risk level refers to max(risk_level); pass the inspection refers to results = 'Pass'
SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.risk_level = 3 AND T2.results = 'Pass' AND T1.facility_type = 'Restaurant'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Calculate the average review star from users in businesses located in South Carolina and California state.
"South Carolina" and "California" are both state; average review stars from users = Divide((Sum(review_stars(state = 'SC')) + Sum(review_stars(state = 'CA'))), Sum(stars))
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 INNE...
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
How many "cool" type compliments does user No. 41717 get?
"cool" type compliments refers to compliment_type = 'cool'; user No. 41717 refers to user_id = 41717
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
List the names of employees involved in an inspection with the Display of Inspection Report Summary category.
name refers to first_name, last_name; Display of Inspection Report Summary category refers to category = 'Display of Inspection Report Summary'
SELECT DISTINCT T1.first_name, T1.last_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id INNER JOIN inspection_point AS T4 ON T3.point_id = T4.point_id WHERE T4.category = 'Display of Inspection Report Summary'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
What city does the business came from where they received a high volume of check-ins from 12 am to 1 am on Saturday.
12 am refers to opening_time = '12AM'; 1 am refers to closing_time = '1AM'; on Saturday refers to day_of_week = 'Saturday'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
What is the percentage for the Yelp businesses in "Pets" category of all businesses?
businesses in "Pets" category refers to category_name = 'Pets'; percentage refers to DIVIDE(COUNT(category_name = 'Pets'), COUNT(business_id)) * 100%
SELECT CAST(SUM(CASE WHEN T2.category_name = 'Pets' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.category_name) FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
How many businesses accept insurance?
business that accept insurance refers to attribute_name = 'Accepts Insurance' AND attribute_value = 'true'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Is the payment in mastercard possible for the Yelp business No."12476"?
Yelp business No."12476" refers to business_id = '12476'; payment in mastercard refers to attribute_value = 'payment_types_mastercard'
SELECT T1.attribute_value FROM Business_Attributes AS T1 INNER JOIN Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T1.business_id = 12476 AND T2.attribute_name = 'payment_types_mastercard'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What is the inspection ID of the inspection with critical point level, $500 fine, and inspector comment "CDI ON 5-17-10"?
critical point level refers to point_level = 'Critical'; $500 fine refers to fine = 500; inspector comment "CDI ON 5-17-10" refers to inspector_comment = 'CDI ON 5-17-10'
SELECT T2.inspection_id FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.fine = 500 AND T1.point_level = 'Critical' AND T2.inspector_comment = 'CDI ON 5-17-10'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Provide the number of Yelp businesses in "Gilbert" which got a" high" review count.
"Gilbert" is the name of city; high review count refers to review_count = 'High'
SELECT COUNT(business_id) FROM Business WHERE review_count = 'High' AND city = 'Gilbert'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
How many of the restaurants with the lowest risk level failed the complaint inspection type?
restaurant refers to facility_type = 'Restaurant'; the lowest risk level refers to min(risk_level); failed refers to results = 'Fail'; the complaint inspection type refers to inspection_type = 'Complaint'
SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.risk_level = '1' AND T2.inspection_type = 'Complaint' AND T1.facility_type = 'Restaurant' AND T2.results = 'Fail'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
food_inspection_2
Provide the fine paid and the complete address of the establishment with inspection ID 48216.
complete address refers to state, city, address
SELECT DISTINCT T3.fine, T1.state, T1.city, T1.address FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T2.inspection_id = 48216
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
food_inspection_2
What are the inspector's comments and clean operating requirement code for inspection ID 54216 and point ID 34?
inspector's comment refers to inspector_comment; clean operating requirement code refers to code
SELECT T2.inspector_comment, T1.code FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.inspection_id = 54216 AND T2.point_id = 34
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Write down the ID, active status and city of the business which are in CA state.
the ID refers to business_id; active status refers to active; active = 'true' means the business is still running; active = 'false' means the business is closed or not running now
SELECT business_id, active, city FROM Business WHERE state = 'CA' AND active = 'true'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
How many actively running Yelp businesses are there located in "Phoenix" city?
actively running business refers to active = 'true'; 'Phoenix' is the name of city
SELECT COUNT(business_id) FROM Business WHERE active = 'true' AND city = 'Phoenix'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What is the employee's last name at 7211 S Hermitage Ave, Chicago, IL?
7211 S Hermitage Ave refers to address = '7211 S Hermitage Ave'; Chicago refers to city = 'Chicago'; IL refers to state = 'IL'
SELECT last_name FROM employee WHERE address = '7211 S Hermitage Ave' AND city = 'Chicago' AND state = 'IL'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
How many times is the number of "Women's Clothing" Yelp businesses to "Men's Clothing"?
"Women's Clothing" Yelp businesses refers to  category_name = 'Women''s Clothing'; "Men's Clothing" refers to category_name = 'Men''s Clothing'; times refers to DIVIDE(COUNT(category_name = 'Women''s Clothing'), COUNT(category_name = 'Men''s Clothing'))
SELECT CAST(SUM(CASE WHEN T2.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) AS TIMES FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
State the ID number for the attribute named "Accepts Insurance"?
ID number refers to attribute_id
SELECT attribute_id FROM Attributes WHERE attribute_name = 'Accepts Insurance'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What is the precise location of the establishment with the highest number of failed inspections?
precise location refers to latitude, longitude; the highest number of failed inspections refers to max(count(results where results = 'Fail'))
SELECT T1.latitude, T1.longitude FROM establishment AS T1 INNER JOIN ( SELECT license_no FROM inspection WHERE results = 'Fail' GROUP BY license_no ORDER BY COUNT(results) DESC LIMIT 1 ) AS T2 ON T1.license_no = T2.license_no
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
food_inspection_2
What is the average number of inspections done by the top 5 employees with the highest salary? List the names of the said employees.
the highest salary refers to max(salary); sanitarian refers to title = 'Sanitarian'; name refers to first_name, last_name; average number = divide(sum(inspection_id), 5)
SELECT CAST(COUNT(DISTINCT T2.inspection_id) AS REAL) / 5, T1.first_name, T1.last_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T1.title = 'Sanitarian' ORDER BY T1.salary DESC LIMIT 5
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Among all attribute names, list down the ID and attribute name which start with "music".
attribute name which start with "music" refers to attribute_name LIKE 'music%'
SELECT attribute_id, attribute_name FROM Attributes WHERE attribute_name LIKE 'music%'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Give the number of "4" stars Yelp businesses in "Mesa" city.
"4" stars refers to stars = '4'; 'Mesa' is the name of city
SELECT COUNT(business_id) FROM Business WHERE stars = 4 AND city = 'Mesa'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
How many businesses from ward 42 have at least 5 failed inspection results between 1/1/2010 to 12/31/2015?
ward 42 refers to ward = 42; at least 5 failed inspection results refers to count(results = 'Fail') > = 5; between 1/1/2010 to 12/31/2015 refers to inspection_date between '2010-01-01' and '2015-12-31'
SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T2.inspection_date BETWEEN '2010-01-01' AND '2015-12-31' AND T1.ward = 42 AND T1.license_no IN ( SELECT license_no FROM ( SELECT license_no FROM inspection WHERE results = 'Fail' GROUP BY lic...
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Calculate the percentage of running business among all business.
running business refers to active = 'true'; percentage refers to DIVIDE(COUNT(active = 'true'), COUNT(business_id)) * 100%
SELECT CAST(SUM(CASE WHEN active = 'true' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(business_id) FROM Business
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What is the full name of the employee who gave the highest amount of fine of all time?
full name refers to first_name, last_name; the highest amount of fine refers to max(sum(fine))
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, SUM(T3.fine) FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id GROUP BY T1.first_name, T1.last_name ORDER BY SUM(T3.fine) DESC LIMIT 1 ) t
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Based on all user compliments, find the percentage of low number of compliments on all compliments ID.
low number of compliments refers to number_of_compliments = 'Low'; percentage refers to DIVIDE(COUNT(number_of_compliments = 'Low'), COUNT(user_id)) * 100
SELECT CAST(SUM(CASE WHEN number_of_compliments = 'Low' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(user_id) FROM Users_compliments
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What are the comments of the inspector during the inspection of Taqueria La Fiesta on 1/25/2010?
comment of the inspector refers to inspector_comment; Taqueria La Fiesta refers to dba_name = 'TAQUERIA LA FIESTA'; on 1/25/2010 refers to inspection_date = '2010-01-25'
SELECT T3.inspector_comment FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T2.inspection_date = '2010-01-25' AND T1.dba_name = 'TAQUERIA LA FIESTA'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
For the Yelp business in "Tempe" city which got "3.5" stars and review count as "Uber", how many "long" reviews did it get?
"Tempe" is the name of city; long review refers to review_length = 'Long'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Among the review votes of funny and cool hit uber with long review length, describe the business ID, active status, user ID and user year of joining Yelp.
review votes of funny refers to review_votes_funny = 'Uber'; cool hit uber refers to review_votes_cool = 'Uber'; user year of joining Yelp refers to user_yelping_since_year
SELECT T1.business_id, T1.active, T3.user_id, T3.user_yelping_since_year FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id INNER JOIN Users AS T3 ON T2.user_id = T3.user_id WHERE T2.review_votes_cool = 'Uber' AND T2.review_votes_funny = 'Uber' AND T2.review_length = 'Long'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Between 2006 and 2007, which year ID had the greater number in elite user?
2006 and 2007 refers to BETWEEN 2006 AND 2007; greater number in elite user refers to count(user_id)
SELECT year_id FROM Elite WHERE year_id IN (2006, 2007) GROUP BY year_id ORDER BY COUNT(user_id) DESC LIMIT 1
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Write the user ID, business ID and tips length of who started using Yelp since 2004 and had high followers.
started using Yelp since 2004 refers to user_yelping_since_year = '2004'; had high followers refers to user_fans = 'High'
SELECT T1.user_id, T2.business_id, T2.tip_length FROM Users AS T1 INNER JOIN Tips AS T2 ON T1.user_id = T2.user_id WHERE T1.user_yelping_since_year = 2004 AND T1.user_fans = 'High'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
Out of all the short form complaint inspections done by David Hodges, how many businesses passed?
short form complaint inspection refers to inspection_type = 'Short Form Complaint'; pass refers to results = 'Pass'
SELECT COUNT(DISTINCT T2.license_no) FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T1.first_name = 'David' AND T1.last_name = 'Hodges' AND T1.employee_id = 153225 AND T2.inspection_type = 'Short Form Complaint' AND T2.results = 'Pass'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Calculate the percentage of business with attribute name of "Accepts Credit Cards".
percentage refers to DIVIDE(COUNT(attribute_name = 'Accepts Credit Cards'), COUNT(business_id))*100%
SELECT CAST(SUM(CASE WHEN T1.attribute_name = 'Accepts Credit Cards' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.attribute_name) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
Among the establishments that failed in the inspection, what is the percentage of establishments with the highest risk level?
failed in inspection refers to results = 'Fail'; the highest risk level refers to max(risk_level); percentage = divide(count(license_no where risk_level = max(risk_level)), count(license_no)) * 100% where results = 'Fail'
SELECT CAST(COUNT(CASE WHEN T1.risk_level = 3 THEN T1.license_no END) AS REAL) * 100 / COUNT(T1.risk_level) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T2.results = 'Fail'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
List down the business ID and user ID who got uber for cool votes.
got uber for cool votes refers to review_votes_cool = 'Uber'
SELECT business_id, user_id FROM Reviews WHERE review_votes_cool = 'Uber'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
Give the address of the schools that passed the inspection in March 2010.
school refers to facility_type = 'School'; pass refers to results = 'Pass'; in March 2010 refers to inspection_date like '2010-03%'
SELECT DISTINCT T1.address FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y-%m', T2.inspection_date) = '2010-03' AND T2.results = 'Pass' AND T1.facility_type = 'School'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Under the attribute name of "music_playlist", describe the attribute ID, business ID, city and inactive status.
active status refers to active; active = 'true' means the business is still running; active = 'false' means the business is inactive or not running now
SELECT T1.attribute_id, T2.business_id, T3.city FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name = 'music_playlist' AND T3.active = 'false'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
food_inspection_2
What is the employee's full name involved in the canvass inspection type on March 09, 2010?
full name refers to first_name, last_name; canvass inspection type refers to inspection_type = 'Canvass'; on March 09, 2010 refers to inspection_date = '2010-03-09'
SELECT DISTINCT T1.first_name, T1.last_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T2.inspection_date = '2010-03-09' AND T2.inspection_type = 'Canvass'
CREATE TABLE inspection ( followup_to INTEGER, -- foreign key (employee_id) references employee(employee_id), employee_id INTEGER, -- license_no INTEGER, -- foreign key (followup_to) references inspection(inspection_id), foreign key (license_no) references establishment(license_no), inspection_id INTEGER p...
public_review_platform
Mention the user average star, elite year and the compliment type of user ID 6027 whereby number of compliments reach uber.
number of compliments reach uber refers to number_of_compliments = 'Uber'; elite year refers to year_id; user average star refers to user_average_stars
SELECT T2.user_average_stars, T1.year_id, T4.compliment_type, T3.number_of_compliments FROM Elite AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id INNER JOIN Users_Compliments AS T3 ON T2.user_id = T3.user_id INNER JOIN Compliments AS T4 ON T3.compliment_id = T4.compliment_id INNER JOIN Years AS T5 ON T1.year_id...
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Which actively running Yelp business in "Gilbert" has got the most reviews? Give the business id.
actively running business refers to active = 'true'; 'Gilbert' is the name of city; most review refers to review_count = 'Uber'
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'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Describe category name which had above 10% in comparing with all business and categories.
above 10% refers to DIVIDE(COUNT(Business_Categories.business_id = category_id), COUNT(category_id)) * 100% > 10%
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Among the stopped businesses in San Tan Valley city, list down the user ID and review length of who had great experience.
stop businesses refers to active = 'false'; great experience refers to review_stars = 5
SELECT T2.user_id, T2.review_length FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.city = 'San Tan Valley' AND T1.active = 'false' AND T2.review_stars = 5
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Compare the number of business between the category of "Men's Clothing" and "Women's Clothing".
category of "Men's Clothing" refers to category_name = 'Men''s Clothing'; "Women's Clothing" refers to category_name = 'Women''s Clothing'
SELECT SUM(CASE WHEN T1.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS diff FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
Under the category name of "Coffee & Tea", mention any 5 business ID , their state and city.
null
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
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
How many 2 stars rated business located in Phoenix, Arizona?
located in Phoenix refers to city = 'Phoenix'; Arizona refers to state = 'AZ'
SELECT COUNT(business_id) FROM Business WHERE city = 'Phoenix' AND state = 'AZ' AND stars = 2
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
For the business with great experience existed in Sun Lakes city, provide the user ID who gave review on it and user followers.
with great experience refers to stars = 5
SELECT T3.user_id, T3.user_fans FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id INNER JOIN Users AS T3 ON T2.user_id = T3.user_id WHERE T1.city = 'Sun Lakes' AND T1.stars = 5
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
public_review_platform
List all the businesses that closed at 8PM.
closed at 8PM refers to closing_time = '8PM';
SELECT DISTINCT business_id FROM Business_Hours WHERE closing_time = '8PM'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
disney
Provide a list of directors from the 1990s.
the 1990s refers to (cast(SUBSTR(release_date, instr(release_date, ', ') + 1) as int) between 1990 and 2000);
SELECT T2.director FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name AND CAST(SUBSTR(release_date, INSTR(release_date, ', ') + 1) AS int) BETWEEN 1990 AND 2000 GROUP BY T2.director
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...