File size: 190,137 Bytes
b108984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
{"question_id": 11, "db_id": "movie_platform", "grading_method": "set", "question": "List the titles of movies that received at least one rating of 4 or higher in 2020.", "evidence": "ratings.rating_timestamp_utc is the rating’s UTC timestamp, stored as YYYY-MM-DD HH:MM:SS. ratings.rating_score uses a 1-to-5 scale.", "SQL": "SELECT DISTINCT m.`movie_title`\nFROM `ratings` r\nJOIN `movies`  m ON r.`movie_id` = m.`movie_id`\nWHERE SUBSTR(r.`rating_timestamp_utc`,1,4) = '2020'\n  AND r.`rating_score` >= 4;"}
{"question_id": 17, "db_id": "movie_platform", "grading_method": "set", "question": "List the Mubi URLs for lists that have one or two followers and were last updated in 2012", "evidence": "URL to the list page on Mubi refers to list_url; list_followers = 1 OR list_followers = 2; last update timestamp was on 2012 refers to list_update_timestamp_utc", "SQL": "SELECT list_url FROM lists WHERE list_update_timestamp_utc LIKE '2012%' AND list_followers BETWEEN 1 AND 2"}
{"question_id": 19, "db_id": "movie_platform", "grading_method": "set", "question": "For movie 1269, how many paying subscribers eligible for a trial when rating it gave a score of 2 or less?", "evidence": "ratings.user_has_payment_method = 1 denotes a paying subscriber; ratings.user_eligible_for_trial = 1 denotes trial eligibility when the rating was made. ratings.rating_score records the score.", "SQL": "SELECT COUNT(DISTINCT user_id) FROM ratings WHERE movie_id = 1269 AND rating_score <= 2 AND user_eligible_for_trial = 1 AND user_has_payment_method = 1"}
{"question_id": 92, "db_id": "movie_platform", "grading_method": "set", "question": "Please provide the titles of the lists with the most comments on the lists.", "evidence": "the most comments refers to Max(list_comments);", "SQL": "SELECT list_title FROM lists WHERE list_comments = (SELECT MAX(list_comments) FROM lists);"}
{"question_id": 93, "db_id": "movie_platform", "grading_method": "set", "question": "Which movies released in 2008 have the highest average rating? List all tied titles.", "evidence": "movies.movie_release_year records release year; ratings.rating_score records rating scores and ratings.movie_id identifies the movie.", "SQL": "SELECT m.movie_title FROM movies AS m JOIN ratings AS r ON r.movie_id = m.movie_id WHERE m.movie_release_year = 2008 GROUP BY m.movie_id HAVING AVG(r.rating_score) = (SELECT AVG(r.rating_score) FROM movies AS m JOIN ratings AS r ON r.movie_id = m.movie_id WHERE m.movie_release_year = 2008 GROUP BY m.movie_id ORDER BY AVG(r.rating_score) DESC LIMIT 1);"}
{"question_id": 97, "db_id": "movie_platform", "grading_method": "set", "question": "What's the cover image of the user who created the movie list 'Georgia related films'?", "evidence": "'Georgia related films' is list_title; cover image of user refers to user_cover_image_url;", "SQL": "SELECT T1.user_cover_image_url FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_title LIKE 'Georgia related films'"}
{"question_id": 101, "db_id": "movie_platform", "grading_method": "set", "question": "How many users were not trialists when they rated the movie \"Patti Smith: Dream of Life\"?", "evidence": "movies.movie_title records 'Patti Smith: Dream of Life'. ratings.user_trialist = 0 means the user was not a trialist when giving that rating.", "SQL": "SELECT COUNT(DISTINCT T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'Patti Smith: Dream of Life' AND T1.user_trialist = 0"}
{"question_id": 107, "db_id": "movie_platform", "grading_method": "set", "question": "Which films rated by user 59988436 have received 21 comments? Indicate the movie titles.", "evidence": "ratings.critic_comments records comments on a review; movies.movie_title records film titles.", "SQL": "SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.user_id = 59988436 AND T1.critic_comments = 21"}
{"question_id": 122, "db_id": "movie_platform", "grading_method": "set", "question": "Show the avatar of the user who gave the rating at 2019/10/17 1:36:36.", "evidence": "at 2019/10/17 1:36:36 refers to rating_timestamp_utc = '2019-10-17 01:36:36'; avatar of the user refers to user_avatar_image_url\n\n", "SQL": "SELECT DISTINCT ru.user_avatar_image_url\nFROM ratings AS r\nJOIN ratings_users AS ru ON r.user_id = ru.user_id\nWHERE r.rating_timestamp_utc = '2019-10-17 01:36:36';"}
{"question_id": 209, "db_id": "book_publishing_company", "grading_method": "set", "question": "Give detailed note information for the four best-selling books.", "evidence": "titles.notes contains the book notes; sales.qty records quantity sold.", "SQL": "SELECT t.notes\nFROM `titles` t\nJOIN (\n    SELECT `title_id`, SUM(`qty`) AS total_qty\n    FROM `sales`\n    GROUP BY `title_id`\n    ORDER BY total_qty DESC\n    LIMIT 4\n) s ON t.`title_id` = s.`title_id`;"}
{"question_id": 237, "db_id": "book_publishing_company", "grading_method": "set", "question": "Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?", "evidence": "publisher refers to pub_name; about the title refers to notes", "SQL": "SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'"}
{"question_id": 263, "db_id": "retail_complains", "grading_method": "set", "question": "How many days elapsed between receiving and sending to the company the complaint from Mr. Brantley Julian Stanley on 2012/5/18?", "evidence": "events.\"Date received\" and \"Date sent to company\" record the two dates in YYYY-MM-DD form. client.first, middle and last record the name components; client.sex = 'Male' corresponds to Mr.", "SQL": "SELECT CAST( julianday(e.`Date sent to company`) -\n             julianday(e.`Date received`) AS INT) AS days_delay\nFROM   events  AS e\nJOIN   client  AS c ON c.client_id = e.`Client_ID`\nWHERE  e.`Date received` = '2012-05-18'\n  AND  c.first  = 'Brantley'\n  AND  c.middle = 'Julian'\n  AND  c.last   = 'Stanley'\n  AND  c.sex    = 'Male'"}
{"question_id": 267, "db_id": "retail_complains", "grading_method": "set", "question": "How many stars did ‘Eagle Capital’ receive in total from Little Rock on 2013/4/4?", "evidence": "Eagle Capital is reviews.Product = 'Eagle Capital'; reviews.Stars records stars received and district.city records the city. reviews.Date represents April 4, 2013 as '2013-04-04'.", "SQL": "SELECT SUM(`Stars`) AS total_stars FROM `reviews` r JOIN `district` d ON r.`district_id` = d.`district_id` WHERE r.`Product` = 'Eagle Capital' AND d.`city` = 'Little Rock' AND r.`Date` = '2013-04-04'"}
{"question_id": 412, "db_id": "movies_4", "grading_method": "set", "question": "What is the name of the director of photography of the movie \"Pirates of the Caribbean: At World's End\"?", "evidence": "name of the director of photography refers to person_name where job = 'Director of Photography'; \"Pirates of the Caribbean: At World's End\" refers to title = 'Pirates of the Caribbean: At World''s End'", "SQL": "SELECT T3.person_name FROM movie AS T1 INNER JOIN movie_crew AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T1.title LIKE 'Pirates of the Caribbean: At World''s End' AND T2.job = 'Director of Photography'"}
{"question_id": 451, "db_id": "movies_4", "grading_method": "set", "question": "What is the title of Jamie Foxx's most recent movie?", "evidence": "most recent movie refers to max(release_date)", "SQL": "SELECT T1.title FROM movie AS T1 INNER JOIN movie_cast AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T3.person_name = 'Jamie Foxx' and T1.release_date = (SELECT MAX(T4.release_date) FROM movie AS T4 INNER JOIN movie_cast AS T5 ON T4.movie_id = T5.movie_id INNER JOIN person AS T6 ON T5.person_id = T6.person_id WHERE T6.person_name = 'Jamie Foxx')"}
{"question_id": 457, "db_id": "movies_4", "grading_method": "set", "question": "In Movie No. 19, how many people work in Department No. 7? In the second column, list their distinct job titles alphabetically, separated by commas with no added spaces.", "evidence": "Movie No. 19 refers to movie_id = 19; Department No. 7 refers to department_id = 7", "SQL": "SELECT COUNT(DISTINCT person_id) AS num_people, (SELECT GROUP_CONCAT(job, ',') FROM (SELECT DISTINCT job FROM movie_crew WHERE movie_id = 19 AND department_id = 7 AND job IS NOT NULL ORDER BY job)) AS jobs FROM movie_crew WHERE movie_id = 19 AND department_id = 7"}
{"question_id": 486, "db_id": "movies_4", "grading_method": "subset,=,5", "question": "List down five movie titles that were released before 2000.", "evidence": "released before 2000 refers to release_date < '2000-01-01'", "SQL": "SELECT title FROM movie WHERE CAST(STRFTIME('%Y', release_date) AS INT) < 2000"}
{"question_id": 543, "db_id": "movies_4", "grading_method": "set", "question": "List the character names in the \"Open Water\" movie.", "evidence": "\"Open Water\" movie refers to title = 'Open Water'", "SQL": "SELECT T2.character_name FROM movie AS T1 INNER JOIN movie_cast AS T2 ON T1.movie_id = T2.movie_id WHERE T1.title = 'Open Water'"}
{"question_id": 555, "db_id": "movies_4", "grading_method": "set", "question": "Which movies did the company Paramount Pictures produce in 2000?", "evidence": "Which movies refers to title; company Paramount Pictures refers to company_name = 'Paramount Pictures'; in 2000 refers to release_date LIKE '2000%'", "SQL": "SELECT T3.title FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id INNER JOIN movie AS T3 ON T2.movie_id = T3.movie_id WHERE T1.company_name = 'Paramount Pictures' AND CAST(STRFTIME('%Y', T3.release_date) AS INT) = 2000"}
{"question_id": 571, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the most liked repository? Indicate its github address and the amount of stars it has received.", "evidence": "more stars mean more people like this repository; most liked refers to max(Stars); the github address of repository refers to Url;", "SQL": "SELECT Url, Stars FROM Repo WHERE Stars = ( SELECT MAX(Stars) FROM Repo )"}
{"question_id": 609, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the solution path for the method \"IQ.Data.DbQueryProvider.CanBeEvaluatedLocally\"?", "evidence": "solution path refers to Path; method refers to Name; Name = 'IQ.Data.DbQueryProvider.CanBeEvaluatedLocally'", "SQL": "SELECT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Name = 'IQ.Data.DbQueryProvider.CanBeEvaluatedLocally'"}
{"question_id": 640, "db_id": "codebase_comments", "grading_method": "set", "question": "List all the solutions of repositories with the Forks higher than half of the watchers.", "evidence": "solutions refers to Solution.Id; forks higher than half of the watchers refers tto Forks>(Watchers/2);;", "SQL": "SELECT DISTINCT T2.Id FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Forks > T1.Watchers / 2"}
{"question_id": 657, "db_id": "codebase_comments", "grading_method": "set", "question": "How many solutions belong to repositories with at least one-third more stars than forks?", "evidence": "solutions refers to Solution.Id; repository stars are at least one-third more than forks refers to Stars >= Forks * 4.0 / 3;", "SQL": "SELECT COUNT(*)\nFROM `Solution` AS s\nJOIN `Repo` AS r ON s.`RepoId` = r.`Id`\nWHERE r.`Stars` >= r.`Forks`*4.0/3;"}
{"question_id": 688, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the average processed time of the solution with a repository of 254 likes, 88 followers, and 254 watchers?", "evidence": "average processed time = AVG(ProcessedTime);", "SQL": "SELECT CAST(SUM(T2.ProcessedTime) AS REAL) / COUNT(T2.ProcessedTime) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Stars = 254 AND T1.Forks = 88 AND T1.Watchers = 254"}
{"question_id": 706, "db_id": "trains", "grading_method": "set", "question": "Which directions have the trains that have the most rectangle-shaped cars?", "evidence": "most rectangle-shaped cars refers to MAX(rectCarsNum)", "SQL": "SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS rectCarsNum FROM cars WHERE shape = 'rectangle' GROUP BY train_id) AS T2 ON T1.id = T2.train_id AND rectCarsNum = (SELECT COUNT(id) AS cnt FROM cars WHERE shape = 'rectangle' GROUP BY train_id ORDER BY cnt DESC LIMIT 1)"}
{"question_id": 763, "db_id": "movie", "grading_method": "set", "question": "How many Romance movies featured John Travolta?", "evidence": "characters records actors’ movie appearances.", "SQL": "SELECT COUNT(*) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Genre = 'Romance' AND T3.Name = 'John Travolta'"}
{"question_id": 823, "db_id": "social_media", "grading_method": "set", "question": "Which gender’s users posted the most tweets in English (en)?", "evidence": "twitter.Lang = 'en' denotes English; twitter.text records the tweet text and user.Gender records the user’s gender.", "SQL": "WITH gender_count AS (\n  SELECT T2.Gender, COUNT( text) AS num \n  FROM twitter AS T1 \n  INNER JOIN user AS T2 ON T1.UserID = T2.UserID \n  WHERE T1.Lang = 'en' GROUP BY T2.Gender\n)\nSELECT T.Gender FROM gender_count T WHERE num = (\n  SELECT MAX(num) FROm gender_count)"}
{"question_id": 824, "db_id": "social_media", "grading_method": "set", "question": "Which genders are recorded for users who posted a tweet that was retweeted more than 30 times?", "evidence": "user.Gender uses 'Male', 'Female', and 'Unknown'.", "SQL": "SELECT DISTINCT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.RetweetCount > 30"}
{"question_id": 840, "db_id": "social_media", "grading_method": "set", "question": "What is the total number of tweets sent by male users on Mondays?", "evidence": "male user refers to Gender = 'Male'; 'Monday' is the Weekday; total number of tweet refers to Count (TweetID)", "SQL": "SELECT COUNT(DISTINCT T1.TweetID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Male' AND T1.Weekday = 'Monday'"}
{"question_id": 856, "db_id": "cs_semester", "grading_method": "set", "question": "How many professors are more popular than Zhihua Zhou?", "evidence": "higher popularity means the professor is more popular;", "SQL": "SELECT COUNT(prof_id) FROM prof WHERE popularity > ( SELECT popularity FROM prof WHERE first_name = 'Zhihua' AND last_name = 'Zhou' )"}
{"question_id": 897, "db_id": "cs_semester", "grading_method": "set", "question": "How many courses does the student with the highest GPA this semester take?", "evidence": "student with the highest GPA refers to student_id where MAX(gpa);", "SQL": "SELECT COUNT(course_id) FROM registration WHERE student_id IN ( SELECT student_id FROM student WHERE gpa = ( SELECT MAX(gpa) FROM student ) )"}
{"question_id": 901, "db_id": "cs_semester", "grading_method": "set", "question": "Which of the two courses, \"Advanced Operating System\" or \"Intro to BlockChain,\" had the most students receive an A?", "evidence": "An A grade is registration.grade = 'A'. Course name is course.name; the compared courses are 'Advanced Operating System' and 'Intro to BlockChain'.", "SQL": "SELECT T2.name FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T1.grade = 'A' AND T2.name IN ('Advanced Operating System', 'Intro to BlockChain') GROUP BY T2.name ORDER BY COUNT(T1.student_id) DESC LIMIT 1"}
{"question_id": 908, "db_id": "cs_semester", "grading_method": "set", "question": "List the first and last names of professors who graduated from the University of Boston.", "evidence": "prof.graduate_from records the university a professor graduated from.", "SQL": "SELECT first_name, last_name FROM prof WHERE graduate_from = 'University of Boston'"}
{"question_id": 920, "db_id": "cs_semester", "grading_method": "set", "question": "Provide the registered courses' names by undergraduate students with GPA of 3.7 and above.", "evidence": "Undergraduate students refers to type = 'UG'; GPA of 3.7 and above refers to gpa >= 3.7;", "SQL": " SELECT DISTINCT `c`.`name`\nFROM `student` AS `s`\nJOIN `registration` AS `r` ON `s`.`student_id` = `r`.`student_id`\nJOIN `course` AS `c` ON `r`.`course_id` = `c`.`course_id`\nWHERE `s`.`type` = 'UG' AND `s`.`gpa` >= 3.7;"}
{"question_id": 934, "db_id": "cs_semester", "grading_method": "set", "question": "What are the distinct difficulties of the courses in which a student with level of intelligence of 5 got an A grade?", "evidence": "difficulty of the course refers to diff;", "SQL": "SELECT DISTINCT T3.diff FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T2.grade = 'A' AND T1.intelligence = 5"}
{"question_id": 962, "db_id": "cs_semester", "grading_method": "set", "question": "Among students who gave a satisfaction value of 4 for the course \"Statistical learning,\" how many have a GPA of 3.8?", "evidence": "Course satisfaction is registration.sat; the requested value is 4. Student GPA is student.gpa; the requested value is 3.8. Course name is course.name; Statistical learning is stored as 'Statistical learning'.", "SQL": "SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Statistical learning' AND T2.sat = 4 AND T1.gpa = 3.8"}
{"question_id": 986, "db_id": "computer_student", "grading_method": "set", "question": "How many teachers are faculty employees?", "evidence": "teachers refers to professor = 1; faculty employees refers to hasPosition = 'Faculty_eme'", "SQL": "SELECT COUNT(*)\nFROM `person`\nWHERE `professor` = 1\n  AND `hasPosition` = 'Faculty_eme'"}
{"question_id": 990, "db_id": "computer_student", "grading_method": "set", "question": "Is the teacher who teaches course no.9 a faculty member? Yes or No", "evidence": "teacher refers to taughtBy.p_id; course no.9 refers to taughtBy.course_id = 9; faculty member refers to hasPosition ! = 0", "SQL": "SELECT CASE WHEN T2.hasPosition != 0 THEN 'Yes' ELSE 'No' END FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.course_id = 9"}
{"question_id": 1027, "db_id": "computer_student", "grading_method": "set", "question": "For each student with more than two advisors, what year of their program are they in?", "evidence": "person.student = 1 denotes a student. advisedBy.p_id identifies the advisee and advisedBy.p_id_dummy the advisor. person.yearsInProgram uses Year_N for program year N.", "SQL": "SELECT T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.student = 1 GROUP BY T2.p_id HAVING COUNT(T2.p_id) > 2"}
{"question_id": 1045, "db_id": "talkingdata", "grading_method": "set", "question": "What is the name of the category which most users belong to?", "evidence": "most users belong to refers to MAX(COUNT(app_id)); name of category refers to category;", "SQL": "WITH category_cnt AS ( \n  SELECT T2.category, COUNT(DISTINCT T1.app_id) AS num \n  FROM app_labels AS T1 \n  INNER JOIN label_categories AS T2 \n  ON T2.label_id = T1.label_id \n  GROUP BY T2.category\n) SELECT category \nFROM category_cnt WHERE num = (SELECT MAX(num) FROM category_cnt)"}
{"question_id": 1046, "db_id": "talkingdata", "grading_method": "set", "question": "What are the models of the oldest users' devices?", "evidence": "model of the device refers to device_model; oldest user refers to MAX(age);", "SQL": "SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T2.age = ( SELECT MAX(age) FROM gender_age );"}
{"question_id": 1087, "db_id": "talkingdata", "grading_method": "set", "question": "Please list the distinct categories of the app users who are not active when event no.2 happened.", "evidence": "not active refers to is_active = 0; event no. refers to event_id; event_id = 2;", "SQL": "SELECT DISTINCT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.event_id = 2 AND T3.is_active = 0"}
{"question_id": 1119, "db_id": "talkingdata", "grading_method": "set", "question": "What is the phone brand of the device model \"坚果手机\"?", "evidence": "", "SQL": "SELECT distinct phone_brand FROM phone_brand_device_model2 WHERE device_model = '坚果手机'"}
{"question_id": 1120, "db_id": "talkingdata", "grading_method": "set", "question": "Give the number of device models for \"中兴\" phone brand.", "evidence": "", "SQL": "SELECT COUNT(DISTINCT device_model) FROM phone_brand_device_model2 WHERE phone_brand = '中兴';"}
{"question_id": 1123, "db_id": "talkingdata", "grading_method": "set", "question": "Provide the number of events that happened on 2016/5/6.", "evidence": "May 6, 2016 refers to the date portion of timestamp being '2016-05-06'; ignore the time of day.", "SQL": "SELECT COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-06'"}
{"question_id": 1154, "db_id": "talkingdata", "grading_method": "set", "question": "Among all users who have at least one event on their device, what are the event IDs that occurred on the device of the oldest user? Please list those event IDs.", "evidence": "oldest user refers to MAX(age);", "SQL": "SELECT T2.event_id FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T1.age = (\nSELECT MAX(T3.age) FROM gender_age AS T3 INNER JOIN events AS T4 ON T3.device_id = T4.device_id)"}
{"question_id": 1190, "db_id": "talkingdata", "grading_method": "set", "question": "What is the average age of users who use the R7 device model?", "evidence": "phone_brand_device_model2.device_model uses 'R7'; gender_age.age records age in years.", "SQL": "SELECT AVG(age) FROM (SELECT age FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'R7' GROUP BY T1.device_id)"}
{"question_id": 1277, "db_id": "law_episode", "grading_method": "set", "question": "How many people gave the most enjoyed episode a 10-star rating?", "evidence": "the most enjoyed refers max(rating); 10-star refers to stars = 10", "SQL": "SELECT SUM(V.`votes`) FROM `Episode` AS E JOIN `Vote`   AS V ON E.`episode_id` = V.`episode_id` WHERE E.`rating` = (SELECT MAX(`rating`) FROM `Episode`) AND V.`stars` = 10;"}
{"question_id": 1290, "db_id": "law_episode", "grading_method": "set", "question": "What is the title of the episode that has the highest number of crews in the Art Department?", "evidence": "the highest number of crews refers to max(count(person_id)); in the Art Department refers to category = 'Art Department'", "SQL": "SELECT E.`title`\nFROM `Episode` AS E\nJOIN `Credit` AS C ON C.`episode_id` = E.`episode_id`\nWHERE C.`category` = 'Art Department'\nGROUP BY E.`episode_id`\nHAVING COUNT(*) = (\n    SELECT MAX(cnt)\n    FROM (\n        SELECT COUNT(*) AS cnt\n        FROM `Credit`\n        WHERE `category` = 'Art Department'\n        GROUP BY `episode_id`\n    )\n);"}
{"question_id": 1308, "db_id": "law_episode", "grading_method": "set", "question": "In which region was the president of NBC West Coast born?", "evidence": "region refers to birth_region; president of NBC West Coast refers to role = 'president of NBC West Coast'", "SQL": "SELECT DISTINCT T2.birth_region FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'president of NBC West Coast'"}
{"question_id": 1387, "db_id": "synthea", "grading_method": "set", "question": "Which patients had allergies that lasted the longest before ending? List their patient IDs.", "evidence": "START and STOP record when an allergy began and ended. Only allergies with a recorded end date are considered. Duration is measured in elapsed days, including all patients tied for the longest duration. Dates use month/day/two-digit-year: 69–99 represent 1969–1999, and 00–68 represent 2000–2068.", "SQL": "WITH parsed AS (\n  SELECT PATIENT,\n         date(printf('%04d-%02d-%02d',\n                     CASE WHEN CAST(substr(START,-2) AS int) > 68\n                          THEN 1900 + CAST(substr(START,-2) AS int)\n                          ELSE 2000 + CAST(substr(START,-2) AS int) END,\n                     CAST(substr(START,1,instr(START,'/')-1) AS int),\n                     CAST(substr(START,instr(START,'/')+1,\n                                  instr(substr(START,instr(START,'/')+1),'/')-1) AS int))) AS start_date,\n         date(printf('%04d-%02d-%02d',\n                     CASE WHEN CAST(substr(STOP,-2) AS int) > 68\n                          THEN 1900 + CAST(substr(STOP,-2) AS int)\n                          ELSE 2000 + CAST(substr(STOP,-2) AS int) END,\n                     CAST(substr(STOP,1,instr(STOP,'/')-1) AS int),\n                     CAST(substr(STOP,instr(STOP,'/')+1,\n                                  instr(substr(STOP,instr(STOP,'/')+1),'/')-1) AS int))) AS stop_date\n  FROM allergies\n  WHERE STOP IS NOT NULL\n),\nspan AS (\n  SELECT PATIENT,\n         julianday(stop_date) - julianday(start_date) AS days_len\n  FROM parsed\n),\nper_patient AS (\n  SELECT PATIENT, MAX(days_len) AS max_len\n  FROM span\n  GROUP BY PATIENT\n)\nSELECT PATIENT\nFROM per_patient\nWHERE max_len = (\n  SELECT MAX(max_len) FROM per_patient);"}
{"question_id": 1395, "db_id": "synthea", "grading_method": "set", "question": "How many of the patients born in 1920s had pneumonia?", "evidence": "patients born in 1920s refer to patient where birthdate like '192%'; pneumonia refers to DESCRIPTION = 'Pneumonia' from conditions;", "SQL": "SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE DESCRIPTION = 'Pneumonia' AND strftime('%Y', T1.birthdate) LIKE '192%'"}
{"question_id": 1406, "db_id": "synthea", "grading_method": "set", "question": "What is the age of the patient with hypertension named Giovanni Russel?", "evidence": "age refers to SUBTRACT(strftime('%Y', deathdate), strftime('%Y', birthdate)); hypertension refers to conditions where DESCRIPTION = 'Hypertension';", "SQL": "SELECT strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) AS age FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Giovanni' AND T2.last = 'Russel' AND T1.DESCRIPTION = 'Hypertension'"}
{"question_id": 1413, "db_id": "synthea", "grading_method": "set", "question": "Who are the patients involved in the care plan with code 315043002? Return their first names and last names.", "evidence": "", "SQL": "SELECT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.CODE = 315043002"}
{"question_id": 1506, "db_id": "synthea", "grading_method": "set", "question": "State the description of the reason why Angelo Buckridge needs the care plan.", "evidence": "description of the reason of the care plan refers to careplans.REASONDESCRIPTION;", "SQL": "SELECT DISTINCT T1.REASONDESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Angelo' AND T2.last = 'Buckridge'"}
{"question_id": 1554, "db_id": "car_retails", "grading_method": "set", "question": "How many customers have a credit limit of 100,000 or less? Among all customers, who paid the most in total during 2004?", "evidence": "Credit limit refers to creditLimit; payment amount refers to amount. The 2004 total includes all payments a customer made that year, regardless of their credit limit.", "SQL": "SELECT (SELECT COUNT(*)\n        FROM `customers`\n        WHERE `creditLimit` <= 100000)                                                   AS customers_with_low_credit,\n       (\n         SELECT c.`customerName`\n         FROM `customers` c\n         JOIN `payments`  p ON c.`customerNumber` = p.`customerNumber`\n         WHERE STRFTIME('%Y', p.`paymentDate`) = '2004'\n         GROUP BY c.`customerNumber`, c.`customerName`\n         ORDER BY SUM(p.`amount`) DESC\n         LIMIT 1\n       )                                                                                 AS top_customer_2004;"}
{"question_id": 1564, "db_id": "car_retails", "grading_method": "set", "question": "How many sales representatives have office code 1?", "evidence": "Sales representatives have employees.jobTitle = 'Sales Rep'.", "SQL": "SELECT COUNT(officeCode) FROM employees WHERE jobTitle = 'Sales Rep' AND officeCode = 1"}
{"question_id": 1565, "db_id": "car_retails", "grading_method": "set", "question": "List the distinct names of customers with a single payment over 50,000.", "evidence": "payments.amount records a payment’s amount; customers.customerName records the customer’s name.", "SQL": "SELECT DISTINCT T2.customerName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.amount > 50000"}
{"question_id": 1593, "db_id": "car_retails", "grading_method": "set", "question": "For customers who made the highest single payment, list each sales agent’s first name and last name, followed by their supervisor’s first name and last name.", "evidence": "Payment refers to payments.amount; highest single payment refers to MAX(amount) across all payments; supervisor refers to employees.reportsTo, which identifies the supervisor's employeeNumber; names are returned as four separate columns in this order: sales agent firstName, sales agent lastName, supervisor firstName, supervisor lastName. Include all matches tied for the highest payment.", "SQL": "SELECT T1.firstName, T1.lastName, T4.firstName, T4.lastName FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN employees AS T4 ON T1.reportsTo = T4.employeeNumber WHERE T3.amount = (SELECT MAX(T3.amount) FROM customers AS T2 INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber);"}
{"question_id": 1600, "db_id": "car_retails", "grading_method": "set", "question": "How many customers with a canceled shipment have a credit limit greater than 115,000?", "evidence": "Cancelled shipment refers to status = 'Cancelled'; credit limit greater than 115,000 refers to creditLimit > 115000.", "SQL": "SELECT COUNT(DISTINCT T1.customerNumber)\nFROM `customers` AS T1\nJOIN `orders`   AS T2 ON T1.customerNumber = T2.customerNumber\nWHERE T2.`status` = 'Cancelled'\n  AND T1.`creditLimit` > 115000;"}
{"question_id": 1627, "db_id": "car_retails", "grading_method": "set", "question": "List all customers whose sales representative is Steve Patterson.", "evidence": "customers.salesRepEmployeeNumber records the assigned sales representative.", "SQL": "SELECT t1.customerName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'Steve' AND t2.lastName = 'Patterson'"}
{"question_id": 1636, "db_id": "car_retails", "grading_method": "set", "question": "When were the products ordered by Cruz & Sons Co. on 2003-03-03 shipped?", "evidence": "Cruz & Sons Co. is name of customer; ordered on 2003-03-03 refers to orderDate;", "SQL": "SELECT t1.shippedDate FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Cruz & Sons Co.' AND t1.orderDate = '2003-03-03'"}
{"question_id": 1649, "db_id": "car_retails", "grading_method": "set", "question": "What percentage of the payment amount in 2004 was made by Atelier graphique?", "evidence": "Payments are recorded in payments.amount and payments.paymentDate. The customer name is customers.customerName; Atelier graphique is stored as 'Atelier graphique'.", "SQL": "SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.paymentDate) = '2004'"}
{"question_id": 1666, "db_id": "car_retails", "grading_method": "set", "question": "Which five products had the fewest units ordered in total? List their names.", "evidence": "ordered quantity in total refers to SUM(quantityOrdered);", "SQL": "SELECT p.productName\nFROM `products` AS p\nLEFT JOIN `orderdetails` AS od ON p.productCode = od.productCode\nGROUP BY p.productCode, p.productName\nORDER BY COALESCE(SUM(od.quantityOrdered), 0) ASC\nLIMIT 5;"}
{"question_id": 1679, "db_id": "restaurant", "grading_method": "set", "question": "What type of food is there in the restaurants on Adeline Street in Berkeley city?", "evidence": "Adeline Street refers to street_name = 'adeline st'; type of food refers to food_type\n\n", "SQL": "SELECT T1.food_type FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.street_name = 'adeline st' AND T2.city = 'berkeley'"}
{"question_id": 1718, "db_id": "restaurant", "grading_method": "set", "question": "What are the names of the least popular Indian restaurants on Shattuck Avenue in Berkeley?", "evidence": "Restaurant name refers to label; least popular means the lowest review among eligible restaurants. All text matching is case-insensitive: city is 'Berkeley', food_type contains 'indian', and street_name starts with 'shattuck ave'.", "SQL": "SELECT T1.`label` FROM `generalinfo` AS T1 JOIN `location` AS T2 ON T1.`id_restaurant` = T2.`id_restaurant` WHERE lower(T1.`city`) = 'berkeley' AND lower(T2.`street_name`) LIKE 'shattuck ave%' AND lower(T1.`food_type`) LIKE '%indian%' AND T1.`review` = ( SELECT MIN(T1.`review`) FROM `generalinfo` AS T1 JOIN `location` AS T2 ON T1.`id_restaurant` = T2.`id_restaurant` WHERE lower(T1.`city`) = 'berkeley' AND lower(T2.`street_name`) LIKE 'shattuck ave%' AND lower(T1.`food_type`) LIKE '%indian%' );"}
{"question_id": 1776, "db_id": "restaurant", "grading_method": "set", "question": "How many Chinese restaurants are there on 1st st, Livermore?", "evidence": "Chinese restaurant refers to food_type = 'chinese'; 1st st refers to street_name = '1st st'; Livermore refers to city = 'livermore'", "SQL": "SELECT COUNT(T1.id_restaurant) FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'livermore' AND T1.food_type = 'chinese' AND T2.street_name = '1st st'"}
{"question_id": 1793, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the bowling skill of SC Ganguly?", "evidence": "SC Ganguly refers to Player_Name = 'SC Ganguly'", "SQL": "SELECT T1.Bowling_Skill FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T2.Bowling_skill = T1.Bowling_Id WHERE T2.Player_Name = 'SC Ganguly'"}
{"question_id": 1795, "db_id": "soccer_2016", "grading_method": "set", "question": "Please list the names of the players who use the right hand as their batting hand and are from Australia.", "evidence": "name of player refers to Player_Name; right hand as batting hand refers to Batting_Hand = 'Right-hand bat'; Australia refers to Country_Name = 'Australia'", "SQL": "SELECT T2.Player_Name FROM Country AS T1 INNER JOIN Player AS T2 ON T2.Country_Name = T1.Country_id INNER JOIN Batting_Style AS T3 ON T2.Batting_hand = T3.Batting_Id WHERE T1.Country_Name = 'Australia' AND T3.Batting_Hand = 'Right-hand bat'"}
{"question_id": 1847, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the total number of won matches of the team named \"Pune Warriors\"?", "evidence": "the team named \"Pune Warriors\" refers to Team_Name = 'Pune Warriors'; the total number of won matches = count(Team_Name where Team_Id = Match_Winner)", "SQL": "SELECT SUM(CASE WHEN T2.Team_Name = 'Pune Warriors' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner"}
{"question_id": 1886, "db_id": "soccer_2016", "grading_method": "set", "question": "List down all of the winning teams' IDs that played in St George's Park.", "evidence": "winning teams' refers to Match_Winner; played in St George's Park refers to Venue_Name like 'St George%'", "SQL": "SELECT DISTINCT M.`Match_Winner`\nFROM `Match` AS M\nJOIN `Venue` AS V ON V.`Venue_Id` = M.`Venue_Id`\nWHERE V.`Venue_Name` LIKE 'St George%';"}
{"question_id": 1892, "db_id": "soccer_2016", "grading_method": "set", "question": "What are the average extra runs given in the second innings of each match? List each match ID and the average extra runs recorded for its second innings. Include every match, and report zero when no average is available.", "evidence": "Extra_Runs.Extra_Runs records extra runs; Extra_Runs.Innings_No = 2 denotes the second innings. Match.Match_Id identifies a match.", "SQL": "SELECT m.`Match_Id`,\n       COALESCE(AVG(er.`Extra_Runs`), 0) AS avg_extra_runs\nFROM `Match` AS m\nLEFT JOIN `Extra_Runs` AS er\n  ON er.`Match_Id` = m.`Match_Id` AND er.`Innings_No` = 2\nGROUP BY m.`Match_Id`;"}
{"question_id": 1922, "db_id": "soccer_2016", "grading_method": "set", "question": "List the names of all New Zealand umpires.", "evidence": "Country.Country_Name uses 'New Zealand'; Umpire.Umpire_Name records the umpire’s name.", "SQL": "SELECT T1.Umpire_Name FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'New Zealand'"}
{"question_id": 1934, "db_id": "soccer_2016", "grading_method": "set", "question": "Give me the match ID and date of the matches that were held in Kingsmead for three consecutive days.", "evidence": "date of the matches refers to Match_Date; held in Kingsmead refers to Venue_Name = 'Kingsmead'", "SQL": "WITH kingsmead_matches AS ( SELECT M.Match_Id, M.Match_Date FROM `Match` M JOIN `Venue` V ON M.`Venue_Id` = V.`Venue_Id` WHERE V.`Venue_Name` = 'Kingsmead' ), unique_dates AS ( SELECT DISTINCT `Match_Date` FROM kingsmead_matches ), ordered AS ( SELECT `Match_Date`, ROW_NUMBER() OVER (ORDER BY `Match_Date`) AS rn FROM unique_dates ), seq_marker AS ( SELECT `Match_Date`, DATE(`Match_Date`, '-' || rn || ' day') AS grp FROM ordered ), valid_groups AS (SELECT grp FROM seq_marker GROUP BY grp HAVING COUNT(*) >= 3 ), wanted_dates AS ( SELECT `Match_Date` FROM seq_marker WHERE grp IN (SELECT grp FROM valid_groups) ) SELECT km.`Match_Id`, km.`Match_Date` FROM kingsmead_matches km WHERE km.`Match_Date` IN (SELECT `Match_Date` FROM wanted_dates) ORDER BY km.`Match_Date`, km.`Match_Id`;"}
{"question_id": 1955, "db_id": "soccer_2016", "grading_method": "set", "question": "How many cities are in U.A.E?", "evidence": "U.A.E refers to Country_Name = 'U.A.E'", "SQL": "SELECT SUM(CASE WHEN T2.Country_Name = 'U.A.E' THEN 1 ELSE 0 END) FROM City AS T1 INNER JOIN country AS T2 ON T1.Country_id = T2.Country_id"}
{"question_id": 1957, "db_id": "soccer_2016", "grading_method": "set", "question": "How many players bowl in the legbreak style?", "evidence": "legbreak style refers to Bowling_skill = 'Legbreak'", "SQL": "SELECT COUNT(*) AS Num_players FROM `Player` AS P JOIN `Bowling_Style` AS B ON P.`Bowling_skill` = B.`Bowling_Id` WHERE B.`Bowling_skill` = 'Legbreak';"}
{"question_id": 1963, "db_id": "soccer_2016", "grading_method": "set", "question": "Who are the youngest players to have won the Purple Cap? List their names", "evidence": "Who refers to Player_Name; youngest player to have won the Purple Cap refers to min(subtract(Season_Year, DOB))", "SQL": "WITH winner_age AS ( SELECT p.Player_Name, (s.Season_Year - CAST(strftime('%Y', p.DOB) AS INT)) AS age FROM   Player  p JOIN   Season  s ON p.Player_Id = s.Purple_Cap ) SELECT Player_Name FROM   winner_age WHERE  age = (SELECT MIN(age) FROM winner_age);"}
{"question_id": 1997, "db_id": "soccer_2016", "grading_method": "set", "question": "What are the names of the second teams in matches tied for the lowest recorded winning margin?", "evidence": "Match.Win_Margin records the winning margin; Match.Team_2 identifies the second team and Team.Team_Name records its name.", "SQL": "SELECT `Team`.`Team_Name`\nFROM `Match`\nJOIN `Team` ON `Team`.`Team_Id` = `Match`.`Team_2`\nWHERE `Match`.`Win_Margin` = (SELECT MIN(`Win_Margin`) FROM `Match` WHERE `Win_Margin` IS NOT NULL)"}
{"question_id": 2008, "db_id": "soccer_2016", "grading_method": "set", "question": "List the names of players who bat left-handed.", "evidence": "Batting_Style.Batting_hand = 'Left-hand bat' denotes left-handed batting; Player.Batting_hand identifies that style.", "SQL": "SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id WHERE T2.Batting_hand = 'Left-hand bat'"}
{"question_id": 2051, "db_id": "music_tracker", "grading_method": "set", "question": "What are the tags of the top 5 least downloaded live albums?", "evidence": "Live albums are marked 'live album' in releaseType. An album’s snatch count is recorded in totalSnatched, and its tags are recorded in tags.", "SQL": "WITH least5 AS (\n    SELECT `id`\n    FROM `torrents`\n    WHERE `releaseType` = 'live album'\n    ORDER BY `totalSnatched` ASC\n    LIMIT 5\n)\nSELECT DISTINCT `tag`\nFROM `tags`\nWHERE `id` IN (SELECT `id` FROM least5);"}
{"question_id": 2057, "db_id": "music_tracker", "grading_method": "set", "question": "How many tags does the release \"city funk\" have?", "evidence": "release \"city funk\" refers to groupName = 'city funk';", "SQL": "SELECT COUNT(DISTINCT T2.tag) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.groupName = 'city funk'"}
{"question_id": 2110, "db_id": "world_development_indicators", "grading_method": "set", "question": "List down the series codes in which the topic is about Environment: Emissions and the license type is restricted.", "evidence": "", "SQL": "SELECT SeriesCode FROM Series WHERE Topic = 'Environment: Emissions' AND LicenseType = 'Restricted'"}
{"question_id": 2114, "db_id": "world_development_indicators", "grading_method": "set", "question": "Please write down the footnote descriptions of Albania in 1981.", "evidence": "Albania refers to Country.ShortName = 'Albania'; 1981 refers to FootNotes.Year = 'YR1981'. Match CountryCode to obtain the footnote descriptions.", "SQL": "SELECT DISTINCT T1.Description FROM FootNotes AS T1 INNER JOIN Country AS T2 ON T1.Countrycode = T2.CountryCode WHERE T1.Year = 'YR1981' AND T2.ShortName = 'Albania'"}
{"question_id": 2131, "db_id": "world_development_indicators", "grading_method": "set", "question": "List the country code of the upper middle income country which has the lowest value of CO2 emissions (kt).", "evidence": "IncomeGroup = 'Upper middle income'; IndicatorName = 'CO2 emissions (kt)'; the lowest value refers to MIN(Value);", "SQL": "SELECT DISTINCT T1.CountryCode \nFROM Country AS T1 \nINNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode \nWHERE T1.IncomeGroup = 'Upper middle income' AND T2.IndicatorName = 'CO2 emissions (kt)' \nAND T2.Value = (\n  SELECT MIN(T4.Value)\n  FROM Country AS T3\n  INNER JOIN Indicators AS T4 ON T3.CountryCode=T4.CountryCode\n  WHERE T3.IncomeGroup = 'Upper middle income' AND T4.IndicatorName = 'CO2 emissions (kt)' \n  ORDER BY T4.Value ASC LIMIT 1)"}
{"question_id": 2135, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which series have indicator observations recorded in 2005 and use the source International Monetary Fund, Balance of Payments Statistics Yearbook and data files? List their series codes.", "evidence": "Recorded in 2005 refers to Indicators.Year = 2005. Match Indicators.IndicatorCode to Series.SeriesCode. Use Series.Source beginning with 'International Monetary Fund, Balance of Payments Statistics Yearbook and data files'.", "SQL": "SELECT DISTINCT s.SeriesCode\nFROM Series s\nJOIN Indicators i ON i.IndicatorCode = s.SeriesCode\nWHERE s.Source LIKE 'International Monetary Fund, Balance of Payments Statistics Yearbook and data files%'\n  AND i.Year = 2005;"}
{"question_id": 2141, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which indicators with an Open license had at least one value below 100 from 1968 through 1970?", "evidence": "Series.LicenseType uses 'Open'. Indicators.Value records observations in each indicator’s own units.", "SQL": "SELECT DISTINCT i.`IndicatorName`\nFROM `Indicators` i\nJOIN `Series`  s ON i.`IndicatorCode` = s.`SeriesCode`\nWHERE i.`Year` BETWEEN 1968 AND 1970\n  AND s.`LicenseType` = 'Open'\n  AND i.`Value` < 100;"}
{"question_id": 2142, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which countries have the highest recorded value for an indicator in the Private Sector & Trade: Exports topic? List each country's name and the indicator name, including ties.", "evidence": "Country refers to an individual World Bank economy, including separately reported territories. Country entries with a nonblank Region are economies; entries with a blank Region are aggregate groups. Use Indicators.CountryName and Indicators.IndicatorName. Restrict the topic to Private Sector & Trade: Exports, find the greatest nonmissing recorded value, and include every matching country/indicator pair.", "SQL": "WITH ranked AS (\n  SELECT i.CountryName, i.IndicatorName,\n         RANK() OVER (ORDER BY i.Value DESC) AS value_rank\n  FROM Indicators AS i\n  JOIN Country AS c ON c.CountryCode = i.CountryCode\n  JOIN Series AS s ON s.IndicatorName = i.IndicatorName\n  WHERE s.Topic = 'Private Sector & Trade: Exports'\n    AND TRIM(COALESCE(c.Region, '')) <> ''\n    AND i.Value IS NOT NULL\n)\nSELECT CountryName, IndicatorName\nFROM ranked\nWHERE value_rank = 1;"}
{"question_id": 2165, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which high-income countries are in East Asia & Pacific? List their country codes.", "evidence": "Country.IncomeGroup uses 'High income: OECD' and 'High income: nonOECD' for high income; Country.Region uses 'East Asia & Pacific'.", "SQL": "SELECT CountryCode FROM Country WHERE (IncomeGroup = 'High income: OECD' OR IncomeGroup = 'High income: nonOECD') AND Region = 'East Asia & Pacific'"}
{"question_id": 2196, "db_id": "world_development_indicators", "grading_method": "subset,=,3", "question": "Please list the short names of any 3 countries that use U.S. dollar.", "evidence": "country.currencyunit = 'U.S. dollar' identifies the currency; country.ShortName records the country name.", "SQL": "SELECT ShortName FROM country WHERE currencyunit = 'U.S. dollar'"}
{"question_id": 2213, "db_id": "world_development_indicators", "grading_method": "set", "question": "How many countries have a footnote described as \"Not specified\"?", "evidence": "Footnotes.Description = 'Not specified' denotes an unspecified footnote.", "SQL": "SELECT COUNT(DISTINCT T1.CountryCode)  FROM Country AS T1 INNER JOIN Footnotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Description = 'Not specified'"}
{"question_id": 2246, "db_id": "world_development_indicators", "grading_method": "set", "question": "What was the average adolescent fertility rate in the country whose Alpha2Code is 1A?", "evidence": "Indicators.IndicatorName uses 'Adolescent fertility rate (births per 1,000 women ages 15-19)'; Indicators.Value records that rate. Country.Alpha2Code records the two-character code.", "SQL": "SELECT CAST(SUM(T2.Value) AS REAL) / COUNT(T2.Year) FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.Alpha2Code = '1A' AND T2.IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)'"}
{"question_id": 2299, "db_id": "movielens", "grading_method": "set", "question": "List all of the user ids and ages who rated movies with the id 1695219?", "evidence": "", "SQL": "SELECT T2.userid, T2.age FROM u2base AS T1 INNER JOIN users AS T2 ON T1.userid = T2.userid WHERE T1.movieid = 1695219"}
{"question_id": 2315, "db_id": "movielens", "grading_method": "set", "question": "What percentage of American movies received at least one 1-star rating?", "evidence": "American movies have country = 'USA'. User ratings are recorded in u2base.rating, where 1 represents one star.", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN u.`rating` = 1 THEN m.`movieid` END) /\n       (SELECT COUNT(*) FROM `movies` WHERE `country` = 'USA') AS neg_crit_pct\nFROM `movies` m\nINNER JOIN `u2base` u ON u.`movieid` = m.`movieid`\nWHERE m.`country` = 'USA';"}
{"question_id": 2337, "db_id": "movielens", "grading_method": "set", "question": "What is the total number of movies directed by directors whose quality and revenue are both 4?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT `m2d`.`movieid`) AS `total_movies` FROM `directors` AS `d` JOIN `movies2directors` AS `m2d` ON `d`.`directorid` = `m2d`.`directorid` WHERE `d`.`d_quality` = 4 AND `d`.`avg_revenue` = 4"}
{"question_id": 2385, "db_id": "superstore", "grading_method": "set", "question": "Which customer in the East region placed the most profitable order?", "evidence": "East refers to the order’s region. Profit records each line item’s profit; an order’s profit is the combined profit of all its line items. Customer names are recorded in Customer Name.", "SQL": "SELECT p.`Customer Name`\nFROM (\n     SELECT `Order ID`,\n            `Customer ID`,\n            SUM(`Profit`) AS total_profit\n     FROM `east_superstore`\n     GROUP BY `Order ID`, `Customer ID`\n     ORDER BY total_profit DESC\n     LIMIT 1\n) o\nJOIN `people` p\n  ON p.`Customer ID` = o.`Customer ID`\n AND p.`Region` = 'East';"}
{"question_id": 2440, "db_id": "superstore", "grading_method": "set", "question": "Which orders from customers in Houston, Texas, have the highest total profit in the Central superstore? List their order IDs.", "evidence": "Houston, Texas refers to City = 'Houston' and State = 'Texas'; total order profit is SUM(Profit) grouped by Order ID; return the order IDs whose total profit equals the highest total order profit, including all ties.", "SQL": "WITH order_profit AS (\n  SELECT T1.`Order ID`, SUM(T1.`Profit`) AS total_profit\n  FROM `central_superstore` AS T1\n  JOIN `people` AS T2\n    ON T1.`Customer ID` = T2.`Customer ID` AND T2.Region = T1.Region\n  WHERE T2.`City`  = 'Houston'\n    AND T2.`State` = 'Texas'\n  GROUP BY T1.`Order ID`\n) SELECT `Order ID`\nFROM order_profit\nWHERE total_profit = (SELECT MAX(total_profit) FROM order_profit);"}
{"question_id": 2456, "db_id": "superstore", "grading_method": "set", "question": "Provide the name of the product with the highest total sales in the South region.", "evidence": "south_superstore.Sales records sales amounts; product.\"Product Name\" records product names. Product identifiers are region-specific.", "SQL": "SELECT p.`Product Name`\nFROM south_superstore s\nJOIN product p\n  ON s.`Product ID` = p.`Product ID` AND p.`Region` = 'South'\nGROUP BY s.`Product ID`\nHAVING SUM(s.`Sales`) = (\n  SELECT SUM(s1.Sales)\n  FROM south_superstore s1\n  JOIN product p1\n    ON s1.`Product ID` = p1.`Product ID` AND p1.`Region` = 'South'\n  GROUP BY s1.`Product ID`\n  ORDER BY SUM(s1.Sales) DESC LIMIT 1)"}
{"question_id": 2531, "db_id": "app_store", "grading_method": "set", "question": "What is the rating for \"Draw A Stickman\"?", "evidence": "Draw A Stickman refers to App = 'Draw A Stickman';", "SQL": "SELECT Rating FROM playstore WHERE APP = 'Draw A Stickman'"}
{"question_id": 2539, "db_id": "app_store", "grading_method": "set", "question": "What are the content ratings for the apps that have \"gr8\" in their comments?", "evidence": "app with gr8 in their comments refers to Translated_Review LIKE '%gr8%';", "SQL": "SELECT DISTINCT T1.`Content Rating` FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T2.Translated_Review LIKE '%gr8%'"}
{"question_id": 2540, "db_id": "app_store", "grading_method": "set", "question": "What is the total Sentiment polarity score of the most expensive app that has at least one user review?", "evidence": "total sentiment polarity score = sum(Sentiment_Polarity); most expensive app refers to MAX(Price);", "SQL": "SELECT SUM(CAST(ur.`Sentiment_Polarity` AS REAL)) AS total_polarity\nFROM `user_reviews` ur\nJOIN `playstore` p ON ur.`App` = p.`App`\nWHERE CAST(REPLACE(p.`Price`, '$', '') AS REAL) = (\n      SELECT MAX(CAST(REPLACE(`Price`, '$', '') AS REAL))\n      FROM `playstore` p WHERE p.App in (SELECT App FROM user_reviews));"}
{"question_id": 2543, "db_id": "app_store", "grading_method": "set", "question": "Show the comments for the highest-rated apps that are suitable for everyone and have at least one written review.", "evidence": "Everyone refers to Content Rating = 'Everyone'. Overall user ratings are recorded in playstore.Rating; written reviews are recorded in user_reviews.Translated_Review. NULL, blank text, and the literal 'nan' indicate no written review.", "SQL": "WITH written_reviews AS (\n    SELECT App, Translated_Review\n    FROM user_reviews\n    WHERE Translated_Review IS NOT NULL\n      AND TRIM(Translated_Review) <> ''\n      AND Translated_Review <> 'nan'\n), max_rating AS (\n    SELECT MAX(p.`Rating`) AS r\n    FROM `playstore` AS p\n    INNER JOIN written_reviews AS u ON p.App = u.App\n    WHERE p.`Content Rating` = 'Everyone'\n      AND p.`Rating` IS NOT NULL\n)\nSELECT u.Translated_Review\nFROM `playstore` AS p\nINNER JOIN max_rating AS m ON p.`Rating` = m.r\nINNER JOIN written_reviews AS u ON u.App = p.App\nWHERE p.`Content Rating` = 'Everyone'"}
{"question_id": 2546, "db_id": "app_store", "grading_method": "set", "question": "Among apps with at least one billion installs, which has the most reviews without a comment?", "evidence": "At least one billion installs refers to Installs = '1,000,000,000+'. A review has no comment if Translated_Review is 'nan' or NULL, or Sentiment is 'nan'.", "SQL": "SELECT T1.App FROM user_reviews AS T1 WHERE (T1.Translated_Review = 'nan' OR T1.Translated_Review IS NULL OR T1.Sentiment = 'nan') AND EXISTS (SELECT 1 FROM playstore AS T2 WHERE T2.App = T1.App AND T2.Installs = '1,000,000,000+') GROUP BY T1.App ORDER BY COUNT(*) DESC LIMIT 1"}
{"question_id": 2554, "db_id": "app_store", "grading_method": "set", "question": "What is the average number of reviews for apps with a rating of 5?", "evidence": "playstore.Reviews is the recorded number of user reviews; Rating is the app’s overall rating when scraped.", "SQL": "SELECT AVG(Reviews) FROM playstore WHERE Rating = 5"}
{"question_id": 2588, "db_id": "regional_sales", "grading_method": "set", "question": "State the order number and calculate the net profit for each order under Joshua Bennett.", "evidence": "For this task, net profit means the per-unit difference between Sales Orders.\"Unit Price\" and \"Unit Cost\". These values may contain thousands-separator commas. Joshua Bennett is recorded in Sales Team.\"Sales Team\".", "SQL": "SELECT T1.OrderNumber , REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')  FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.`Sales Team` = 'Joshua Bennett'"}
{"question_id": 2591, "db_id": "regional_sales", "grading_method": "set", "question": "List down the product IDs and names that include the word \"Outdoor\".", "evidence": "names that include the word \"Outdoor\" refer to Product Name LIKE '%Outdoor%';", "SQL": "SELECT ProductID, T FROM ( SELECT ProductID , CASE  WHEN `Product Name` LIKE '%Outdoor%' THEN `Product Name` ELSE NULL END AS T FROM Products ) WHERE T IS NOT NULL ORDER BY T DESC"}
{"question_id": 2599, "db_id": "regional_sales", "grading_method": "set", "question": "List the customer names for customers with at least one order whose net profit exceeded 3,800 USD.", "evidence": "Sales Orders.\"Unit Price\" and \"Unit Cost\" record per-unit amounts with thousands-separator commas; \"Order Quantity\" records units ordered. Order net profit is the price–cost difference for those units.", "SQL": " SELECT DISTINCT c.`Customer Names`\nFROM `Sales Orders` s\nJOIN Customers c ON c.`CustomerID` = s.`_CustomerID`\nWHERE (CAST(REPLACE(s.`Unit Price`, ',', '') AS REAL) -\n       CAST(REPLACE(s.`Unit Cost`,  ',', '') AS REAL)) * s.`Order Quantity` > 3800;"}
{"question_id": 2610, "db_id": "regional_sales", "grading_method": "set", "question": "List the product name for the order with a unit cost of 781.22.", "evidence": "Sales Orders.\"Unit Cost\" identifies the order line with a unit cost of 781.22; Products.\"Product Name\" records the product name.", "SQL": "SELECT T FROM ( SELECT DISTINCT IIF(T1.`Unit Cost` = 781.22, T2.`Product Name`, NULL) AS T FROM `Sales Orders` T1 INNER JOIN Products T2 ON T2.ProductID = T1._ProductID ) WHERE T IS NOT NULL"}
{"question_id": 2640, "db_id": "regional_sales", "grading_method": "set", "question": "List the names of customers with more than three orders in 2018.", "evidence": "Sales Orders.OrderDate uses month/day/two-digit-year dates. Customer names are recorded in Customers.\"Customer Names\".", "SQL": "SELECT C.`Customer Names`\nFROM `Sales Orders` AS S\nJOIN Customers AS C ON C.`CustomerID` = S.`_CustomerID`\nWHERE substr(S.`OrderDate`, -2) = '18'\nGROUP BY S.`_CustomerID`\nHAVING COUNT(*) > 3;"}
{"question_id": 2682, "db_id": "regional_sales", "grading_method": "set", "question": "In which regions are the stores that have shipped products through the WARE-UHY1004 warehouse?", "evidence": "\"WARE-UHY1004\" is the WarehouseCode", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE  WHEN T3.WarehouseCode = 'WARE-UHY1004' THEN T1.Region END AS T FROM Regions T1 INNER JOIN `Store Locations` T2 ON T2.StateCode = T1.StateCode INNER JOIN `Sales Orders` T3 ON T3._StoreID = T2.StoreID ) WHERE T IS NOT NULL"}
{"question_id": 2687, "db_id": "regional_sales", "grading_method": "set", "question": "List the 5 sales teams that have made sales with the highest net profits.", "evidence": "highest net profit = Max(SUM(Subtract (Unit Price, Unit Cost)*Quantity))", "SQL": "SELECT st.`Sales Team`\nFROM `Sales Orders` so\nJOIN `Sales Team` st ON st.`SalesTeamID` = so.`_SalesTeamID`\nGROUP BY st.`SalesTeamID`\nORDER BY SUM((CAST(REPLACE(so.`Unit Price`, ',', '') AS REAL) - CAST(REPLACE(so.`Unit Cost`, ',', '') AS REAL)) * so.`Order Quantity`) DESC\nLIMIT 5;"}
{"question_id": 2693, "db_id": "regional_sales", "grading_method": "set", "question": "How many online purchases did Ole Group make in May 2019?", "evidence": "\"Ole Group\" is the Customer Names; online purchase refers to Sales Channel = 'Online'; made in May 2019 refers to OrderDate LIKE '5/%/19'", "SQL": "SELECT SUM(CASE WHEN T1.`Sales Channel` = 'Online' AND T2.`Customer Names` = 'Ole Group' AND T1.OrderDate LIKE '5/%/19' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID"}
{"question_id": 2754, "db_id": "european_football_1", "grading_method": "set", "question": "Across all divisions in 2010, what was the home-win percentage minus the away-win percentage, in percentage points?", "evidence": "matchs.season records the season year. matchs.FTR uses 'H' for a home win and 'A' for an away win.", "SQL": "SELECT CAST(COUNT(CASE WHEN FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(FTR) - CAST(COUNT(CASE WHEN FTR = 'A' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(FTR) DIFFERENCE FROM matchs WHERE season = 2010"}
{"question_id": 2764, "db_id": "european_football_1", "grading_method": "set", "question": "In how many matches in the Seria A division did both teams have equal goals?", "evidence": "Seria A is a name of division; equal goals refers to FTR = 'D', where D stands for draft;", "SQL": "SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Seria A' AND T1.FTR = 'D'"}
{"question_id": 2775, "db_id": "european_football_1", "grading_method": "set", "question": "Which division had the most games with more than 4 total field goals on 2020/2/22? Give the full name of the division?", "evidence": "more than 4 total field goals refers to SUM(FTHG, FTAG)>4, which are short names for Final-time Home-team Goals and Final-time Away-team Goals; 2020/2/22 is a date;", "SQL": "SELECT d.`name`\nFROM divisions d\nJOIN (\n    SELECT `Div`, COUNT(*) AS cnt\n    FROM matchs\n    WHERE `Date` = '2020-02-22'\n      AND (`FTHG` + `FTAG`) > 4\n    GROUP BY `Div`\n) t ON d.`division` = t.`Div`\nORDER BY t.cnt DESC, d.`division`\nLIMIT 1;"}
{"question_id": 2794, "db_id": "european_football_1", "grading_method": "set", "question": "What was the total number of final home-team goals in Bundesliga matches during the 2021 season?", "evidence": "matchs.FTHG records full-time home-team goals; matchs.season records the season. Bundesliga is recorded in divisions.name as 'Bundesliga'.", "SQL": "SELECT SUM(T1.FTHG) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.season = 2021"}
{"question_id": 2802, "db_id": "professional_basketball", "grading_method": "set", "question": "Who is the longest serving coach from year 1970 to 1980. List the coach ID and the team(s) he served.", "evidence": "1970 to 1980 refers to year between 1970 and 1980; longest serving coach means the maximum number of distinct years coached; list teams refers to GROUP_CONCAT(DISTINCT tmID)", "SQL": "WITH coach_years AS (\n  SELECT `coachID`, COUNT(DISTINCT `year`) AS yrs\n  FROM `coaches`\n  WHERE `year` BETWEEN 1970 AND 1980\n  GROUP BY `coachID`\n), max_yrs AS (\n  SELECT MAX(yrs) AS max_yrs FROM coach_years\n)\nSELECT c.`coachID`, GROUP_CONCAT(DISTINCT t.`tmID`) AS teams\nFROM coach_years c\nJOIN max_yrs m ON c.yrs = m.max_yrs\nJOIN coaches t ON t.`coachID` = c.`coachID` AND t.`year` BETWEEN 1970 AND 1980\nGROUP BY c.`coachID`;"}
{"question_id": 2843, "db_id": "professional_basketball", "grading_method": "set", "question": "From 1962 to 2011, how many coaches received both NBA and ABA awards?", "evidence": "coachID identifies a coach. NBA and ABA awards have award values beginning with 'NBA' and 'ABA', respectively. A qualifying coach received at least one award from each league between 1962 and 2011, inclusive.", "SQL": "SELECT COUNT(DISTINCT coachID) FROM awards_coaches WHERE year BETWEEN 1962 AND 2011 AND award LIKE 'ABA%' AND coachID IN ( SELECT coachID FROM awards_coaches WHERE year BETWEEN 1962 AND 2011 AND award LIKE 'NBA%' )"}
{"question_id": 2849, "db_id": "professional_basketball", "grading_method": "set", "question": "Among players born after 1950, whose offensive rebounds account for more than 30% of their total rebounds across all seasons recorded? List their last and first names.", "evidence": "born after 1950 refers to birthDate > '1950-12-31'; for each player, sum oRebounds and rebounds across all recorded players_teams rows with rebounds > 0; offensive rebound rate more than 30% refers to 1.0 * SUM(oRebounds) / SUM(rebounds) > 0.3.", "SQL": "WITH per_player AS (\n    SELECT p.playerID,\n           p.lastName,\n           p.firstName,\n           SUM(pt.oRebounds) AS oReb,\n           SUM(pt.rebounds)  AS totReb\n    FROM players p\n    JOIN players_teams pt ON p.playerID = pt.playerID\n    WHERE p.birthDate > '1950-12-31'\n      AND pt.rebounds IS NOT NULL\n      AND pt.rebounds > 0\n    GROUP BY p.playerID\n)\nSELECT lastName, firstName\nFROM   per_player\nWHERE  1.0 * oReb / totReb > 0.30;"}
{"question_id": 2867, "db_id": "professional_basketball", "grading_method": "set", "question": "What is the full name of the team with the fastest growth in winning rate in the 'ABA' league from 1972 to 1973?", "evidence": "\"ABA\" is the lgID; from 1972 to 1973 refers to year = 1972 and year = 1973; team with the fastest growth in winning rate = Max(Subtract(Divide(won where year = 1973, Sum(won, lost)),Divide(won where year = 1972, Sum(won, lost))))", "SQL": "SELECT T1.name FROM teams AS T1 INNER JOIN ( SELECT * FROM teams WHERE lgID = 'ABA' AND year = 1972 ) AS T2 ON T1.tmID = T2.tmID WHERE T1.lgID = 'ABA' AND T1.year = 1973 ORDER BY (CAST(T1.won AS REAL) / (T1.won + T1.lost) - (CAST(T2.won AS REAL) / (T2.won + T2.lost))) DESC LIMIT 1"}
{"question_id": 2927, "db_id": "professional_basketball", "grading_method": "set", "question": "How many turnovers per game did the assist champion have in the 2003 NBA season?", "evidence": "turnovers per game = SUM(turnovers)/SUM(GP); the assist champion is the player with highest SUM(assists)/SUM(GP) in the 2003 NBA season; 2003 refers to year = 2003; NBA refers to lgID = 'NBA'", "SQL": "WITH assist_leader AS ( SELECT `playerID`, 1.0*SUM(`assists`)/SUM(`GP`) AS apg FROM `players_teams` WHERE `year` = 2003 AND `lgID` = 'NBA' GROUP BY `playerID` ORDER BY apg DESC LIMIT 1 ) SELECT 1.0*SUM(pt.`turnovers`)/SUM(pt.`GP`) AS turnovers_per_game FROM `players_teams` pt JOIN assist_leader al ON pt.`playerID` = al.`playerID` WHERE pt.`year` = 2003 AND pt.`lgID` = 'NBA'"}
{"question_id": 2939, "db_id": "professional_basketball", "grading_method": "set", "question": "In the year 1998, how many home wins did the team which had the 1st round, 12th pick have that year?", "evidence": "in 1998 refers to year = 1998; 1st round refers to draftRound = 1; 12th pick refers to draftSelection = 12; home win refers to homeWon", "SQL": "SELECT T2.homeWon FROM draft AS T1 INNER JOIN teams AS T2 ON T1.tmID = T2.tmID AND T1.draftYear = T2.year WHERE T1.draftRound = 1 AND T1.draftSelection = 12 AND T1.draftYear = 1998"}
{"question_id": 3030, "db_id": "shakespeare", "grading_method": "set", "question": "From 1593 onwards, what is the difference between the number of comedy works and history works?", "evidence": "From 1593 onwards refers to Date >= 1593; comedy works and history works refer to GenreType = 'Comedy' and GenreType = 'History', respectively.", "SQL": "SELECT SUM(IIF(GenreType = 'Comedy', 1, 0)) - SUM(IIF(GenreType = 'History', 1, 0)) FROM works WHERE Date >= 1593"}
{"question_id": 3046, "db_id": "shakespeare", "grading_method": "set", "question": "How many of the works of Shakespeare are Tragedy?", "evidence": "Tragedy refers to GenreType = 'Tragedy'", "SQL": "SELECT COUNT(id) FROM works WHERE GenreType = 'Tragedy'"}
{"question_id": 3104, "db_id": "cars", "grading_method": "set", "question": "What percentage of cars with a sweep volume of at least 30 were produced by Japan?", "evidence": "Engine displacement is data.displacement and cylinder count is data.cylinders; sweep volume is displacement divided by cylinders. Production country is country.country, linked through production.country; Japan is stored as 'Japan'.", "SQL": "WITH eligible AS (\n    SELECT DISTINCT d.ID\n    FROM data d\n    WHERE d.displacement / d.cylinders >= 30\n),\njapan AS (\n    SELECT DISTINCT e.ID\n    FROM eligible e\n    JOIN production p ON p.ID = e.ID\n    JOIN country    c ON c.origin = p.country\n    WHERE c.country = 'Japan'\n)\nSELECT 100.0 * (SELECT COUNT(*) FROM japan)\n              / (SELECT COUNT(*) FROM eligible) AS percentage;"}
{"question_id": 3115, "db_id": "cars", "grading_method": "set", "question": "How many cars worth greater than 40000 were from the USA?", "evidence": "worth greater than 40000 refers to price > 40000; from the USA refers to country = 'USA'", "SQL": "SELECT COUNT(DISTINCT T1.ID)\nFROM `price` AS T1\nJOIN `production` AS T2 ON T1.ID = T2.ID\nJOIN `country`  AS T3 ON T3.origin = T2.country\nWHERE T3.`country` = 'USA'\n  AND T1.`price` > 40000;"}
{"question_id": 3133, "db_id": "cars", "grading_method": "set", "question": "What is the average price of model 70 cars?", "evidence": "model 70 refers to model = 70; average price = avg(price) where model = 70", "SQL": "SELECT AVG(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.model = 70"}
{"question_id": 3140, "db_id": "cars", "grading_method": "set", "question": "How many Japanese cars weigh more than 2000 lbs?", "evidence": "Japanese car refers to country = 'Japan'; weigh more than 2000 lbs refers to weight > 2000", "SQL": "SELECT COUNT(DISTINCT T1.ID) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T3.country = 'Japan' AND T1.weight > 2000"}
{"question_id": 3163, "db_id": "donor", "grading_method": "set", "question": "How many schools in the West New York School District have the highest poverty level?", "evidence": "the highest poverty level refers to poverty_level = 'highest poverty'", "SQL": "SELECT COUNT(DISTINCT `schoolid`) AS num_schools\nFROM `projects`\nWHERE `school_district` = 'West New York School District'\n  AND `poverty_level` = 'highest poverty';"}
{"question_id": 3164, "db_id": "donor", "grading_method": "set", "question": "How many donations from teachers were done in the state of Colorado?", "evidence": "from teachers refers to is_teacher_acct = 't'; the state of Colorado refers to donor_state = 'CO'", "SQL": "SELECT COUNT(donationid) FROM donations WHERE is_teacher_acct = 't' AND donor_state = 'CO'"}
{"question_id": 3172, "db_id": "donor", "grading_method": "set", "question": "What is the total amount of all the donations made by the donor who made the highest donation in a single amount?", "evidence": "total amount of all the donations refers to sum(donation_total); highest donation refers to max(donation_total)", "SQL": "WITH max_single AS (\n    SELECT donor_acctid,\n           donation_total AS max_donation,\n           projectid\n    FROM donations\n    WHERE donation_total = (SELECT MAX(donation_total) FROM donations)\n) SELECT \n           SUM(donation_total) AS total_amount\n    FROM donations\n    WHERE donor_acctid IN (SELECT donor_acctid FROM max_single)\n    GROUP BY donor_acctid"}
{"question_id": 3174, "db_id": "donor", "grading_method": "set", "question": "When was the first ever project went live on the site?", "evidence": "first ever project refers to min(date_posted);", "SQL": "SELECT MIN(`date_posted`) FROM `projects`"}
{"question_id": 3193, "db_id": "donor", "grading_method": "set", "question": "Please list the types of resources that the vendor Lakeshore Learning Materials has provided for the projects.", "evidence": "Lakeshore Learning Materials is vendor_name; type of resources refers to project_resource_type;", "SQL": "SELECT DISTINCT project_resource_type FROM resources WHERE vendor_name = 'Lakeshore Learning Materials'"}
{"question_id": 3224, "db_id": "donor", "grading_method": "set", "question": "Of the schools that received donations from teachers, what percentage are in Brooklyn, NY?", "evidence": "projects.school_city records the school's city; projects.school_state = 'NY' denotes New York. Stored city names may vary in capitalization or contain surrounding spaces. Teacher donors have donations.is_teacher_acct = 't'. A school qualifies if at least one of its projects received a donation from a teacher. projects.schoolid identifies a school.", "SQL": "WITH teacher_schools AS (SELECT DISTINCT p.schoolid, p.school_city, p.school_state FROM projects p JOIN donations d ON p.projectid=d.projectid WHERE d.is_teacher_acct='t') SELECT 100.0 * SUM(CASE WHEN LOWER(TRIM(school_city))='brooklyn' AND school_state='NY' THEN 1 ELSE 0 END) / COUNT(*) AS brooklyn_school_percentage FROM teacher_schools;"}
{"question_id": 3233, "db_id": "donor", "grading_method": "set", "question": "What is the teacher prefix for the teacher who wrote the project 'Creating Memories and Inspiring Dreams'?", "evidence": "Creating Memories and Inspiring Dreams is title;", "SQL": "SELECT T2.teacher_prefix FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.title LIKE 'Creating Memories and Inspiring Dreams%'"}
{"question_id": 3244, "db_id": "donor", "grading_method": "set", "question": "Across all donations to Awesome Audiobooks Make Avid Readers, what percentage of the total donated amount was optional support?", "evidence": "essays.title records the project title. donations.donation_optional_support is the optional tip and donation_total is the total donation amount.", "SQL": "SELECT CAST(SUM(T2.donation_optional_support) AS REAL) * 100 / SUM(T2.donation_total) FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.title LIKE 'Awesome Audiobooks Make Avid Readers'"}
{"question_id": 3249, "db_id": "donor", "grading_method": "set", "question": "Name the vendors that sell the item Classroom Keepers Management Center.", "evidence": "vendor refer to vendor_name; Classroom Keepers Management Center refer to item_name and should be matched case-insensitively", "SQL": "SELECT DISTINCT vendor_name FROM resources WHERE LOWER(item_name) = 'classroom keepers management center'"}
{"question_id": 3294, "db_id": "donor", "grading_method": "set", "question": "Which item provided for projects with Mathematics as a primary subject is the most expensive?", "evidence": "Mathematics as a primary subject refers to primary_focus_subject = 'Mathematics'; most expensive refers to max(item_unit_price)", "SQL": "SELECT T1.item_name FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T2.primary_focus_subject = 'Mathematics' ORDER BY T1.item_unit_price DESC LIMIT 1"}
{"question_id": 3295, "db_id": "donor", "grading_method": "set", "question": "Where are the schools that need a \"Viewscreen LCD from Texas Instruments, TI-84 Plus\"? Only return the latitudes and longitudes of them.", "evidence": "needs a \"Viewscreen LCD from Texas Instruments, TI-84 Plus\" refers to item_name = 'Viewscreen LCD from Texas Instruments, TI-84 Plus'; latitude refers to school_latitude; longtitude refers to school_longitude", "SQL": "SELECT DISTINCT `p`.`school_latitude`, `p`.`school_longitude` FROM `resources` AS `r` JOIN `projects`  AS `p` ON `p`.`projectid` = `r`.`projectid` WHERE `r`.`item_name` = 'Viewscreen LCD from Texas Instruments, TI-84 Plus'"}
{"question_id": 3384, "db_id": "video_games", "grading_method": "set", "question": "How many games were published by Acclaim Entertainment?", "evidence": "published by Acclaim Entertainment refers to publisher_name = 'Acclaim Entertainment'", "SQL": "SELECT COUNT(DISTINCT T1.game_id) FROM game_publisher AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'Acclaim Entertainment'"}
{"question_id": 3399, "db_id": "video_games", "grading_method": "set", "question": "What are the least common game genres?", "evidence": "the least common game genre refers to the genre with min(count(game.id)); genre refers to genre_name", "SQL": "WITH min_count AS (\n    SELECT MIN(cnt) AS min_cnt\n    FROM (\n        SELECT COUNT(game.id) AS cnt\n        FROM genre\n        LEFT JOIN game ON game.genre_id = genre.id\n        GROUP BY genre.id\n    )\n)\nSELECT genre.genre_name\nFROM genre\nLEFT JOIN game ON game.genre_id = genre.id\nGROUP BY genre.id\nHAVING COUNT(game.id) = (SELECT min_cnt FROM min_count);"}
{"question_id": 3418, "db_id": "video_games", "grading_method": "set", "question": "How many publishers published the Minecraft game?", "evidence": "Minecraft refers to game_name = 'Minecraft';", "SQL": "SELECT COUNT(DISTINCT gp.publisher_id) FROM `game` AS g JOIN `game_publisher` AS gp ON gp.game_id = g.id WHERE g.game_name = 'Minecraft'"}
{"question_id": 3522, "db_id": "authors", "grading_method": "set", "question": "What is the average number of papers published in the journal \"Molecular Brain\" every year from 2008 to 2011?", "evidence": "\"Molecular Brain\" is the FullName of journal; year from 2008 to 2011 refers to Year BETWEEN 2008 AND 2011; average = Divide (Count(Id),4)", "SQL": "SELECT CAST(COUNT(p.`Id`) AS REAL) / 4 AS avg_papers_per_year FROM `Paper`  p JOIN `Journal` j ON j.`Id` = p.`JournalId` WHERE j.`FullName` = 'Molecular Brain' AND p.`Year` BETWEEN 2008 AND 2011"}
{"question_id": 3524, "db_id": "authors", "grading_method": "set", "question": "How many journals have a word \"computing\" in its full name?", "evidence": "word computing refers to FullName LIKE '%computing%'", "SQL": "SELECT COUNT(Id) FROM Journal WHERE FullName LIKE '%computing%'"}
{"question_id": 3537, "db_id": "authors", "grading_method": "set", "question": "What are the journal homepages and author ID of the papers published in 2000 to 2005 with a word \"social\" in its title?", "evidence": "in 2000 to 2005 refers to Year BETWEEN 2000 AND 2005; a word \"social\" in its title refers to Title = '%SOCIAL%'", "SQL": "SELECT T3.HomePage, T2.AuthorId FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId INNER JOIN Journal AS T3 ON T1.JournalId = T3.Id WHERE T1.Year BETWEEN 2000 AND 2005 AND T1.Title LIKE '%SOCIAL%'"}
{"question_id": 3539, "db_id": "authors", "grading_method": "set", "question": "Among papers with journal IDs from 200 to 300 and journal short names starting with A, what percentage have a conference ID of 0?", "evidence": "Paper.JournalId identifies the journal; Journal.ShortName is its abbreviated name. Paper.ConferenceId records the conference identifier.", "SQL": "SELECT CAST(SUM(CASE WHEN T1.ConferenceId = 0 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.ConferenceId) FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.JournalId BETWEEN 200 AND 300 AND T2.ShortName LIKE 'A%'"}
{"question_id": 3541, "db_id": "authors", "grading_method": "set", "question": "Write down the conference full name of \"ICWE\" and it's homepage address.", "evidence": "\"ICWE\" is the ShortName of conference", "SQL": "SELECT FullName, Homepage FROM Conference WHERE ShortName = 'ICWE'"}
{"question_id": 3564, "db_id": "authors", "grading_method": "set", "question": "How many authors have written paper \"145 GROWTH HORMONE RECEPTORS AND THE ONSET OF HYPERINSULINEMIA IN THE OBESE ZUCKER RAT: \"?", "evidence": "paper \"145 GROWTH HORMONE RECEPTORS AND THE ONSET OF HYPERINSULINEMIA IN THE OBESE ZUCKER RAT: \" refers to Title like'%145 GROWTH HORMONE RECEPTORS AND THE ONSET OF HYPERINSULINEMIA IN THE OBESE ZUCKER RAT:%'", "SQL": "SELECT COUNT(DISTINCT T2.Name) FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Title = '145 GROWTH HORMONE RECEPTORS AND THE ONSET OF HYPERINSULINEMIA IN THE OBESE ZUCKER RAT: '"}
{"question_id": 3571, "db_id": "authors", "grading_method": "set", "question": "List the unique author names appearing on preprinted but unpublished articles.", "evidence": "Preprinted but unpublished articles have Year = 0, with ConferenceId and JournalId each either 0 or missing. Author names as listed on an article are recorded in PaperAuthor.Name.", "SQL": "SELECT DISTINCT pa.`Name`\nFROM `Paper` AS p\nJOIN `PaperAuthor` AS pa ON pa.`PaperId` = p.`Id`\nWHERE p.`Year` = 0\n  AND (p.`ConferenceId` = 0 OR p.`ConferenceId` IS NULL)\n  AND (p.`JournalId`   = 0 OR p.`JournalId` IS NULL);"}
{"question_id": 3573, "db_id": "authors", "grading_method": "set", "question": "For all papers in which a journal was not published but a conference, return the distinct full names of the conferences.", "evidence": "journal was not published but a conference refers to ConferenceId ! = 0 And JournalId <= 0", "SQL": "SELECT DISTINCT `Conference`.`FullName` FROM `Paper` JOIN `Conference` ON `Paper`.`ConferenceId` = `Conference`.`Id` WHERE `Paper`.`ConferenceId` <> 0 AND `Paper`.`JournalId` <= 0"}
{"question_id": 3577, "db_id": "authors", "grading_method": "set", "question": "Indicate the name of all the journals published in the paper database in the year 2001.", "evidence": "name of all the journals refers to FullName", "SQL": "SELECT DISTINCT J.`FullName` FROM `Paper` AS P JOIN `Journal` AS J ON P.`JournalId` = J.`Id` WHERE P.`Year` = 2001 AND P.`JournalId` > 0"}
{"question_id": 3581, "db_id": "authors", "grading_method": "set", "question": "List the author names as they appear on papers published at conferences whose full names contain “Workshop”.", "evidence": "Author names as they appear on papers refers to PaperAuthor.Name; conference full names containing “Workshop” refers to Conference.FullName LIKE '%Workshop%'.", "SQL": "SELECT T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId INNER JOIN Conference AS T3 ON T1.ConferenceId = T3.Id WHERE T3.FullName LIKE '%Workshop%'"}
{"question_id": 3584, "db_id": "authors", "grading_method": "set", "question": "How many authors of paper number 220 were associated with the Microsoft Research when paper number 220 was written?", "evidence": "associated with the Microsoft Research refers to Affiliation contains 'Microsoft Research'; paper number 220 refers to PaperId = 220", "SQL": "SELECT COUNT(*) FROM `PaperAuthor` WHERE `PaperId` = 220 AND `Affiliation` LIKE '%Microsoft Research%';"}
{"question_id": 3589, "db_id": "authors", "grading_method": "set", "question": "How many papers were in the journal \"Iet Software/iee Proceedings - Software\"?", "evidence": "journal \"Iet Software/iee Proceedings - Software\" refers to FullName = 'Iet Software/iee Proceedings - Software'; papers refers to COUNT(JournalId)", "SQL": "SELECT COUNT(T1.JournalId) FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T2.FullName = 'Iet Software/iee Proceedings - Software'"}
{"question_id": 3614, "db_id": "authors", "grading_method": "set", "question": "How many papers are published in year 2000 under the conference \"SSPR\"?", "evidence": "SSPR is a ShortName; papers refers to Paper.Id", "SQL": "SELECT COUNT(T1.Id) FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Year = 2000 AND T2.ShortName = 'SSPR'"}
{"question_id": 3624, "db_id": "authors", "grading_method": "set", "question": "Give the number of papers that were published on \"IEEE Transactions on Nuclear Science\" in 1999.", "evidence": "'IEEE Transactions on Nuclear Science' is the FullName of journal; 1999 refers to Year = '1999'; papers refers to Paper.Id", "SQL": "SELECT COUNT(T2.Id) FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.FullName = 'IEEE Transactions on Nuclear Science' AND T2.Year = 1999"}
{"question_id": 3631, "db_id": "authors", "grading_method": "set", "question": "How many authors wrote the paper “An Improved Active Suspension Model for Attitude Control of Electric Vehicles”?", "evidence": "authors refers to AuthorId; 'An Improved Active Suspension Model for Attitude Control of Electric Vehicles' is the Title of a paper; A paper can have more than one author. Co-authorship can be derived from (paper ID, author ID) pair.", "SQL": "SELECT COUNT(T2.AuthorId) FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Title = 'An Improved Active Suspension Model for Attitude Control of Electric Vehicles'"}
{"question_id": 3643, "db_id": "authors", "grading_method": "set", "question": "Which papers in “TUBERCLE LUNG DIS” were published earliest?", "evidence": "“TUBERCLE LUNG DIS” is the journal’s ShortName. Paper titles are recorded in Title, and publication years in Year.", "SQL": "SELECT T2.Title FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.ShortName = 'TUBERCLE LUNG DIS' AND T2.Year = (SELECT MIN(T2.Year) FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.ShortName = 'TUBERCLE LUNG DIS')"}
{"question_id": 3652, "db_id": "authors", "grading_method": "set", "question": "List the full names of all of the conferences where a paper was published in 2008.", "evidence": "Published in 2008 refer to Year = 2008", "SQL": "SELECT DISTINCT T2.FullName FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Year = 2008"}
{"question_id": 3656, "db_id": "authors", "grading_method": "set", "question": "How many papers are preprint or not published?", "evidence": "preprint or not published refer to Year = 0 or ConferenceId and JournalID are less than or equal to 0 at the same time.", "SQL": "SELECT COUNT(Id) FROM Paper WHERE Year = 0 OR (ConferenceId <= 0 AND JournalId <= 0)"}
{"question_id": 3662, "db_id": "authors", "grading_method": "set", "question": "Where was the 'A context-based navigation paradigm for accessing Web data' paper published? State the name of the conference.", "evidence": "'A context-based navigation paradigm for accessing Web data' is the title of paper; name of conference refer to FullName", "SQL": "SELECT T2.FullName FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Title = 'A context-based navigation paradigm for accessing Web data'"}
{"question_id": 3679, "db_id": "authors", "grading_method": "set", "question": "Who are the authors listed on paper 221, and in what year was it published?", "evidence": "Use PaperAuthor.Name for the authors’ names as listed on the paper and Paper.Year for its publication year.", "SQL": "SELECT T1.Name, T2.Year FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T1.PaperId = 221"}
{"question_id": 3725, "db_id": "college_completion", "grading_method": "set", "question": "Give the cohort name for the school with biggest cohort size.", "evidence": "biggest cohort size refers to MAX(cohort_size)", "SQL": "SELECT DISTINCT g.`cohort`\nFROM `institution_details`   AS d\nJOIN `institution_grads`    AS g ON g.`unitid` = d.`unitid`\nWHERE d.`cohort_size` = (SELECT MAX(`cohort_size`) FROM `institution_details`);"}
{"question_id": 3785, "db_id": "public_review_platform", "grading_method": "set", "question": "How many hours does the Yelp business No. \"5734\" open on Saturday?", "evidence": "Business_Hours.opening_time and Business_Hours.closing_time store clock times as AM/PM text. Days.day_of_week records 'Saturday'.", "SQL": "WITH times AS ( SELECT CASE WHEN opening_time LIKE '%AM' THEN CASE WHEN REPLACE(opening_time,'AM','')='12' THEN 0 ELSE CAST(REPLACE(opening_time,'AM','') AS INT) END ELSE CASE WHEN REPLACE(opening_time,'PM','')='12' THEN 12 ELSE CAST(REPLACE(opening_time,'PM','') AS INT)+12 END END AS open_hr, CASE WHEN closing_time LIKE '%AM' THEN CASE WHEN REPLACE(closing_time,'AM','')='12' THEN 0 ELSE CAST(REPLACE(closing_time,'AM','') AS INT) END ELSE CASE WHEN REPLACE(closing_time,'PM','')='12' THEN 12 ELSE CAST(REPLACE(closing_time,'PM','') AS INT)+12 END END AS close_hr FROM Business_Hours bh JOIN Days d ON bh.day_id = d.day_id WHERE bh.business_id = 5734 AND d.day_of_week = 'Saturday' ) SELECT CASE WHEN close_hr > open_hr THEN close_hr - open_hr ELSE 24 - (open_hr - close_hr) END AS hours_open_on_saturday FROM times"}
{"question_id": 3829, "db_id": "public_review_platform", "grading_method": "subset,=,1", "question": "Please name one attribute that business number 2 does not have.", "evidence": "business number refers to business_id; business_id = 2; does not have refers to attribute_value = 'none' or 'no' or 'false';", "SQL": "SELECT T1.attribute_name FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.business_id = 2 AND lower(T2.attribute_value) IN ('none', 'no', 'false')"}
{"question_id": 3859, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses in the Food category are marked as good for kids?", "evidence": "Attributes.attribute_name uses 'Good for Kids'; Business_Attributes.attribute_value = 'TRUE' means the attribute is enabled.", "SQL": "SELECT COUNT(DISTINCT T3.business_id)\nFROM Categories AS T1\nINNER JOIN Business_Categories AS T2\n    ON T1.category_id = T2.category_id\nINNER JOIN Business AS T3\n    ON T2.business_id = T3.business_id\nINNER JOIN Business_Attributes AS T4\n    ON T3.business_id = T4.business_id\nINNER JOIN Attributes AS T5\n    ON T4.attribute_id = T5.attribute_id\nWHERE T1.category_name LIKE 'Food'\n  AND T5.attribute_name LIKE 'Good for Kids'\n  AND T4.attribute_value LIKE 'TRUE';"}
{"question_id": 3873, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the users who have posted more than 10 reviews, how many users are elite users?", "evidence": "posted more than 10 reviews refers to count(Reviews.user_id) > 10", "SQL": "WITH prolific AS (\n    SELECT `user_id`\n    FROM `Reviews`\n    GROUP BY `user_id`\n    HAVING COUNT(*) > 10\n)\nSELECT COUNT(DISTINCT p.`user_id`)\nFROM prolific p\nJOIN `Elite` e ON p.`user_id` = e.`user_id`;\n"}
{"question_id": 3903, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses in Phoenix, Arizona is attributed to waiter service?", "evidence": "Phoenix, Arizona refers to city = 'Phoenix' and state = 'AZ'. Waiter service refers to attribute_name = 'Waiter Service', ignoring case.", "SQL": "SELECT COUNT(DISTINCT b.`business_id`) FROM `Business`            AS b JOIN `Business_Attributes` AS ba ON ba.`business_id` = b.`business_id` JOIN `Attributes`          AS a  ON a.`attribute_id` = ba.`attribute_id` WHERE b.`city`  = 'Phoenix' AND b.`state` = 'AZ' AND LOWER(a.`attribute_name`) = 'waiter service' AND COALESCE(LOWER(ba.`attribute_value`), '') NOT IN ('no','false','none')"}
{"question_id": 3980, "db_id": "public_review_platform", "grading_method": "set", "question": "For user 6027, list their average review-star rating, elite year IDs, and compliment types whose compliment-count category is Uber.", "evidence": "Users.user_average_stars is the stored average review rating. Elite.year_id is a year identifier, not a calendar year. Users_Compliments.number_of_compliments uses categories such as 'Uber'. Compliments.compliment_type names the type.", "SQL": "SELECT T2.user_average_stars, T1.year_id, T4.compliment_type 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 WHERE T3.number_of_compliments = 'Uber' AND T3.user_id = 6027"}
{"question_id": 4038, "db_id": "public_review_platform", "grading_method": "set", "question": "Which business ID have the shortest total business operating hours?", "evidence": "Business_Hours records each business’s operating periods. A closing time earlier than opening falls on the following day. Identical opening and closing times represent 24 hours of operation.", "SQL": "WITH business_operating_hours AS (SELECT SUM(CASE WHEN opening_time_24h < closing_time_24h THEN closing_time_24h - opening_time_24h ELSE closing_time_24h + 24 - opening_time_24h END ) AS total_open_hours, business_id FROM (SELECT CASE WHEN INSTR(opening_time, 'AM') > 0 THEN CAST(SUBSTR(opening_time, 1, LENGTH(opening_time) - 2) AS INTEGER) % 12 WHEN INSTR(opening_time, 'PM') > 0 AND CAST(SUBSTR(opening_time, 1, LENGTH(opening_time) - 2) AS INTEGER) = 12 THEN 12 WHEN INSTR(opening_time, 'PM') > 0 THEN CAST(SUBSTR(opening_time, 1, LENGTH(opening_time) - 2) AS INTEGER) + 12 ELSE NULL END AS opening_time_24h, CASE WHEN INSTR(closing_time, 'AM') > 0 THEN CAST(SUBSTR(closing_time, 1, LENGTH(closing_time) - 2) AS INTEGER) % 12  WHEN INSTR(closing_time, 'PM') > 0 AND CAST(SUBSTR(closing_time, 1, LENGTH(closing_time) - 2) AS INTEGER) = 12 THEN 12 WHEN INSTR(closing_time, 'PM') > 0 THEN CAST(SUBSTR(closing_time, 1, LENGTH(closing_time) - 2) AS INTEGER) + 12 ELSE NULL END AS closing_time_24h, business_id FROM Business_Hours  ) GROUP BY business_id ) SELECT business_id FROM business_operating_hours WHERE total_open_hours = (SELECT MIN(total_open_hours) FROM business_operating_hours);"}
{"question_id": 4101, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses have a rating indicating a bad or terrible customer experience?", "evidence": "Business.stars = 2 means a bad experience; 1 means a terrible experience.", "SQL": "SELECT COUNT(business_id) FROM Business WHERE stars IN (1, 2)"}
{"question_id": 4144, "db_id": "citeseer", "grading_method": "set", "question": "Calculate the percentage of words used in Agents class label.", "evidence": "percentage = (divide(count(word_cited_id where class_label = 'Agents')), (count(word_cited_id)))*100;", "SQL": "SELECT CAST(COUNT(CASE WHEN T1.class_label = 'Agents' THEN T2.word_cited_id ELSE NULL END) AS REAL) * 100 / COUNT(T2.word_cited_id) FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id"}
{"question_id": 4147, "db_id": "citeseer", "grading_method": "set", "question": "List all words cited in the AI class label.", "evidence": "", "SQL": "SELECT DISTINCT T2.word_cited_id FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id WHERE T1.class_label = 'AI'"}
{"question_id": 4151, "db_id": "citeseer", "grading_method": "set", "question": "Which papers in the database have the most and fewest citations? List each paper and its citation count, including any ties.", "evidence": "", "SQL": "WITH citation_counts AS ( SELECT p.paper_id, COALESCE(COUNT(c.cited_paper_id), 0) AS citations FROM paper p LEFT JOIN cites c ON p.paper_id = c.cited_paper_id GROUP BY p.paper_id), extremes AS ( SELECT MAX(citations) AS max_cites, MIN(citations) AS min_cites FROM citation_counts ) SELECT cc.paper_id, cc.citations FROM citation_counts cc, extremes e WHERE cc.citations = e.max_cites OR cc.citations = e.min_cites;"}
{"question_id": 4156, "db_id": "citeseer", "grading_method": "set", "question": "Among the papers under DB classification, which papers have the highest number of words cited? List their ids.", "evidence": "classification refers to class_label; class_label = 'DB';", "SQL": "SELECT T1.paper_id FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id WHERE T1.class_label = 'DB' GROUP BY T1.paper_id HAVING COUNT(T2.word_cited_id) = (SELECT MAX(cnt) FROM (SELECT COUNT(T4.word_cited_id) AS cnt FROM paper AS T3 INNER JOIN content AS T4 ON T3.paper_id = T4.paper_id WHERE T3.class_label = 'DB' GROUP BY T3.paper_id) AS T5);"}
{"question_id": 4159, "db_id": "simpson_episodes", "grading_method": "set", "question": "What's the nickname for Dan Castellaneta?", "evidence": "\"Dan Castellaneta\" is the name of Person", "SQL": "SELECT nickname FROM Person WHERE name = 'Dan Castellaneta';"}
{"question_id": 4271, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many people were considered as prospective recipients of the \"Animation\" award?", "evidence": "prospective recipients refers to result = 'Nominee'", "SQL": "SELECT COUNT(DISTINCT `person`) FROM Award WHERE award = 'Animation' AND result = 'Nominee';"}
{"question_id": 4310, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many crew members are working from Casting Department?", "evidence": "working from Casting Department refers to category = 'Casting Department'", "SQL": "SELECT COUNT(DISTINCT T2.person) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.category = 'Casting Department';"}
{"question_id": 4355, "db_id": "simpson_episodes", "grading_method": "set", "question": "List down the episode ID of episodes aired in 2008 with 5 stars and below.", "evidence": "aired in 2008 refers to air_date LIKE '2008%'; 5 stars and below refers to stars <= 5", "SQL": "SELECT DISTINCT T1.episode_id FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008' AND T2.stars <= 5;"}
{"question_id": 4370, "db_id": "student_loan", "grading_method": "set", "question": "How many students belong to the navy department?", "evidence": "belong to the navy department refers to organ = 'navy';", "SQL": "SELECT COUNT(DISTINCT name) FROM enlist WHERE organ = 'navy'"}
{"question_id": 4382, "db_id": "student_loan", "grading_method": "set", "question": "Please list all the female students that have filed for bankruptcy.", "evidence": "The filed_for_bankrupcy table lists students who filed for bankruptcy. In this database, male students are listed in the male table; all other students are recorded as female.", "SQL": "SELECT name FROM filed_for_bankrupcy WHERE name NOT IN ( SELECT name FROM male )"}
{"question_id": 4464, "db_id": "student_loan", "grading_method": "set", "question": "How many students joined at least two organizations?", "evidence": "enlist.name identifies the student and enlist.organ records the organization joined.", "SQL": "SELECT COUNT(*)\nFROM (\n    SELECT `name`\n    FROM `enlist`\n    GROUP BY `name`\n    HAVING COUNT(DISTINCT `organ`) >= 2\n) t;"}
{"question_id": 4472, "db_id": "student_loan", "grading_method": "set", "question": "How many female students are enlisted in the Navy organization?", "evidence": "female students refers to enlist.name who are NOT in male.name; organization refers to organ; organ = 'navy';", "SQL": "SELECT COUNT(DISTINCT `name`) FROM `enlist` WHERE `organ` = 'navy' AND `name` NOT IN (SELECT `name` FROM `male`)"}
{"question_id": 4482, "db_id": "student_loan", "grading_method": "set", "question": "What is the ratio of students who have payment due and those who do not have payment due?", "evidence": "ratio =  DIVIDE(COUNT(name WHERE `bool` = 'pos'), COUNT(name WHERE `bool` = 'neg')); have payment due refers to `bool` = 'pos'; no payment due refers to `bool` = 'neg';", "SQL": "SELECT CAST(SUM(IIF(`bool` = 'pos', 1, 0)) AS REAL) / SUM(IIF(`bool` = 'neg', 1, 0)) FROM no_payment_due"}
{"question_id": 4484, "db_id": "student_loan", "grading_method": "set", "question": "On average, how many different students are enlisted in each organization? Round your answer to 4 decimal places.", "evidence": "Enlistment records are stored in enlist, where name identifies the student and organ identifies the organization.", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(student_count) FROM (SELECT organ,COUNT(DISTINCT name) AS student_count FROM enlist GROUP BY organ)\n) SELECT ROUND(value, 4) FROM unrounded;"}
{"question_id": 4493, "db_id": "student_loan", "grading_method": "set", "question": "How many unemployed students filed for bankruptcy?", "evidence": "unemployed students who filed for bankruptcy refers to unemployed.name who are IN filed_for_bankrupcy.name;", "SQL": "SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T2.name = T1.name"}
{"question_id": 4506, "db_id": "student_loan", "grading_method": "set", "question": "List out student names that enrolled in exactly two schools and two organizations?", "evidence": "enrolled in two schools refers to COUNT(school) = 2; two organizations refers to COUNT(organ) = 2;", "SQL": "SELECT p.`name`\nFROM `person` AS p\nJOIN `enrolled` AS e ON p.`name` = e.`name`\nJOIN `enlist`   AS l ON p.`name` = l.`name`\nGROUP BY p.`name`\nHAVING COUNT(DISTINCT e.`school`) = 2\n   AND COUNT(DISTINCT l.`organ`)  = 2;"}
{"question_id": 4514, "db_id": "student_loan", "grading_method": "set", "question": "What is the difference in the number of male students who filed for bankruptcy compared to female students?", "evidence": "difference = SUBTRACT(COUNT(filed_for_bankrupcy.name who are In male.name), COUNT(filed_for_bankrupcy.name who are NOT in male.name)); male students are mentioned in male.name; female students refers to filed_for_bankrupy.name who are NOT in male.name;", "SQL": "SELECT COUNT(T2.name) - SUM(IIF(T2.name IS NULL, 1, 0)) AS num FROM filed_for_bankrupcy AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name"}
{"question_id": 4533, "db_id": "student_loan", "grading_method": "set", "question": "What is the average length, in months, of female students’ longest school absences?", "evidence": "longest_absense_from_school.month records absence duration in months; in this dataset, students not listed in male are female.", "SQL": "SELECT AVG(T2.month) FROM person AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T1.name = T3.name WHERE T3.name IS NULL"}
{"question_id": 4540, "db_id": "student_loan", "grading_method": "set", "question": "Among the students that filed for bankruptcy, how many of them have been enrolled in OCC?", "evidence": "OCC refers to school = 'occ';", "SQL": "SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN enrolled AS T2 ON T1.name = T2.name WHERE T2.school = 'occ'"}
{"question_id": 4575, "db_id": "mental_health_survey", "grading_method": "set", "question": "Between 2016 and 2019, inclusive, which survey years had the most respondents reporting mental illness? Include ties.", "evidence": "Answer.SurveyID is the survey year. Answer.QuestionID = 34 identifies the mental-illness question; Answer.AnswerText = 'Yes' is a positive response.", "SQL": "WITH survey_num AS(\n  SELECT T1.SurveyID, COUNT(T1.UserID) num\n  FROM Answer AS T1 \n  INNER JOIN Question AS T2 \n  ON T1.QuestionID = T2.questionid \n  WHERE T1.SurveyID BETWEEN 2016 AND 2019 AND T2.questionid = 34 AND T1.AnswerText LIKE 'Yes' \n  GROUP BY T1.SurveyID\n) SELECT SurveyID FROM survey_num WHERE num = (SELECT MAX(num) FROM survey_num)"}
{"question_id": 4606, "db_id": "mental_health_survey", "grading_method": "set", "question": "How many people wrote comments for the question \"Any additional notes or comments.\"?", "evidence": "question refers to questiontext; wrote comments refers to AnswerText ! = -1", "SQL": "SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'Any additional notes or comments' AND T1.AnswerText != -1"}
{"question_id": 4621, "db_id": "disney", "grading_method": "set", "question": "How much greater was the Walt Disney Company's total recorded revenue in 1998 than in 1997?", "evidence": "Use revenue.Total for each year and subtract the 1997 total from the 1998 total. Here Total means the company revenue recorded in the revenue table, not the movie-level box-office gross in movies_total_gross.", "SQL": "SELECT SUM(CASE WHEN `Year` = 1998 THEN Total ELSE 0 END) - SUM(CASE WHEN `Year` = 1997 THEN Total ELSE 0 END) FROM revenue"}
{"question_id": 4624, "db_id": "disney", "grading_method": "set", "question": "Please list the villains of all the movies directed by Wolfgang Reitherman.", "evidence": "Wolfgang Reitherman refers to director = 'Wolfgang Reitherman';", "SQL": "SELECT T2.villian FROM director AS T1 INNER JOIN characters AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Wolfgang Reitherman' AND T2.villian IS NOT NULL"}
{"question_id": 4635, "db_id": "disney", "grading_method": "set", "question": "Who is the villain of the movie \"Beauty and the Beast\"?", "evidence": "Beauty and the Beast refers to movie_title = 'Beauty and the Beast';", "SQL": "SELECT villian FROM characters WHERE movie_title = 'Beauty and the Beast'"}
{"question_id": 4675, "db_id": "disney", "grading_method": "set", "question": "List the directors of movies that feature a song.", "evidence": "movies that feature a song refer to movie_title where song is not NULL;", "SQL": "SELECT T2.director FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.song IS NOT NULL GROUP BY T2.director"}
{"question_id": 4699, "db_id": "disney", "grading_method": "set", "question": "Name the voice actor of the character Calliope in the movie Hercules.", "evidence": "Hercules refers to movie = 'Hercules';", "SQL": "SELECT `voice-actor` FROM `voice-actors` WHERE movie = 'Hercules' AND character = 'Calliope'"}
{"question_id": 4709, "db_id": "disney", "grading_method": "set", "question": "List the titles of movies directed by Jack Kinney that were released before 1947.", "evidence": "Dates in characters.release_date are stored as YYYY-MM-DD. The film’s director is recorded in director.director.", "SQL": "SELECT T1.movie_title FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T2.director = 'Jack Kinney' AND date(T1.release_date) < '1947-01-01'"}
{"question_id": 4730, "db_id": "disney", "grading_method": "set", "question": "What was the average inflation-adjustment factor (adjusted gross divided by original gross) for Disney films released in 1995?", "evidence": "movies_total_gross.total_gross records original gross and inflation_adjusted_gross records adjusted gross, both as formatted currency amounts.", "SQL": "SELECT AVG(CAST(REPLACE(trim(inflation_adjusted_gross, '$'), ',', '') AS REAL) / CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL)) FROM movies_total_gross WHERE SUBSTR(release_date, LENGTH(release_date) - 3, LENGTH(release_date)) = '1995'"}
{"question_id": 4747, "db_id": "legislator", "grading_method": "set", "question": "Among the current legislators who do not have accounts on OpenSecrets.org., how many of them do not have instagram accounts either?", "evidence": "do not have accounts on OpenSecrets.org refers to opensecrets_ID is NULL OR opensecrets_id = ''; do not have instagram accounts refers to instagram is null", "SQL": "SELECT SUM(CASE WHEN T1.instagram IS NULL OR T1.instagram='' THEN 1 ELSE 0 END) AS count FROM `social-media` AS T1 RIGHT JOIN current AS T2 ON T1.bioguide = T2.bioguide_id WHERE T2.opensecrets_id IS NULL OR T2.opensecrets_id = ''"}
{"question_id": 4749, "db_id": "legislator", "grading_method": "set", "question": "For how many terms has current legislator Sherrod Brown served?", "evidence": "Sherrod Brown is an official_full_name", "SQL": "SELECT COUNT(*) FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.official_full_name = 'Sherrod Brown'"}
{"question_id": 4759, "db_id": "legislator", "grading_method": "set", "question": "How many female members were among the past legislators?", "evidence": "Historical legislators are recorded in historical; gender_bio = 'F' denotes female.", "SQL": "SELECT COUNT(*) FROM historical WHERE gender_bio = 'F'"}
{"question_id": 4806, "db_id": "legislator", "grading_method": "set", "question": "How many current legislators have not been registered in Federal Election Commission data?", "evidence": "have not been registered in Federal Election Commission data refers to fec_id is null OR fec_id = ''", "SQL": "SELECT COUNT(*) FROM current WHERE fec_id IS NULL OR fec_id = ''"}
{"question_id": 4813, "db_id": "legislator", "grading_method": "set", "question": "List the first names of current legislators who have served as senior senators.", "evidence": "current-terms.state_rank = 'senior' denotes senior senator. For completed terms, this is rank at the term’s end.", "SQL": "SELECT T1.first_name FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T2.state_rank = 'senior' GROUP BY T1.bioguide_id"}
{"question_id": 4878, "db_id": "legislator", "grading_method": "set", "question": "Which legislators listed as current have exactly 13 consecutive House terms recorded and represented three different congressional districts during that time? List their official full names.", "evidence": "Current legislators are those listed in current; official names are recorded in official_full_name. House terms are marked type = 'rep' in current-terms. For this question, a term means one two-year congressional period, including any recorded partial or ongoing term. Exactly 13 refers to all of the legislator’s recorded House terms. Consecutive means no congressional period is skipped; later swearing-in dates do not break the sequence. Districts are identified by their state and district number.", "SQL": "WITH house_terms AS (\n    SELECT bioguide, state, district,\n           CAST(strftime('%Y', start) AS INTEGER)\n           - CASE\n               WHEN CAST(strftime('%Y', start) AS INTEGER) % 2 = 0 THEN 1\n               WHEN strftime('%m-%d', start) < '01-03' THEN 2\n               ELSE 0\n             END AS term_year\n    FROM `current-terms`\n    WHERE type = 'rep'\n), periods AS (\n    SELECT DISTINCT bioguide, term_year\n    FROM house_terms\n), ordered_periods AS (\n    SELECT bioguide, term_year,\n           LAG(term_year) OVER (PARTITION BY bioguide ORDER BY term_year) AS previous_term_year\n    FROM periods\n), tenure AS (\n    SELECT bioguide\n    FROM ordered_periods\n    GROUP BY bioguide\n    HAVING COUNT(*) = 13\n       AND SUM(CASE\n                 WHEN term_year IS NULL THEN 1\n                 WHEN previous_term_year IS NULL THEN 0\n                 WHEN term_year = previous_term_year + 2 THEN 0\n                 ELSE 1\n               END) = 0\n), districts AS (\n    SELECT DISTINCT bioguide, state, district\n    FROM house_terms\n    WHERE state IS NOT NULL AND district IS NOT NULL\n), district_counts AS (\n    SELECT bioguide\n    FROM districts\n    GROUP BY bioguide\n    HAVING COUNT(*) = 3\n)\nSELECT c.official_full_name\nFROM current AS c\nINNER JOIN tenure AS t ON c.bioguide_id = t.bioguide\nINNER JOIN district_counts AS d ON c.bioguide_id = d.bioguide"}
{"question_id": 4887, "db_id": "legislator", "grading_method": "set", "question": "What is the religion of current legislator Sherrod Brown?", "evidence": "religion refers to religion_bio;", "SQL": "SELECT religion_bio FROM current WHERE official_full_name = 'Sherrod Brown'"}
{"question_id": 4922, "db_id": "olympics", "grading_method": "set", "question": "Please list the names of the Olympic games that were held in London.", "evidence": "held in London refers to city_name = 'London';", "SQL": "SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'London'"}
{"question_id": 4932, "db_id": "olympics", "grading_method": "set", "question": "Which game has Jessica Carolina Aguilera Aguilera participated in? Give the id of the game.", "evidence": "id of the game refers to games_id;", "SQL": "SELECT T2.games_id FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Jessica Carolina Aguilera Aguilera'"}
{"question_id": 4952, "db_id": "olympics", "grading_method": "set", "question": "How many athletes competed in the 1992 Summer Olympics?", "evidence": "1992 Summer Olympics refers to games_name = '1992 Summer'.", "SQL": "SELECT COUNT(DISTINCT `gc`.`person_id`)\nFROM `games` AS `g`\nJOIN `games_competitor` AS `gc` ON `g`.`id` = `gc`.`games_id`\nWHERE `g`.`games_name` = '1992 Summer';"}
{"question_id": 4978, "db_id": "olympics", "grading_method": "set", "question": "List out all the gold medalist winners in cycling sport.", "evidence": "gold medalist winners refer to full_name where medal_name = 'Gold'; cycling sport refers to sport_name = 'Cycling';", "SQL": "SELECT DISTINCT T5.full_name FROM event AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.event_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN sport AS T4 ON T1.sport_id = T4.id INNER JOIN person AS T5 ON T3.person_id = T5.id WHERE T4.sport_name = 'Cycling' AND T2.medal_id = 1"}
{"question_id": 5013, "db_id": "olympics", "grading_method": "set", "question": "Who is the heaviest athlete from Russia?", "evidence": "the heaviest athlete refers to full_name where MAX(weight); from Russia refers to region_name = 'Russia';", "SQL": "WITH name_weight AS (\n  SELECT T3.full_name, T3.weight \n  FROM noc_region AS T1 \n  INNER JOIN person_region AS T2 ON T1.id = T2.region_id \n  INNER JOIN person AS T3 ON T2.person_id = T3.id \n  WHERE T1.region_name = 'Russia'\n) SELECT full_name FROM name_weight WHERE weight = (SELECT MAX(weight) FROM name_weight)"}
{"question_id": 5038, "db_id": "olympics", "grading_method": "set", "question": "What are the IDs of the games held in London?", "evidence": "Host cities are recorded in city.city_name, including 'London'; games_city.games_id identifies the hosted Games.", "SQL": "SELECT T1.games_id FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T2.city_name = 'London'"}
{"question_id": 5045, "db_id": "olympics", "grading_method": "set", "question": "List the IDs of events where a gold medal was awarded.", "evidence": "medal.medal_name = 'Gold' denotes a gold medal.", "SQL": "SELECT DISTINCT T2.event_id FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id WHERE T1.medal_name = 'Gold'"}
{"question_id": 5047, "db_id": "olympics", "grading_method": "set", "question": "Which city were the Olympic games held in 1992?", "evidence": "city refers to city_name; in 1992 refers to games_year = 1992;", "SQL": "SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_year = 1992"}
{"question_id": 5065, "db_id": "olympics", "grading_method": "set", "question": "List the names of the games held in Paris.", "evidence": "Paris refers to city_name = 'Paris'; names of games refers to games_name;", "SQL": "SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'Paris'"}
{"question_id": 5074, "db_id": "olympics", "grading_method": "set", "question": "What was the season of the game in which a competitor weighing 73 kg and standing 180 cm tall participated?", "evidence": "person.height records height in centimeters; person.weight records weight in kilograms. games.season records the season.", "SQL": "SELECT DISTINCT T1.season FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.height = 180 AND T3.weight = 73"}
{"question_id": 5094, "db_id": "address", "grading_method": "set", "question": "What is the highest gender ratio of the residential areas in Arecibo county?", "evidence": "\"ARECIBO\" is the county; highest gender ration refers to Max(Divide (male_population, female_population))", "SQL": "SELECT CAST(T1.male_population AS REAL) / T1.female_population as ratio FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'ARECIBO' AND T1.female_population <> 0 ORDER BY ratio DESC LIMIT 1"}
{"question_id": 5097, "db_id": "address", "grading_method": "set", "question": "What is the alias of the city called Hartford?", "evidence": "\"Hartford\" is the city", "SQL": "SELECT DISTINCT T2.alias FROM zip_data AS T1 INNER JOIN alias AS T2 ON T1.zip_code = T2.zip_code WHERE T1.city = 'Hartford'"}
{"question_id": 5101, "db_id": "address", "grading_method": "set", "question": "In California, how many delivery receptacles are there in the community post office that has the highest number of delivery receptacles?", "evidence": "in California refers to state = 'CA'; 'Community Post Office' is the Type", "SQL": "SELECT MAX(`total_delivery_receptacles`) AS max_delivery_receptacles\nFROM `zip_data`\nWHERE `state` = 'CA'\n  AND `type` LIKE '%Community Post Office%';"}
{"question_id": 5111, "db_id": "address", "grading_method": "set", "question": "How many males are there in New Haven County's residential areas?", "evidence": "\"NEW HAVEN\" is the county; male refers to male_population", "SQL": "SELECT SUM(T1.male_population) FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'NEW HAVEN'"}
{"question_id": 5113, "db_id": "address", "grading_method": "set", "question": "For the city with the most elders, what's its area code?", "evidence": "city with most elders refers to Max(SUM(over_65))", "SQL": "WITH most_elders_city AS (SELECT city FROM zip_data GROUP BY city ORDER BY SUM(over_65) DESC LIMIT 1)\nSELECT DISTINCT T3.area_code FROM most_elders_city T1 JOIN zip_data T2 ON T1.city = T2.city JOIN area_code T3 ON T2.zip_code = T3.zip_code "}
{"question_id": 5124, "db_id": "address", "grading_method": "set", "question": "Name the bad alias of Geneva, AL.", "evidence": "\"Geneva\" is the city; 'AL' is the state", "SQL": "SELECT T1.bad_alias FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.city = 'Geneva' AND T2.state = 'AL'"}
{"question_id": 5129, "db_id": "address", "grading_method": "subset,=,10", "question": "List the zip codes, area codes, and city names of any 10 residential areas with a median age over 40.", "evidence": "median age over 40 refers to median_age > 40", "SQL": "SELECT T2.city, T2.zip_code, T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.median_age > 40"}
{"question_id": 5134, "db_id": "address", "grading_method": "subset,=,10", "question": "Name 10 cities with their states that are under the Lexington-Fayette, KY office of the Canada Border Services Agency.", "evidence": "\"Lexington-Fayette, KY\" is the CBSA_name", "SQL": "SELECT DISTINCT T2.city, T2.state FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'Lexington-Fayette, KY'"}
{"question_id": 5135, "db_id": "address", "grading_method": "set", "question": "For Indiana, what is the ratio of Democratic to Republican congressional representatives, expressed as a percentage?", "evidence": "The congress table records representatives, their state, and party names Democrat and Republican.", "SQL": "    SELECT  \n           cast(SUM(CASE WHEN `party` = 'Democrat'   THEN 1 ELSE 0 END) AS REAL) * 100 /  \n           SUM(CASE WHEN `party` = 'Republican' THEN 1 ELSE 0 END) AS is_rep  \n    FROM `congress`   \n    WHERE `state` = 'Indiana'  "}
{"question_id": 5220, "db_id": "address", "grading_method": "set", "question": "Provide the zip codes, cities, and locations of the postal points that have Shared Reshipper as a bad alias.", "evidence": "latitude and longitude coordinates can be used to identify the location;", "SQL": "SELECT T1.zip_code, T2.city, T2.latitude, T2.longitude FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.bad_alias = 'Shared Reshipper'"}
{"question_id": 5230, "db_id": "address", "grading_method": "set", "question": "Calculate the average number of beneficiaries per postal point in Guam.", "evidence": "DIVIDE(SUM(total_beneficiaries), COUNT(zip_code)) where name = 'Guam';", "SQL": "SELECT CAST(SUM(T2.total_beneficiaries) AS REAL) / COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Guam'"}
{"question_id": 5248, "db_id": "beer_factory", "grading_method": " multiset", "question": "Among all the root beers purchased by Frank-Paul Santangelo, how many of them were non-sweetened?", "evidence": "non-sweetened refers to honey = 'FALSE' AND artificialsweetener = 'FALSE';", "SQL": "SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND T4.ArtificialSweetener = 'FALSE' AND T4.Honey = 'FALSE'"}
{"question_id": 5253, "db_id": "beer_factory", "grading_method": "set", "question": "Show the credit card number of Lisa Ling.", "evidence": "", "SQL": "SELECT DISTINCT T2.CreditCardNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Lisa' AND T1.Last = 'Ling'"}
{"question_id": 5257, "db_id": "beer_factory", "grading_method": "set", "question": "What is the phone number of the customer who owns the credit card of number 6011179359005382?", "evidence": "", "SQL": "SELECT DISTINCT T1.PhoneNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.CreditCardNumber = 6011179359005382"}
{"question_id": 5262, "db_id": "beer_factory", "grading_method": "set", "question": "For the customer who gave a 3 star rating to Frostie brand on 2014/4/24, did the user permit the company to send regular emails to him/her? YES or NO", "evidence": "3 star rating refers to StarRating = 3; Frostie refers to  BrandName = 'Frostie'; if SubscribedToEmailList = 'TRUE', it means the user permit the company to send regular emails to him/her; if SubscribedToEmailList = 'FALSE', it means the user did not permit the company to send regular emails to him/her; rating on 2014/4/24 refers to ReviewDate = '2014-04-24';", "SQL": "SELECT CASE WHEN T1.SubscribedToEmailList LIKE 'TRUE' THEN 'YES' ELSE 'NO' END AS result FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T2.StarRating = 3 AND T3.BrandName = 'Frostie' AND T2.ReviewDate = '2014-04-24'"}
{"question_id": 5268, "db_id": "beer_factory", "grading_method": "set", "question": "What are the first and last names of the first 11 customers that made a purchase?", "evidence": "FirstPurchaseDate records a customer’s first purchase date. First and Last contain the customer’s name.", "SQL": "SELECT First, Last FROM customers ORDER BY FirstPurchaseDate LIMIT 11"}
{"question_id": 5269, "db_id": "beer_factory", "grading_method": "set", "question": "How many breweries are there in Australia?", "evidence": "Australia refers to Country = 'Australia';", "SQL": "SELECT COUNT(DISTINCT `BreweryName`) FROM `rootbeerbrand` WHERE `Country` = 'Australia'"}
{"question_id": 5271, "db_id": "beer_factory", "grading_method": "set", "question": "How many transactions were paid through MasterCard in 2014?", "evidence": "MasterCard refers to CreditCardType = 'MasterCard'; in 2014 refers to TransactionDate > = '2014-01-01' AND TransactionDate < = '2014-12-31';", "SQL": "SELECT COUNT(TransactionID) FROM `transaction` WHERE CreditCardType = 'MasterCard' AND TransactionDate LIKE '2014%'"}
{"question_id": 5277, "db_id": "beer_factory", "grading_method": "set", "question": "Which brand of root beer was highly rated by customers?", "evidence": "brand of root beer refers to BrandName; highly rated refers to MAX(COUNT(StarRating = 5));", "SQL": "SELECT rb.`BrandName`\nFROM `rootbeerbrand` rb\nJOIN `rootbeerreview` rr ON rb.`BrandID` = rr.`BrandID`\nWHERE rr.`StarRating` = 5\nGROUP BY rb.`BrandID`\nHAVING COUNT(*) = (\n    SELECT MAX(cnt)\n    FROM (\n        SELECT COUNT(*) AS cnt\n        FROM `rootbeerreview`\n        WHERE `StarRating` = 5\n        GROUP BY `BrandID`\n    )\n);"}
{"question_id": 5278, "db_id": "beer_factory", "grading_method": "set", "question": "How many Henry Weinhard's were bought by Nicholas Sparks?", "evidence": "Henry Weinhard's refers to BrandName = 'Henry Weinhard''s';", "SQL": "SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.First = 'Nicholas' AND T1.Last = 'Sparks' AND T4.BrandName LIKE 'Henry Weinhard%s'"}
{"question_id": 5279, "db_id": "beer_factory", "grading_method": "set", "question": "Of the root beer brands with neither a Facebook page nor a Twitter account listed, which was purchased most often?", "evidence": "FacebookPage and Twitter record a brand’s Facebook page and Twitter account. Both must be missing for a brand to qualify. Purchase frequency is measured by the number of transactions.", "SQL": "SELECT rb.BrandName FROM `transaction` t JOIN `rootbeer` r ON t.RootBeerID = r.RootBeerID JOIN `rootbeerbrand` rb ON r.BrandID = rb.BrandID WHERE rb.FacebookPage IS NULL AND rb.Twitter IS NULL GROUP BY rb.BrandID ORDER BY COUNT(*) DESC LIMIT 1;"}
{"question_id": 5285, "db_id": "beer_factory", "grading_method": "set", "question": "For the root beer brand or brands with the lowest unit profit, which customer ID had the highest number of purchases?", "evidence": "Unit profit is rootbeerbrand.CurrentRetailPrice minus rootbeerbrand.WholesaleCost. Purchases are recorded in transaction; transaction.CustomerID identifies the customer.", "SQL": "WITH min_profit_brand AS (\n    SELECT BrandID, BrandName\n    FROM rootbeerbrand\n    WHERE (CurrentRetailPrice - WholesaleCost) = (\n          SELECT MIN(CurrentRetailPrice - WholesaleCost)\n          FROM rootbeerbrand)\n),\nbrand_purchases AS (\n    SELECT mp.BrandName,\n           t.CustomerID,\n           COUNT(*) AS num_purchases\n    FROM min_profit_brand mp\n    JOIN rootbeer r  ON r.BrandID = mp.BrandID\n    JOIN `transaction` t ON t.RootBeerID = r.RootBeerID\n    GROUP BY t.CustomerID, mp.BrandName\n)\nSELECT CustomerID\nFROM brand_purchases\nWHERE num_purchases = (SELECT MAX(num_purchases) FROM brand_purchases)"}
{"question_id": 5290, "db_id": "beer_factory", "grading_method": "set", "question": "Among the transactions, what percentage is done by using a visa card?", "evidence": "Visa refers to CreditCardType = 'Visa'.", "SQL": "SELECT CAST(COUNT(CASE WHEN CreditCardType = 'Visa' THEN TransactionID ELSE NULL END) AS REAL) * 100 / COUNT(TransactionID) FROM `transaction`"}
{"question_id": 5298, "db_id": "beer_factory", "grading_method": "set", "question": "Which root beer brands received the most five-star reviews in 2012? List their names.", "evidence": "Five-star reviews have StarRating = 5; “in 2012” refers to the year of ReviewDate.", "SQL": "SELECT T3.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.StarRating = 5 AND strftime('%Y', T2.ReviewDate) = '2012' GROUP BY T1.BrandID HAVING COUNT(DISTINCT CustomerID) = (SELECT MAX(FiveStarCount) FROM (SELECT T1.BrandID, COUNT(DISTINCT T2.CustomerID) AS FiveStarCount FROM rootbeer AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND strftime('%Y', T2.ReviewDate) = '2012' GROUP BY T1.BrandID) AS FiveStarCounts);"}
{"question_id": 5324, "db_id": "beer_factory", "grading_method": "set", "question": "Give me the brewery and brand names of canned root beer that were purchased before 6/6/2015.", "evidence": "canned root beer refers to ContainerType = 'Can'; purchased before 6/6/2015 refers to PurchaseDate < '2015-06-06';", "SQL": "SELECT DISTINCT T2.BreweryName, T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate < '2015-06-06' AND T1.ContainerType = 'Can'"}
{"question_id": 5339, "db_id": "beer_factory", "grading_method": "set", "question": "How many bottles of beer have been bought by Jim Breech?", "evidence": "bottles refers to ContainerType = 'Bottle';", "SQL": "SELECT COUNT(T3.ContainerType) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T2.CustomerID = T1.CustomerID INNER JOIN rootbeer AS T3 ON T3.RootBeerID = T2.RootBeerID WHERE T3.ContainerType = 'Bottle' AND T1.First = 'Jim' AND T1.Last = 'Breech'"}
{"question_id": 5353, "db_id": "beer_factory", "grading_method": "set", "question": "How many stars did Urijah Faber rate for Frostie?", "evidence": "stars refers to StarRating; Frostie refers to BrandName = 'Frostie';", "SQL": "SELECT T2.StarRating FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Urijah' AND T1.Last = 'Faber' AND T3.BrandName = 'Frostie'"}
{"question_id": 5384, "db_id": "sales", "grading_method": "set", "question": "Among customers with the last name of Alvarez, who purchased the highest total quantity? Report the customer id.", "evidence": "highest quantity refers to the largest SUM(Sales.Quantity) for a customer across all sales;", "SQL": "SELECT c.CustomerID FROM Customers AS c JOIN Sales AS s ON c.CustomerID = s.CustomerID WHERE c.LastName = 'Alvarez' GROUP BY c.CustomerID HAVING SUM(s.Quantity) = (SELECT MAX(total_quantity) FROM (SELECT c2.CustomerID, SUM(s2.Quantity) AS total_quantity FROM Customers AS c2 JOIN Sales AS s2 ON c2.CustomerID = s2.CustomerID WHERE c2.LastName = 'Alvarez' GROUP BY c2.CustomerID) AS subquery);"}
{"question_id": 5402, "db_id": "sales", "grading_method": "set", "question": "Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48.", "evidence": "name of the sales person = FirstName, MiddleInitial, LastName; 'Road-250 Black, 48' is name of product;", "SQL": "SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID INNER JOIN Customers AS T4 ON T2.CustomerID = T4.CustomerID WHERE T4.MiddleInitial = 'A' AND T4.LastName = 'White' AND T1.Name = 'Road-250 Black, 48' AND T4.FirstName = 'Elizabeth'"}
{"question_id": 5431, "db_id": "sales", "grading_method": "set", "question": "Among customers with the first name Kate, who bought the most units in total? List their first and last names.", "evidence": "Kate refers to FirstName = 'Kate'; Sales.Quantity records the number of items purchased.", "SQL": "SELECT c.`FirstName`,\n       c.`LastName`\nFROM `Customers` AS c\nJOIN `Sales`     AS s ON s.`CustomerID` = c.`CustomerID`\nWHERE c.`FirstName` = 'Kate'\nGROUP BY c.`CustomerID`, c.`FirstName`, c.`LastName`\nORDER BY SUM(s.`Quantity`) DESC\nLIMIT 1;"}
{"question_id": 5436, "db_id": "sales", "grading_method": "set", "question": "What are the names of the products Kathryn Deng bought in the greatest total quantity across all her purchases?", "evidence": "greatest total quantity refers to the largest SUM(Sales.Quantity) for a product across all purchases by Kathryn Deng;", "SQL": "SELECT p.`Name` FROM `Products`  AS p JOIN `Sales`     AS s ON s.`ProductID`  = p.`ProductID` JOIN `Customers` AS c ON c.`CustomerID` = s.`CustomerID` WHERE c.`FirstName` = 'Kathryn' AND c.`LastName`  = 'Deng' GROUP BY p.`ProductID`, p.`Name` HAVING SUM(s.`Quantity`) = (SELECT MAX(TotalQuantity) FROM (SELECT p2.`ProductID`, SUM(s2.`Quantity`) AS TotalQuantity FROM `Products` AS p2 JOIN `Sales` AS s2 ON s2.`ProductID` = p2.`ProductID` JOIN `Customers` AS c2 ON c2.`CustomerID` = s2.`CustomerID` WHERE c2.`FirstName` = 'Kathryn' AND c2.`LastName` = 'Deng' GROUP BY p2.`ProductID`) AS ProductQuantities);"}
{"question_id": 5452, "db_id": "sales", "grading_method": "set", "question": "How many \"Mountain-100 Silver, 38\" were sold by Stearns MacFeather?", "evidence": "'Mountain-100 Silver, 38' is name of product;", "SQL": "SELECT SUM(T2.Quantity) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Stearns' AND T1.LastName = 'MacFeather' AND T3.Name = 'Mountain-100 Silver, 38'"}
{"question_id": 5496, "db_id": "menu", "grading_method": "set", "question": "Among the dishes on menu page ID 7610, list the names and highest prices of the dishes in menu items that were created on 23rd May 2011.", "evidence": "highest prices of the dishes refers to Dish.highest_price; created on 23rd May 2011 refers to created_at like '2011-05-23%';", "SQL": "SELECT DISTINCT d.name, d.highest_price\nFROM `Dish` d\nJOIN `MenuItem` mi ON mi.dish_id = d.id\nWHERE mi.menu_page_id = 7610\n  AND mi.created_at LIKE '2011-05-23%';"}
{"question_id": 5532, "db_id": "menu", "grading_method": "set", "question": "For the dishes that were free, give me their name and their current price on the menu.", "evidence": "dishes that were free refers to lowest_price = 0;", "SQL": "SELECT T2.name, T1.price FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE T2.lowest_price = 0"}
{"question_id": 5631, "db_id": "shipping", "grading_method": "set", "question": "How many cities with populations over 50,000 had shipments in 2017?", "evidence": "shipment.city_id is the destination city. shipment.ship_date is when the driver received the shipment, stored as YYYY-MM-DD.", "SQL": "SELECT COUNT(DISTINCT T1.city_id)\nFROM `city` AS T1\nJOIN `shipment` AS T2 ON T1.city_id = T2.city_id\nWHERE T1.population > 50000\n  AND STRFTIME('%Y', T2.ship_date) = '2017';"}
{"question_id": 5697, "db_id": "language_corpus", "grading_method": "set", "question": "What is the word id of the catalan language that was repeated no more than 10 times in the said language?", "evidence": "word id refers to wid; repeated no more than 10 times refers to occurrences < = 10", "SQL": "SELECT `wid`\nFROM `langs_words`\nWHERE `lid` = 1\n  AND `occurrences` <= 10;"}
{"question_id": 5718, "db_id": "language_corpus", "grading_method": "set", "question": "List the revision page IDs of pages where \"fresc\" appears.", "evidence": "Revision identifiers are recorded in pages.revision; the word is recorded in words.word as 'fresc'.", "SQL": "SELECT T3.revision FROM words AS T1 INNER JOIN pages_words AS T2 ON T1.wid = T2.wid INNER JOIN pages AS T3 ON T2.pid = T3.pid WHERE T1.word = 'fresc'"}
{"question_id": 5804, "db_id": "language_corpus", "grading_method": "set", "question": "How many occurrences does the word \"exemple\" have in Catalan?", "evidence": "langs_words.occurrences records a word’s occurrence count for a language; lid = 1 denotes Catalan. The word is words.word = 'exemple'.", "SQL": "SELECT T2.occurrences FROM words AS T1 INNER JOIN langs_words AS T2 ON T1.wid = T2.wid WHERE T1.word = 'exemple' AND T2.lid = 1"}
{"question_id": 5831, "db_id": "airline", "grading_method": "set", "question": "How many flights operated by American Airlines Inc. on 2018/8/1 were faster than scheduled?", "evidence": "American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; on 2018/8/1 refers to FL_DATE = '2018/8/1'; faster than scheduled refers to ACTUAL_ELAPSED_TIME < CRS_ELAPSED_TIME;", "SQL": "SELECT COUNT(*) AS count\nFROM `Airlines` a\nJOIN `Air Carriers` c ON a.`OP_CARRIER_AIRLINE_ID` = c.`Code`\nWHERE c.`Description` = 'American Airlines Inc.: AA'\n  AND a.`FL_DATE` = '2018/8/1'\n  AND a.`ACTUAL_ELAPSED_TIME` < a.`CRS_ELAPSED_TIME`;"}
{"question_id": 5836, "db_id": "airline", "grading_method": "set", "question": "What is the average departure delay time of flights operated by American Airlines Inc.?", "evidence": "American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'. Departure delay is recorded in DEP_DELAY; missing values indicate that no delay measurement was recorded.", "SQL": "SELECT AVG(T1.DEP_DELAY) FROM Airlines AS T1  INNER JOIN `Air Carriers` AS T3 ON T1.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T3.Description = 'American Airlines Inc.: AA'"}
{"question_id": 5838, "db_id": "airline", "grading_method": "set", "question": "What is the number of air carriers in the database?", "evidence": "", "SQL": "SELECT COUNT(Code) FROM `Air Carriers`"}
{"question_id": 5846, "db_id": "airline", "grading_method": "set", "question": "For the flight with the tail number 'N702SK', which air carrier does it belong to?", "evidence": "tail number refers to TAIL_NUM; TAIL_NUM = 'N702SK';", "SQL": "SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.TAIL_NUM = 'N702SK' GROUP BY T2.Description"}
{"question_id": 5863, "db_id": "airline", "grading_method": "set", "question": "Among the airports whose destination is Logan International, what is the airline id of the carrier operator with the highest delay in minutes due to security?", "evidence": "destination refers to DEST; Logan International refers to Description = 'Boston, MA: Logan International'; airline id of the carrier operator refers to OP_CARRIER_AIRLINE_ID; highest delay in minutes due to security refers to MAX(SECURITY_DELAY);", "SQL": "SELECT T2.OP_CARRIER_AIRLINE_ID FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST WHERE T1.Description = 'Boston, MA: Logan International' AND T2.DEST = 'BOS' ORDER BY T2.SECURITY_DELAY DESC LIMIT 1"}
{"question_id": 5907, "db_id": "airline", "grading_method": "set", "question": "Provide the air carrier description of the flight with a tail number N922US from Phoenix.", "evidence": "tail number refers to TAIL_NUM; TAIL_NUM = 'N922US'; from Phoenix refers to ORIGIN = 'PHX';", "SQL": "SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T2.Code = T1.OP_CARRIER_AIRLINE_ID WHERE T1.TAIL_NUM = 'N922US' AND T1.ORIGIN = 'PHX' GROUP BY T2.Description"}
{"question_id": 5916, "db_id": "books", "grading_method": "set", "question": "What is the name of the publisher that published the most books?", "evidence": "Publisher names are recorded in publisher.publisher_name.", "SQL": "SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_id ORDER BY COUNT(T1.book_id) DESC LIMIT 1"}
{"question_id": 5949, "db_id": "books", "grading_method": "set", "question": "How many orders did Antonia Poltun return?", "evidence": "order returned refers to status_value = 'Returned'", "SQL": "SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.status_value = 'Returned' AND T4.first_name = 'Antonia' AND T4.last_name = 'Poltun'"}
{"question_id": 5970, "db_id": "books", "grading_method": "set", "question": "List the author's name of the books published by Abrams.", "evidence": "\"Abrams\" is the publisher_name; author's name refers to author_name", "SQL": "SELECT T3.author_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 T4.publisher_name = 'Abrams'"}
{"question_id": 5975, "db_id": "books", "grading_method": "set", "question": "Name the streets in Dallas.", "evidence": "\"Dallas\" is the city; streets refers to street_name", "SQL": "SELECT street_name FROM address WHERE city = 'Dallas'"}
{"question_id": 5982, "db_id": "books", "grading_method": "set", "question": "How many books were published in Japanese?", "evidence": "published in Japanese refers to language_name = 'Japanese'", "SQL": "SELECT COUNT(T2.book_id) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'"}
{"question_id": 5991, "db_id": "books", "grading_method": "set", "question": "What is the average price for the order line?", "evidence": "average price refers to AVG(price)", "SQL": "SELECT AVG(price) FROM order_line"}
{"question_id": 5994, "db_id": "books", "grading_method": "set", "question": "How many publishers have the word \"book\" in their name?", "evidence": "publisher have the word 'book' refers to publisher_name LIKE '%book%'", "SQL": "SELECT COUNT(*) FROM publisher WHERE publisher_name LIKE '%book%'"}
{"question_id": 6004, "db_id": "books", "grading_method": "set", "question": "What is the address that received the most orders?", "evidence": "address refers to street_name, city; received the most orders refers to Max(count(dest_address_id))", "SQL": "SELECT T2.street_name, T2.city FROM cust_order AS T1 INNER JOIN address AS T2 ON T1.dest_address_id = T2.address_id\n GROUP BY T2.address_id, T2.street_number, T2.street_name, T2.city ORDER BY COUNT(T1.dest_address_id) DESC LIMIT 1"}
{"question_id": 6056, "db_id": "books", "grading_method": "set", "question": "How many books were published in 2017?", "evidence": "published in 2017 refers to Substr(publication_date,1, 4) = '2017'", "SQL": "SELECT COUNT(*) FROM book WHERE STRFTIME('%Y', publication_date) = '2017'"}
{"question_id": 6093, "db_id": "books", "grading_method": "set", "question": "Provide the publisher name of the book with ISBN 76092025986.", "evidence": "\"76092025986\" is the isbn13", "SQL": "SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.isbn13 = 76092025986"}
{"question_id": 6111, "db_id": "food_inspection_2", "grading_method": "set", "question": "Please list the full names of the sanitarians who did at least one inspection in May, 2010.", "evidence": "full name refers to first_name, last_name; in May 2010 refers to inspection_date like '2010-05%'; sanitarian refers to title = 'Sanitarian'", "SQL": "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 strftime('%Y-%m', T2.inspection_date) = '2010-05' AND T1.title = 'Sanitarian'"}
{"question_id": 6129, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many \"food maintenance\" related violations did inspection no.1454071 have?", "evidence": "\"food maintenance\" related refers to category = 'Food Maintenance'; inspection no.1454071 refers to inspection_id = '1454071'", "SQL": "SELECT COUNT(T2.point_id) FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.inspection_id = '1454071' AND T1.category = 'Food Maintenance'"}
{"question_id": 6159, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the employee's last name at 7211 S Hermitage Ave, Chicago, IL?", "evidence": "7211 S Hermitage Ave refers to address = '7211 S Hermitage Ave'; Chicago refers to city = 'Chicago'; IL refers to state = 'IL'", "SQL": "SELECT last_name FROM employee WHERE address = '7211 S Hermitage Ave' AND city = 'Chicago' AND state = 'IL'"}
{"question_id": 6162, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the employee's full name involved in the canvass inspection type on March 09, 2010?", "evidence": "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'", "SQL": "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'"}
{"question_id": 6172, "db_id": "food_inspection_2", "grading_method": "set", "question": "Among listed establishments that have failed an inspection, what percentage have the highest recorded risk-level code? Round your answer to 3 decimal places.", "evidence": "establishment lists establishments by license_no and records their numeric risk_level. inspection.results = 'Fail' denotes a failed inspection. Risk-level code refers to the recorded number, not an independently inferred safety classification.", "SQL": "WITH unrounded(value) AS (\nWITH failed_establishments AS (\n    SELECT DISTINCT `license_no`\n    FROM `inspection`\n    WHERE `results` = 'Fail'\n),\nrl AS (\n    SELECT fe.`license_no`, e.`risk_level`\n    FROM failed_establishments fe\n    JOIN `establishment` e USING (`license_no`)\n),\nmx AS (\n    SELECT MAX(`risk_level`) AS max_risk FROM rl\n)\nSELECT\n    CAST(SUM(CASE WHEN rl.`risk_level` = mx.`max_risk` THEN 1 ELSE 0 END) AS REAL) * 100.0 /\n    COUNT(*)      AS percentage_highest_risk\nFROM rl\nCROSS JOIN mx\n) SELECT ROUND(value, 3) FROM unrounded;"}
{"question_id": 6181, "db_id": "food_inspection_2", "grading_method": "set", "question": "Which facilities were inspected by Sarah Lindsey on 20th November 2012?", "evidence": "facility name refers to dba_name; on 20th November 2012 refers to inspection_date = '2012-11-20'", "SQL": "SELECT DISTINCT T1.dba_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 = '2012-11-20' AND T3.first_name = 'Sarah' AND T3.last_name = 'Lindsey'"}
{"question_id": 6259, "db_id": "coinmarketcap", "grading_method": "set", "question": "For all coins with average price more than $1000. State the current status of the coin.", "evidence": "average price more than $1000 refers to AVG(price)>1000", "SQL": "SELECT c.status\nFROM coins AS c\nJOIN historical AS h ON c.id = h.coin_id\nGROUP BY c.id\nHAVING AVG(h.price) > 1000;"}
{"question_id": 6295, "db_id": "coinmarketcap", "grading_method": "set", "question": "On April 28, 2013, list the names of the coins that have a price above the average value of coin prices on that day.", "evidence": "average price = divide(sum(price), count(name)); on April 28, 2013 refers to date = '2013-04-28'", "SQL": "SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T2.price > ( SELECT AVG(price) FROM historical WHERE date = '2013-04-28' )"}
{"question_id": 6318, "db_id": "retail_world", "grading_method": "set", "question": "What is the product that is ordered in the highest quantity in order no. 10248?", "evidence": "highest quantity refers to max(Quantity)", "SQL": "SELECT ProductName\nFROM Products\nWHERE ProductID = (\n        SELECT ProductID\n        FROM OrderDetails\n        WHERE OrderID = 10248\n        ORDER BY Quantity DESC\n        LIMIT 1);"}
{"question_id": 6374, "db_id": "retail_world", "grading_method": "set", "question": "Which products have the largest total quantity ordered? List their product IDs, including ties.", "evidence": "OrderDetails.Quantity records units on an order line.", "SQL": "with sub as (SELECT od.`ProductID`, SUM(od.`Quantity`) as num\nFROM `OrderDetails` od \nGROUP BY od.`ProductID`\nORDER BY SUM(od.`Quantity`) DESC\n)\nSELECT ProductID FROM sub where num = (SELECT max(num) FROM sub)"}
{"question_id": 6437, "db_id": "retail_world", "grading_method": "set", "question": "Who is the contact representing the supplier \"Heli Süßwaren GmbH & Co. KG\"?", "evidence": "SupplierName = 'Heli Süßwaren GmbH & Co. KG'; the supplier's representative refers to ContactName.", "SQL": "SELECT `ContactName`\nFROM `Suppliers`\nWHERE `SupplierName` = 'Heli Süßwaren GmbH & Co. KG';"}
{"question_id": 6602, "db_id": "retail_world", "grading_method": "set", "question": "What percentage of all orders contain fewer than 50 items in total?", "evidence": "Quantity records the number of items on an order line. Orders with no line items are treated as containing zero items.", "SQL": "WITH per_order AS (\n    SELECT o.`OrderID`,\n           COALESCE(SUM(d.`Quantity`),0) AS total_qty\n    FROM `Orders` o\n    LEFT JOIN `OrderDetails` d ON o.`OrderID` = d.`OrderID`\n    GROUP BY o.`OrderID`\n)\nSELECT CAST(SUM(CASE WHEN total_qty < 50 THEN 1 ELSE 0 END) AS REAL) * 100.0 / COUNT(*) AS pct_orders_lt_50\nFROM per_order;"}
{"question_id": 6652, "db_id": "retail_world", "grading_method": "set", "question": "Which shippers were assigned the most orders placed in the first quarter of 1997? Give their names, including any ties.", "evidence": "OrderDate records when an order was placed; shipper names are recorded in ShipperName. The first quarter covers January through March.", "SQL": "WITH sub as (SELECT  ShipperName, COUNT(*) as num\nFROM `Orders`   o\nJOIN `Shippers` s ON s.`ShipperID` = o.`ShipperID`\nWHERE strftime('%Y', o.`OrderDate`) = '1997'\n  AND CAST(strftime('%m', o.`OrderDate`) AS INTEGER) BETWEEN 1 AND 3\nGROUP BY s.`ShipperID`\n)\nselect ShipperName FROM sub where num = (SELECT max(num) from sub)"}
{"question_id": 6705, "db_id": "retails", "grading_method": "set", "question": "How many orders were shipped in 1998?", "evidence": "orders refer to l_orderkey; shipped in 1998 refers to year(l_shipdate) = 1998;", "SQL": "SELECT COUNT(DISTINCT `l_orderkey`) FROM `lineitem` WHERE STRFTIME('%Y', `l_shipdate`) = '1998'"}
{"question_id": 6736, "db_id": "retails", "grading_method": "set", "question": "Calculate the total profit made by chocolate floral blue coral cyan.", "evidence": "SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) where p_name = 'chocolate floral blue coral cyan';", "SQL": "SELECT SUM(T3.l_extendedprice * (1 - T3.l_discount) - T2.ps_supplycost * T3.l_quantity) FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN lineitem AS T3 ON T2.ps_partkey = T3.l_partkey AND T2.ps_suppkey = T3.l_suppkey WHERE T1.p_name = 'chocolate floral blue coral cyan'"}
{"question_id": 6754, "db_id": "retails", "grading_method": "set", "question": "Provide the phone numbers of the customers with the highest total price in an order.", "evidence": "phone number of the customer refers to c_phone; the highest total price refers to MAX(o_totalprice);", "SQL": "SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice = ( SELECT MAX(T3.o_totalprice) FROM orders AS T3 );"}
{"question_id": 6765, "db_id": "retails", "grading_method": "set", "question": "What percentage of supplier listings have a supply cost above 500?", "evidence": "Each partsupp row represents a part offered by a supplier; ps_supplycost records its supply cost.", "SQL": "SELECT CAST(SUM(IIF(ps_supplycost > 500, 1, 0)) AS REAL) * 100 / COUNT(ps_suppkey) FROM partsupp"}
{"question_id": 6829, "db_id": "retails", "grading_method": "set", "question": "What are the account balances of the suppliers with the most parts?", "evidence": "account balance refers to s_acctbal; the most parts refers to max(count(ps_suppkey))", "SQL": "SELECT s_acctbal FROM ( SELECT s_suppkey, s_acctbal, COUNT(*) AS num FROM supplier JOIN partsupp ON s_suppkey = ps_suppkey GROUP BY s_suppkey, s_acctbal ) t WHERE num = (SELECT MAX(cnt) FROM (SELECT COUNT(*) AS cnt FROM partsupp GROUP BY ps_suppkey))"}
{"question_id": 6839, "db_id": "retails", "grading_method": "set", "question": "How many order keys are not applied for any discounts?", "evidence": "An undiscounted order has no discounted line items. Orders are identified by l_orderkey; a nonzero l_discount indicates a discount on a line item.", "SQL": "SELECT COUNT(DISTINCT l_orderkey) FROM lineitem WHERE l_orderkey not in (SELECT DISTINCT l_orderkey FROM lineitem WHERE l_discount != 0)"}
{"question_id": 6913, "db_id": "retails", "grading_method": "set", "question": "What are the names of the parts that were ordered by customer 110942?", "evidence": "name of the part refers to p_name; customer 110942 refers to o_custkey = 110942", "SQL": "SELECT DISTINCT p.`p_name`\nFROM `orders`  AS o\nJOIN `lineitem` AS l ON o.`o_orderkey` = l.`l_orderkey`\nJOIN `part`     AS p ON l.`l_partkey` = p.`p_partkey`\nWHERE o.`o_custkey` = 110942;"}
{"question_id": 6923, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What is the weight of the player with the longest time on ice in the player’s first 7 years of NHL career in kilograms?", "evidence": "weight in kilograms refers to weight_in_kg; longest time on ice in the player's first 7 years of NHL career refers to MAX(sum_7yr_TOI);", "SQL": "SELECT T2.weight_in_kg FROM PlayerInfo AS T1 INNER JOIN weight_info AS T2 ON T1.weight = T2.weight_id WHERE T1.sum_7yr_TOI = ( SELECT MAX(t.sum_7yr_TOI) FROM PlayerInfo t )"}
{"question_id": 6945, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Identify the players who weigh 120 kg.", "evidence": "players refers to PlayerName; weigh 120 kg refers to weight_in_kg = 120;", "SQL": "SELECT T2.PlayerName FROM weight_info AS T1 INNER JOIN PlayerInfo AS T2 ON T1.weight_id = T2.weight WHERE T1.weight_in_kg = 120"}
{"question_id": 6972, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "List the names of all players in team Avangard Omsk in season 2000-2001.", "evidence": "names of the players refers to PlayerName; team Avangard Omsk refers to TEAM = 'Avangard Omsk'; 2000-2001 season refers to SEASON = '2000-2001';", "SQL": "SELECT DISTINCT T2.PlayerName FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '2000-2001' AND T1.TEAM = 'Avangard Omsk'"}
{"question_id": 6989, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Which teams have the most Swedish players?", "evidence": "Swedish players have PlayerInfo.nation = 'Sweden'; SeasonStatus.TEAM records a player’s team.", "SQL": "SELECT T.TEAM FROM ( SELECT T2.TEAM, COUNT(DISTINCT T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.nation = 'Sweden' GROUP BY T2.TEAM HAVING COUNT(DISTINCT T1.ELITEID) = (SELECT COUNT(DISTINCT T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.nation = 'Sweden' GROUP BY T2.TEAM ORDER BY COUNT(DISTINCT T1.ELITEID) DESC LIMIT 1)  ) AS T"}
{"question_id": 7067, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the IDs of employees with more than 20 vacation hours who wish to receive email promotions.", "evidence": "Person.EmailPromotion values 1 and 2 indicate willingness to receive email promotions; Employee.VacationHours records vacation hours.", "SQL": "SELECT e.BusinessEntityID\nFROM Employee AS e\nJOIN Person AS p ON p.BusinessEntityID = e.BusinessEntityID\nWHERE e.VacationHours > 20\n  AND p.EmailPromotion IN (1,2);"}
{"question_id": 7086, "db_id": "works_cycles", "grading_method": "set", "question": "What percentage of orders contain at most three items in total and have no discount on any item?", "evidence": "SalesOrderHeader.SalesOrderID identifies an order. SalesOrderDetail.OrderQty records the quantity on an order line; UnitPriceDiscount records its discount, with 0 meaning no discount. Orders with no detail rows have no items or discounts.", "SQL": "WITH order_totals AS (\n    SELECT h.SalesOrderID,\n           COALESCE(SUM(d.OrderQty), 0) AS total_quantity,\n           MAX(CASE WHEN d.UnitPriceDiscount <> 0 THEN 1 ELSE 0 END) AS has_discount\n    FROM SalesOrderHeader AS h\n    LEFT JOIN SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID\n    GROUP BY h.SalesOrderID\n)\nSELECT 100.0 * SUM(CASE WHEN total_quantity <= 3 AND has_discount = 0\n                       THEN 1 ELSE 0 END) / NULLIF(COUNT(*), 0) AS percentage\nFROM order_totals;"}
{"question_id": 7096, "db_id": "works_cycles", "grading_method": "set", "question": "Sum the total number of products rejected for having a trim length that is too long.", "evidence": "number of product rejected refers to ScrapedQty; trim length that is too long refers to scrap reason where Name = 'Trim length too long'", "SQL": "SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long'"}
{"question_id": 7169, "db_id": "works_cycles", "grading_method": "set", "question": "What is the numeric credit-rating code of the company with business entity rowguid “33671A4E-DF2B-4879-807B-E3F930DD5C0C”?", "evidence": "Vendor.CreditRating uses 1 for Superior, 2 for Excellent, 3 for Above average, 4 for Average, and 5 for Below average.", "SQL": "SELECT T1.CreditRating FROM Vendor AS T1 INNER JOIN BusinessEntity AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.rowguid = '33671A4E-DF2B-4879-807B-E3F930DD5C0C'"}
{"question_id": 7174, "db_id": "works_cycles", "grading_method": "set", "question": "What's Lynn N Tsoflias's job title?", "evidence": "", "SQL": "SELECT T2.JobTitle FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'Lynn' AND T1.MiddleName = 'N' AND T1.LastName = 'Tsoflias'"}
{"question_id": 7282, "db_id": "works_cycles", "grading_method": "set", "question": "What is the name of the product that gets the most reviews?", "evidence": "most reviews refers to MAX(count(ProductID))", "SQL": "SELECT p.`Name`\nFROM `ProductReview` r\nJOIN `Product` p ON p.`ProductID` = r.`ProductID`\nGROUP BY p.`ProductID`, p.`Name`\nHAVING COUNT(*) = (\n    SELECT MAX(cnt)\n    FROM (\n        SELECT COUNT(*) AS cnt\n        FROM `ProductReview`\n        GROUP BY `ProductID`\n    ) sub\n);"}
{"question_id": 7290, "db_id": "works_cycles", "grading_method": "set", "question": "Which products have changed price at least twice? List their names.", "evidence": "ProductListPriceHistory records historical list prices and their start dates. A history row does not necessarily represent a transition to a different price.", "SQL": "WITH price_history AS (\n    SELECT ProductID, ListPrice,\n           LAG(ListPrice) OVER (\n               PARTITION BY ProductID ORDER BY StartDate\n           ) AS previous_price\n    FROM ProductListPriceHistory\n)\nSELECT P.Name\nFROM Product AS P\nINNER JOIN price_history AS H ON H.ProductID = P.ProductID\nWHERE H.ListPrice <> H.previous_price\nGROUP BY P.ProductID, P.Name\nHAVING COUNT(*) >= 2;"}
{"question_id": 7292, "db_id": "works_cycles", "grading_method": "set", "question": "What is the highest vendor's selling price for Hex Nut 5?", "evidence": "vendor's selling price refers to StandardPrice", "SQL": "SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice DESC LIMIT 1"}
{"question_id": 7301, "db_id": "works_cycles", "grading_method": "set", "question": "What are the email addresses of reviewers who gave \"HL Mountain Pedal\" its lowest rating?", "evidence": "ProductReview.EmailAddress is the address supplied with the review.", "SQL": "SELECT DISTINCT pr.EmailAddress\nFROM ProductReview AS pr\nJOIN Product AS p ON p.ProductID = pr.ProductID\nWHERE p.Name = 'HL Mountain Pedal'\n  AND pr.Rating = (\n        SELECT MIN(pr2.Rating)\n        FROM ProductReview AS pr2\n        WHERE pr2.ProductID = p.ProductID\n      );"}
{"question_id": 7306, "db_id": "works_cycles", "grading_method": "set", "question": "What is the product that has the highest average rating from the mountain product line?", "evidence": "mountain product line refers to ProductLine = 'M'; highest average rating = max(divide(sum(Rating), count(ProductReview)))", "SQL": "SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ProductLine = 'M' GROUP BY T2.Name ORDER BY CAST(SUM(T1.Rating) AS REAL) / COUNT(T1.ProductID) DESC LIMIT 1"}
{"question_id": 7325, "db_id": "works_cycles", "grading_method": "set", "question": "Please provide contact details of all Marketing Managers. State their first name, last name, and email address.", "evidence": "Marketing Manager is a job title", "SQL": "SELECT p.FirstName, p.LastName, ea.EmailAddress FROM   Person AS p JOIN   Employee AS e ON p.BusinessEntityID = e.BusinessEntityID LEFT JOIN EmailAddress AS ea ON p.BusinessEntityID = ea.BusinessEntityID WHERE  e.JobTitle = 'Marketing Manager'"}
{"question_id": 7374, "db_id": "works_cycles", "grading_method": "set", "question": "Which products have the largest size measured in centimeters, and what are their reorder points?", "evidence": "Product.Size is text; Product.SizeUnitMeasureCode = 'CM' denotes centimeters. Product.ReorderPoint is the replenishment threshold.", "SQL": "SELECT Name, ReorderPoint \nFROM Product WHERE SizeUnitMeasureCode = 'CM' AND Size = (SELECT max(size) from Product where SizeUnitMeasureCode = 'CM' )"}
{"question_id": 7473, "db_id": "image_and_language", "grading_method": "set", "question": "How many object samples are there in image no.1?", "evidence": "object samples refers to OBJ_SAMPLE_ID; image no.1 refers to IMG_ID = 1", "SQL": "SELECT COUNT(OBJ_SAMPLE_ID) FROM IMG_OBJ WHERE IMG_ID = 1"}
{"question_id": 7488, "db_id": "image_and_language", "grading_method": "set", "question": "For image 1, list the bounding boxes of both objects in each “by” relationship. Give each box’s x-coordinate, y-coordinate, width and height, without repeating any boxes.", "evidence": "Image number refers to IMG_ID; relationship labels are recorded in PRED_CLASS. Bounding-box coordinates and dimensions are recorded in X, Y, W and H.", "SQL": "SELECT DISTINCT IO.`X`, IO.`Y`, IO.`W`, IO.`H`\nFROM `PRED_CLASSES` AS PC\nJOIN `IMG_REL` AS IR ON PC.`PRED_CLASS_ID` = IR.`PRED_CLASS_ID`\nJOIN `IMG_OBJ` AS IO ON IO.`IMG_ID` = IR.`IMG_ID`\n                     AND IO.`OBJ_SAMPLE_ID` IN (IR.`OBJ1_SAMPLE_ID`, IR.`OBJ2_SAMPLE_ID`)\nWHERE IR.`IMG_ID` = 1\n  AND PC.`PRED_CLASS` = 'by';"}
{"question_id": 7627, "db_id": "hockey", "grading_method": "set", "question": "Which goalies played in the most seasons? Give their first and last names and their average playing time per regular season in minutes, rounded to two decimal places.", "evidence": "Goalies.year identifies the season, and Goalies.Min records regular-season playing time in minutes. A goalie can have multiple records for the same season. Names are recorded in Master.firstName and Master.lastName.", "SQL": "WITH seasons_cnt AS (\n    SELECT playerID,\n           COUNT(DISTINCT year) AS seasons\n    FROM `Goalies`\n    GROUP BY playerID\n),\nmax_goalies AS (\n    SELECT playerID\n    FROM seasons_cnt\n    WHERE seasons = (SELECT MAX(seasons) FROM seasons_cnt)\n),\navg_minutes AS (\n    SELECT g.playerID,\n           ROUND(SUM(CAST(g.Min AS REAL))/COUNT(DISTINCT year), 2) AS avg_minutes\n    FROM `Goalies` g\n    WHERE g.playerID IN (SELECT playerID FROM max_goalies)\n    GROUP BY g.playerID\n)\nSELECT m.firstName,\n       m.lastName,\n       a.avg_minutes\nFROM   avg_minutes a\nJOIN   `Master` m ON m.playerID = a.playerID"}
{"question_id": 7724, "db_id": "hockey", "grading_method": "set", "question": "What are the overall power-play percentages of the teams with the highest total number of losses across all seasons?", "evidence": "Overall power-play percentage refers to 100.0 * SUM(PPG) / SUM(PPC), calculated across all seasons for each team grouped by tmID; highest total number of losses refers to the largest SUM(L) across those team groups. Include all teams tied for that largest total.", "SQL": "SELECT CAST(SUM(PPG) AS REAL) * 100 / SUM(PPC) FROM Teams GROUP BY tmID HAVING SUM(L) = (SELECT SUM(L) FROM Teams GROUP BY tmID ORDER BY SUM(L) DESC LIMIT 1);"}
{"question_id": 7738, "db_id": "hockey", "grading_method": "set", "question": "What is the name of the losing team during an exhibition game in 1912?", "evidence": "exhibition game refers to note = 'EX'; team of losing team refers to tmIDLoser", "SQL": "SELECT T2.name FROM SeriesPost AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND tmIDLoser = tmID WHERE T1.note = 'EX' AND T2.year = '1912'"}
{"question_id": 7764, "db_id": "hockey", "grading_method": "set", "question": "Please list the names of the teams that had a tie in 1909.", "evidence": "tie refers to T>0; year = 1909;", "SQL": "SELECT DISTINCT `name` FROM `Teams` WHERE `year` = 1909 AND `T` > 0"}
{"question_id": 7779, "db_id": "hockey", "grading_method": "set", "question": "Which coach was the first to coach the Montreal Canadiens? Give his first name.", "evidence": "Coaches.year records a coaching season; Master.firstName records a coach’s first name. Montreal Canadiens is recorded in Teams.name as 'Montreal Canadiens'.", "SQL": "SELECT T3.firstName FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T2.name = 'Montreal Canadiens' ORDER BY T1.year LIMIT 1"}
{"question_id": 7808, "db_id": "hockey", "grading_method": "set", "question": "What are the total goals for player ID aaltoan01, and how old is the player now?", "evidence": "Scoring.G records goals; Master.birthyear records birth year. Age here means the current calendar year minus birth year.", "SQL": "SELECT SUM(T2.G), STRFTIME('%Y', CURRENT_TIMESTAMP) - T1.birthyear FROM Master AS T1 INNER JOIN Scoring AS T2 ON T1.playerID = T2.playerID WHERE T1.playerID = 'aaltoan01' GROUP BY T1.birthyear"}
{"question_id": 7828, "db_id": "world", "grading_method": "set", "question": "Provide the name, capital city, and official language(s) of the country with the highest life expectancy.", "evidence": "Country.Capital identifies the capital city; CountryLanguage.IsOfficial = 'T' denotes an official language. Country.LifeExpectancy records life expectancy.", "SQL": "SELECT  c.`Name`          AS CountryName,\n        ci.`Name`         AS CapitalCity,\n        cl.`Language`     AS OfficialLanguage\nFROM    `Country` c\nJOIN    `City` ci ON c.`Capital` = ci.`ID`\nJOIN    `CountryLanguage` cl\n      ON cl.`CountryCode` = c.`Code`\n     AND cl.`IsOfficial` = 'T'\nWHERE   c.`LifeExpectancy` = (SELECT MAX(`LifeExpectancy`) FROM `Country`);"}
{"question_id": 7873, "db_id": "world", "grading_method": "set", "question": "Which country has the smallest surface area?", "evidence": "which country refers to country name; smallest surface area refers to MIN(smallest surface area);", "SQL": "SELECT Name FROM Country ORDER BY SurfaceArea ASC LIMIT 1"}
{"question_id": 7883, "db_id": "world", "grading_method": "set", "question": "Among the countries containing the five most populous cities in the world, which country has the most languages?", "evidence": "City.Population records city population; CountryLanguage.Language records languages used in a country.", "SQL": "WITH Top5Cities AS (\n    SELECT CountryCode\n    FROM City\n    ORDER BY Population DESC\n    LIMIT 5\n),\nTopCountries AS (\n    SELECT DISTINCT CountryCode\n    FROM Top5Cities\n),\nLangCount AS (\n    SELECT c.Name,\n           COUNT(DISTINCT cl.Language) AS num\n    FROM TopCountries tc\n    JOIN Country c         ON c.Code = tc.CountryCode\n    JOIN CountryLanguage cl ON cl.CountryCode = tc.CountryCode\n    GROUP BY c.Code\n)\nSELECT Name\nFROM LangCount\nWHERE num = (SELECT MAX(num) FROM LangCount);"}
{"question_id": 7957, "db_id": "music_platform_2", "grading_method": "set", "question": "List the titles of the podcasts belong to the art category.", "evidence": "art category refers to category = 'arts'", "SQL": "SELECT  p.`title` FROM `podcasts` AS p JOIN `categories` AS c USING(`podcast_id`) WHERE c.`category` = 'arts';"}
{"question_id": 7984, "db_id": "music_platform_2", "grading_method": "set", "question": "Please list the titles of the podcasts for which the author whose ID is F7E5A318989779D has written a review.", "evidence": "author whose ID is F7E5A318989779D refers to author_id = 'F7E5A318989779D'", "SQL": "SELECT T1.title FROM podcasts AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.author_id = 'F7E5A318989779D'"}
{"question_id": 7995, "db_id": "university", "grading_method": "set", "question": "Which universities had the largest publication rank number in 2014? Include any ties.", "evidence": "Publication rank refers to criteria_name = 'Publications Rank'; its numerical value is recorded in score. University names are recorded in university_name.", "SQL": "SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Publications Rank' AND T2.year = 2014 AND T1.id = 17 AND T2.score = (SELECT MAX(score) FROM university_ranking_year WHERE ranking_criteria_id = 17 AND year = 2014);"}
{"question_id": 8158, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many no.9 items from store no.11 were sold on 2012/12/7?", "evidence": "no. 9 item refers to item_nbr = 9; store no.11 refers to store_nbr = 11; sold on 2012/12/7 refers to date = '2012-12-07'", "SQL": "SELECT units FROM sales_in_weather WHERE `date` = '2012-12-07' AND store_nbr = 11 AND item_nbr = 9"}
{"question_id": 8172, "db_id": "sales_in_weather", "grading_method": "set", "question": "Show the sea level status recorded by the weather station of store no.19 on 2013/2/24.", "evidence": "store no.19 refers to store_nbr = 19; on 2013/2/24 refers to date = '2013-02-24'; sea level status refers to sealevel", "SQL": "SELECT T1.sealevel FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-24' AND T2.store_nbr = 19"}
{"question_id": 8222, "db_id": "mondial_geo", "grading_method": "set", "question": "Which countries have population growth above 2% and an infant mortality rate below 5%? List their names and populations.", "evidence": "Country names and populations are recorded in country.Name and country.Population. population.Population_Growth is the annual growth rate expressed as a percentage; population.Infant_Mortality is expressed per thousand.", "SQL": "SELECT T1.Name, T1.Population FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country WHERE T2.Population_Growth > 2 AND T2.Infant_Mortality < 50"}
{"question_id": 8234, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the value of Brazil’s service-sector GDP?", "evidence": "economy.GDP records GDP; economy.Service records the percentage attributable to services. Brazil is recorded in country.Name as 'Brazil'.", "SQL": "SELECT T2.Service * T2.GDP /100 FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Brazil'"}
{"question_id": 8236, "db_id": "mondial_geo", "grading_method": "set", "question": "List all countries with negative growth in population. State the country name, population and growth.", "evidence": "Negative growth in population means population_growth < 0", "SQL": "SELECT T1.Name, T1.Population, T2.Population_Growth FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country WHERE T2.Population_Growth < 0"}
{"question_id": 8239, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the infant mortality rate for Ethiopia?", "evidence": "Ethiopia is one of country names", "SQL": "SELECT T2.Infant_Mortality FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Ethiopia'"}
{"question_id": 8344, "db_id": "mondial_geo", "grading_method": "set", "question": "Provide all rivers name and length in USA.", "evidence": "USA is a country", "SQL": "SELECT DISTINCT r.`Name`, r.`Length`\nFROM `river` AS r\nJOIN `geo_river` AS gr ON gr.`River` = r.`Name`\nWHERE gr.`Country` = 'USA';"}
{"question_id": 8349, "db_id": "mondial_geo", "grading_method": "set", "question": "Which countries are dependent on the British Crown?", "evidence": "dependent on the British Crown refers to dependent='GB'", "SQL": "SELECT c.`Name`\nFROM politics p\nJOIN country c ON c.`Code` = p.`Country`\nWHERE p.`Dependent` = 'GB';"}
{"question_id": 8425, "db_id": "mondial_geo", "grading_method": "set", "question": "Of all the countries that share territory with more than one continent, in which of them does the average population not exceed 10 inhabitants per square kilometer?", "evidence": "", "SQL": "SELECT NAME FROM country WHERE CODE IN ( SELECT country FROM encompasses GROUP BY country HAVING COUNT(continent) > 1 ) AND population / Area <= 10"}
{"question_id": 8499, "db_id": "mondial_geo", "grading_method": "set", "question": "Which nation, with a population ranging from 60,000,000 to 99,000,000, has the greatest gross domestic product?", "evidence": "GDP refers to gross domestic product; Nation and country are synonyms", "SQL": "with sub as (SELECT T1.Name, T2.GDP FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T1.Population BETWEEN 60000000 AND 99000000)\nselect Name from sub where GDP = (select max(GDP) from sub)"}
{"question_id": 8614, "db_id": "chicago_crime", "grading_method": "set", "question": "What are the first and last names of the alderman for the ward where case JB103470 occurred?", "evidence": "case No. JB103470 refers to case_number = 'JB103470'; full name refers to alderman_first_name, alderman_last_name", "SQL": "SELECT T1.alderman_first_name, T1.alderman_last_name FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.case_number = 'JB103470'"}
{"question_id": 8636, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the legislative district's office address where 010XX W LAKE ST is located?", "evidence": "the legislative district's office address refers to ward_office_address; 010XX W LAKE ST refers to block = '010XX W LAKE ST'", "SQL": "SELECT T1.ward_office_address FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.block = '010XX W LAKE ST' GROUP BY T1.ward_office_address"}
{"question_id": 8682, "db_id": "chicago_crime", "grading_method": "set", "question": "Which community area has the highest number of crimes reported on the street?", "evidence": "reported on the street refers to location_description = 'STREET'; community area with highest number of crime refers to Max(Count(location_description)); community area refers to community_area_name", "SQL": "SELECT CA.`community_area_name` FROM `Community_Area` AS CA JOIN `Crime` AS C ON C.`community_area_no` = CA.`community_area_no` WHERE C.`location_description` = 'STREET' GROUP BY CA.`community_area_name` HAVING COUNT(*) = ( SELECT MAX(crime_count) FROM ( SELECT COUNT(*) AS crime_count FROM `Crime` AS C2 JOIN `Community_Area` AS CA2 ON C2.`community_area_no` = CA2.`community_area_no` WHERE C2.`location_description` = 'STREET' GROUP BY CA2.`community_area_name` ) AS CrimeCounts );"}
{"question_id": 8699, "db_id": "chicago_crime", "grading_method": "set", "question": "How many different types of crimes, according to the primary description, have occurred in the Hermosa neighborhood?", "evidence": "\"Hermosa\" is the neighborhood_name", "SQL": "SELECT COUNT(DISTINCT `primary_description`)\nFROM `Crime`     AS c\nJOIN `IUCR`      AS i  ON i.`iucr_no` = c.`iucr_no`\nJOIN `Neighborhood` AS n ON n.`community_area_no` = c.`community_area_no`\nWHERE n.`neighborhood_name` = 'Hermosa';"}
{"question_id": 8704, "db_id": "chicago_crime", "grading_method": "set", "question": "In which districts have there been the most intimidation-type crimes?", "evidence": "most intimidation-type crime refers to Max(Count(primary_description = 'INTIMIDATION')); district refers to district_name", "SQL": "SELECT T3.district_name FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.primary_description = 'INTIMIDATION' GROUP BY T3.district_name HAVING COUNT(T1.primary_description) = (SELECT MAX(Counted) FROM (SELECT COUNT(T1.primary_description) AS Counted FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.primary_description = 'INTIMIDATION' GROUP BY T3.district_name) AS counts);"}
{"question_id": 8725, "db_id": "chicago_crime", "grading_method": "set", "question": "How many crime against society were reported in Englewood?", "evidence": "\"Englewood\" is the community_area_name; 'Society' is the crime_against", "SQL": "SELECT SUM(CASE WHEN T3.community_area_name = 'Englewood' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.crime_against = 'Society'"}
{"question_id": 8742, "db_id": "chicago_crime", "grading_method": "set", "question": "What types of crime were reported most often in the Rogers Park community area?", "evidence": "Identify Rogers Park using Community_Area.community_area_name = 'Rogers Park'. Crime types are stored in FBI_Code.title. Count the Crime records for each type and return all types tied for the highest count.", "SQL": "SELECT T1.`title` FROM `FBI_Code` AS T1 JOIN `Crime`  AS T2 ON T1.`fbi_code_no` = T2.`fbi_code_no` JOIN `Community_Area` AS T3 ON T2.`community_area_no` = T3.`community_area_no` WHERE T3.`community_area_name` = 'Rogers Park' GROUP BY T1.`title` HAVING COUNT(*) = (SELECT MAX(Counted) FROM (SELECT COUNT(*) AS Counted FROM `FBI_Code` AS T1 JOIN `Crime`  AS T2 ON T1.`fbi_code_no` = T2.`fbi_code_no` JOIN `Community_Area` AS T3 ON T2.`community_area_no` = T3.`community_area_no` WHERE T3.`community_area_name` = 'Rogers Park' GROUP BY T1.`title`) AS counts);"}
{"question_id": 8745, "db_id": "chicago_crime", "grading_method": "set", "question": "Provide the ward number with the highest population.", "evidence": "highest population refers to Max(Population); ward number refers to ward_no", "SQL": "SELECT `ward_no`\nFROM `Ward`\nWHERE  CAST(`Population` AS INT) = (SELECT max( CAST(`Population` AS INT)) FROM `Ward`)"}
{"question_id": 8749, "db_id": "chicago_crime", "grading_method": "set", "question": "List down the district's commander associated with the crime that happened at the yard and has a beat of 532.", "evidence": "beat of 532 refers to beat = 532; happened in the Yard refers to location_description = 'YARD'; district commander refers to commander", "SQL": "SELECT T2.commander FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.location_description = 'YARD' AND T1.beat = 532"}
{"question_id": 8755, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the full name of the alderman of ward no.21?", "evidence": "full name of alderman refers to alderman_first_name, alderman_last_name, alderman_name_suffix", "SQL": "SELECT alderman_first_name, alderman_last_name, alderman_name_suffix FROM Ward WHERE ward_no = 21"}
{"question_id": 8764, "db_id": "chicago_crime", "grading_method": "set", "question": "Please list the case numbers of all the incidents with the generic description of \"BATTERY\" in the IUCR classification.", "evidence": "general description refers to primary_description; 'BATTERY' is the primary_description", "SQL": "SELECT T2.case_number FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'"}
{"question_id": 8789, "db_id": "food_inspection", "grading_method": "set", "question": "Which business had the most number of inspections? Give the Id number for that business.", "evidence": "the most number of inspections refers to MAX(COUNT(business_id)); Id number for that business refers to business_id;", "SQL": "SELECT `business_id`\nFROM `inspections`\nGROUP BY `business_id`\nHAVING COUNT(*) = (\n    SELECT MAX(cnt)\n    FROM (\n        SELECT COUNT(*) AS cnt\n        FROM `inspections`\n        GROUP BY `business_id`\n    )\n)"}
{"question_id": 8802, "db_id": "food_inspection", "grading_method": "set", "question": "What is the average score for \"Chairman Bao\" in all its unscheduled routine inspections?", "evidence": "DIVIDE(SUM(score where type = 'Routine - Unscheduled' and name = 'Chairman Bao'), COUNT(type = 'Routine - Unscheduled' where name = 'Chairman Bao'));", "SQL": "SELECT AVG(`score`) \nFROM `inspections` AS i\nJOIN `businesses` AS b ON i.`business_id` = b.`business_id`\nWHERE b.`name` = 'Chairman Bao'\n  AND i.`type` = 'Routine - Unscheduled';"}
{"question_id": 8810, "db_id": "food_inspection", "grading_method": "set", "question": "In 2016, which city has the highest number of establishments with the highest health and safety hazards?", "evidence": "the highest health and safety hazards refer to risk_category = 'High Risk'; year(date) = 2016; establishments has the same meaning as businesses;", "SQL": "SELECT b.city\nFROM businesses b\nJOIN (\n    SELECT DISTINCT business_id\n    FROM violations\n    WHERE risk_category = 'High Risk'\n      AND STRFTIME('%Y', `date`) = '2016'\n) v ON b.business_id = v.business_id\nGROUP BY b.city\nORDER BY COUNT(*) DESC\nLIMIT 1;"}
{"question_id": 8811, "db_id": "food_inspection", "grading_method": "set", "question": "What is the name of the establishment with the lowest inspection score of all time?", "evidence": "the lowest inspection score refers to MIN(score);", "SQL": "SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = ( SELECT MIN(score) FROM inspections )"}
{"question_id": 8824, "db_id": "food_inspection", "grading_method": "set", "question": "How many eateries have a Low Risk violation described as Unpermitted food facility?", "evidence": "Eateries are businesses. violations.risk_category uses 'Low Risk'; violations.description uses 'Unpermitted food facility'.", "SQL": "SELECT COUNT(DISTINCT business_id) FROM violations WHERE risk_category = 'Low Risk' AND description = 'Unpermitted food facility'"}
{"question_id": 8849, "db_id": "food_inspection", "grading_method": "set", "question": "Among the owners from Cameron Park, what is the business name of the business with a score of 100?", "evidence": "Cameron Park is a name of city;", "SQL": "SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.owner_city = 'Cameron Park' AND T1.score = 100"}
{"question_id": 8850, "db_id": "food_inspection", "grading_method": "set", "question": "List the violation type IDs for businesses with IDs from 30 to 50 located at 747 IRVING St, San Francisco.", "evidence": "Violation type IDs are recorded in violations.violation_type_id; business address and city are businesses.address and businesses.city.", "SQL": "SELECT DISTINCT T1.violation_type_id FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.business_id BETWEEN 30 AND 50 AND T2.address = '747 IRVING St' AND T2.city LIKE 'San Francisco'"}
{"question_id": 8871, "db_id": "cookbook", "grading_method": "set", "question": "Please list the names of all the ingredients needed for the recipe \"Raspberry Chiffon Pie\" that do not need preprocessing.", "evidence": "Raspberry Chiffon Pie refers to title; do not need preprocessing refers to preparation IS NULL", "SQL": "SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Raspberry Chiffon Pie' AND T2.preparation IS NULL"}
{"question_id": 8915, "db_id": "cookbook", "grading_method": "set", "question": "Provide the title and total time of the recipe which can be made with only lima beans.", "evidence": "total time refers to total time refers to TOTAL(prep_min, cook_min, stnd_min); lima beans is a name of an ingredient", "SQL": "SELECT r.title,\n       (r.prep_min + r.cook_min + r.stnd_min) AS total_time\nFROM Recipe r\nJOIN Quantity q ON q.recipe_id = r.recipe_id\nJOIN Ingredient i ON i.ingredient_id = q.ingredient_id\nGROUP BY r.recipe_id\nHAVING COUNT(DISTINCT i.name) = 1                      -- exactly one ingredient overall\n   AND MAX(CASE WHEN i.name = 'lima beans' THEN 1 ELSE 0 END) = 1;  -- that ingredient is lima beans"}
{"question_id": 8924, "db_id": "cookbook", "grading_method": "set", "question": "Which recipe has the highest calories?", "evidence": "the highest calories refers to MAX(calories)", "SQL": "SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.calories DESC LIMIT 1"}
{"question_id": 8944, "db_id": "human_resources", "grading_method": "set", "question": "Which employee's job position requires a higher education level, Jose Rodriguez or Sandy Adams? Output first name and last name separately.", "evidence": "Jose Rodriguez AND Sandy Adams are the fullname of employee; full name = firstname, lastname; higher education level refers to MAX(educationrequired)", "SQL": "SELECT T1.firstname, T1.lastname FROM employee AS T1  INNER JOIN position AS T2  ON T1.positionID = T2.positionID WHERE (T1.lastname = 'Adams' AND T1.firstname = 'Sandy') OR (T1.lastname = 'Rodriguez' AND T1.firstname = 'Jose') ORDER BY T2.educationrequired DESC LIMIT 1"}
{"question_id": 8949, "db_id": "human_resources", "grading_method": "set", "question": "How much higher, as a percentage, is the average Trainee salary than the minimum salary for the role?", "evidence": "employee.salary is annual salary; position.minsalary is the position’s minimum salary. Both use currency text such as 'US$69,000.00'. The minimum salary is the baseline for the percentage increase.", "SQL": "SELECT 100 * (AVG(CAST(REPLACE(SUBSTR(T1.salary, 4), ',', '') AS REAL)) - CAST(REPLACE(SUBSTR(T2.minsalary, 4), ',', '') AS REAL)) / CAST(REPLACE(SUBSTR(T2.minsalary, 4), ',', '') AS REAL) AS per FROM employee AS T1  INNER JOIN position AS T2  ON T1.positionID = T2.positionID WHERE T2.positiontitle = 'Trainee'"}
{"question_id": 9009, "db_id": "bike_share_1", "grading_method": "set", "question": "When was the hottest temperature recorded? If there are multiple dates with the hottest temperature, indicate all of the dates.", "evidence": "the hottest temperature refers to max_temperature_f;", "SQL": "SELECT  date FROM weather WHERE max_temperature_f = ( SELECT MAX(max_temperature_f) FROM weather WHERE max_temperature_f IS NOT NULL AND max_temperature_f IS NOT '' )"}
{"question_id": 9028, "db_id": "bike_share_1", "grading_method": "set", "question": "How many docks were available at the starting station of trip ID 4312 in the first status reading during its starting minute?", "evidence": "trip.start_station_id identifies the starting station. trip.start_date uses M/D/YYYY H:MM; status.time uses YYYY/MM/DD HH:MM:SS. status.docks_available records available docks at that reading.", "SQL": "SELECT T2.docks_available\nFROM trip AS T1 JOIN status AS T2\nON T2.station_id=T1.start_station_id\nAND T2.time LIKE printf('%04d/%02d/%02d %s:',\n CAST(substr(T1.start_date,instr(T1.start_date,' ')-4,4) AS INTEGER),\n CAST(T1.start_date AS INTEGER),\n CAST(substr(T1.start_date,instr(T1.start_date,'/')+1) AS INTEGER),\n substr(T1.start_date,instr(T1.start_date,' ')+1)) || '%'\nWHERE T1.id=4312\nORDER BY T2.time LIMIT 1;\n"}
{"question_id": 9040, "db_id": "bike_share_1", "grading_method": "set", "question": "How many stations in San Francisco are installed in 2014?", "evidence": "stations refers to name; San Francisco refers to city = 'San Francisco'; installed in 2014 refers to installation_date like'%2014';", "SQL": "SELECT SUM(CASE WHEN city = 'San Francisco' AND SUBSTR(installation_date, -4) = '2014' THEN 1 ELSE 0 END) FROM station"}
{"question_id": 9057, "db_id": "bike_share_1", "grading_method": "set", "question": "Of the customer trips that ended in 2015 on days with weather recorded for their destination city, what percentage ended on rainy days? Round your answer to 2 decimal places.", "evidence": "Customer trips have trip.subscription_type = 'Customer'. trip.end_station_id identifies the destination station in station.id. weather.events contains 'Rain' for rainy days, including combined weather categories. weather.date uses M/D/YYYY; trip.end_date uses M/D/YYYY H:MM. Daily weather for station.city is represented by weather.zip_code: San Francisco 94107, San Jose 95113, Mountain View 94041, Palo Alto 94301, and Redwood City 94063. trip.zip_code records the member’s home ZIP, not the station location.", "SQL": "SELECT ROUND(100.0 * SUM(CASE WHEN w.events LIKE '%Rain%' THEN 1 ELSE 0 END) / COUNT(*), 2)\nFROM trip AS t\nJOIN station AS s ON s.id = t.end_station_id\nJOIN weather AS w ON w.zip_code = CASE s.city\n WHEN 'San Francisco' THEN '94107' WHEN 'San Jose' THEN '95113'\n WHEN 'Mountain View' THEN '94041' WHEN 'Palo Alto' THEN '94301'\n WHEN 'Redwood City' THEN '94063' END\n AND w.date = SUBSTR(t.end_date, 1, INSTR(t.end_date, ' ') - 1)\nWHERE SUBSTR(w.date, -4) = '2015' AND t.subscription_type = 'Customer';"}
{"question_id": 9117, "db_id": "movie_3", "grading_method": "set", "question": "Please list the titles of all the films starring the actor PENELOPE GUINESS.", "evidence": "", "SQL": "SELECT T2.title FROM film_actor AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id INNER JOIN actor AS T3 ON T1.actor_id = T3.actor_id WHERE T3.first_name = 'PENELOPE' AND T3.last_name = 'GUINESS'"}
{"question_id": 9139, "db_id": "movie_3", "grading_method": "set", "question": "What is the average replacement cost of the films under the category of \"Horror\"?", "evidence": "\"Horror\" is the name of category; average replacement cost = Divide (Sum(replacement_cost), Count(film_id where name = Horror))", "SQL": "SELECT AVG(T3.replacement_cost) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T2.name = 'Horror'"}
{"question_id": 9176, "db_id": "movie_3", "grading_method": "set", "question": "List the names of the films that are more than 180 minutes long.", "evidence": "more than 180 min long refers to length > 180; name of film refers to title", "SQL": "SELECT title FROM film WHERE length > 180"}
{"question_id": 9229, "db_id": "movie_3", "grading_method": "set", "question": "List the last names of actors in the film described as \"A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies\".", "evidence": "The quoted film description is recorded in film.description; actors’ surnames are recorded in actor.last_name.", "SQL": "SELECT T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.description = 'A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies'"}
{"question_id": 9334, "db_id": "movie_3", "grading_method": "set", "question": "List the descriptions of movies under the category Travel.", "evidence": "the category Travel refers to category.name = 'Travel'", "SQL": "SELECT T1.description FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.`name` = 'Travel'"}
{"question_id": 9362, "db_id": "movie_3", "grading_method": "set", "question": "What is the title of the restricted film, whose length is 71 minutes and whose replacement cost is $29.99?", "evidence": "restricted means rating = 'R'; length is 71 minutes refers to length = 71; replacement cost is $29.99 refers to replacement_cost = 29.99", "SQL": "SELECT title FROM film WHERE replacement_cost = 29.99 AND rating = 'R' AND length = 71"}
{"question_id": 9374, "db_id": "movie_3", "grading_method": "set", "question": "Where can you rent the movie 'Wyoming Storm'? Identify the address of the rental store and the rental rate.", "evidence": "'Wyoming Storm' refers to title = 'WYOMING STORM'", "SQL": "SELECT T1.address, T4.rental_rate FROM address AS T1 INNER JOIN store AS T2 ON T1.address_id = T2.address_id INNER JOIN inventory AS T3 ON T2.store_id = T3.store_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T4.title = 'WYOMING STORM'"}