{"question_id": 3, "db_id": "movie_platform", "grading_method": "set", "question": "Name the titles of the movies with the most ratings.", "evidence": "movie with the most rating refers to MAX(COUNT(ratings));", "SQL": "SELECT m.movie_title FROM movies AS m JOIN ratings AS r ON m.movie_id = r.movie_id GROUP BY m.movie_id, m.movie_title HAVING COUNT(*) = (SELECT COUNT(*) FROM movies AS m JOIN ratings AS r ON m.movie_id = r.movie_id GROUP BY m.movie_id, m.movie_title ORDER BY COUNT(*) DESC LIMIT 1);"} {"question_id": 16, "db_id": "movie_platform", "grading_method": "set", "question": "What is the name of the most followed list?", "evidence": "most followed list refers to MAX(list_followers);", "SQL": "SELECT list_title FROM lists WHERE list_followers = (SELECT MAX(list_followers) FROM lists)"} {"question_id": 25, "db_id": "movie_platform", "grading_method": "set", "question": "In what year was Quentin Tarantino’s third-earliest movie released?", "evidence": "movies.director_name records 'Quentin Tarantino'; movies.movie_release_year records the release year.", "SQL": "SELECT movie_release_year \nFROM movies \nWHERE director_name = 'Quentin Tarantino' \nORDER BY movie_release_year ASC LIMIT 2, 1"} {"question_id": 27, "db_id": "movie_platform", "grading_method": "set", "question": "What is the average rating score of the movie \"When Will I Be Loved\" and who was its director? Show the average rating score and the name of its director.", "evidence": "average rating score = AVG(rating_score);", "SQL": "SELECT AVG(T1.rating_score), T2.director_name FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'When Will I Be Loved'"} {"question_id": 33, "db_id": "movie_platform", "grading_method": "set", "question": "Among the lists created by user 4208563, which ones have the highest number of followers? Indicate the list ids, how many followers they have, and whether the users were a subscriber or not when they created the lists.", "evidence": "User 4208563 refers to user_id;highest number of followers refers to MAX(list_followers); user_subscriber = 1 means that the user was a subscriber when he created the list; user_subscriber = 0 means the user was not a subscriber when he created the list (to replace); return 1 if the user was a subscriber when the list was created. Otherwise, return 0.", "SQL": "SELECT T2.list_id, T1.list_followers, T2.user_subscriber = 1 FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id AND T1.list_id = T2.list_id WHERE T2.user_id = 4208563 AND T1.list_followers = (SELECT MAX(T1.list_followers) FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id AND T1.list_id = T2.list_id WHERE T2.user_id = 4208563);"} {"question_id": 37, "db_id": "movie_platform", "grading_method": "set", "question": "How many different users gave “The Magnificent Ambersons” a rating of 2 or lower?", "evidence": "movies.movie_title records 'The Magnificent Ambersons'; ratings.rating_score records the score and ratings.user_id identifies the user.", "SQL": "SELECT COUNT(DISTINCT r.`user_id`) AS users_with_low_rating\nFROM `movies` AS m\nJOIN `ratings` AS r ON m.`movie_id` = r.`movie_id`\nWHERE m.`movie_title` = 'The Magnificent Ambersons'\n AND r.`rating_score` <= 2"} {"question_id": 38, "db_id": "movie_platform", "grading_method": "set", "question": "Among users who created a list in February 2016 and were eligible for trial when they created the list, which user has the most followers in their list in February 2016? Indicate their IDs.", "evidence": "lists_users.list_creation_date_utc records list creation date; user_eligible_for_trial = 1 denotes trial eligibility at creation. lists.list_followers records the list’s follower count.", "SQL": "WITH eligible_users AS (SELECT l.user_id AS user_id,\n l.list_followers AS list_followers\n FROM `lists` AS l\n JOIN `lists_users` AS lu\n ON l.list_id = lu.list_id\n AND l.user_id = lu.user_id\n WHERE lu.list_creation_date_utc BETWEEN '2016-02-01' AND '2016-02-29' AND user_eligible_for_trial = '1'\n)\nSELECT DISTINCT user_id FROM eligible_users WHERE list_followers = (SELECT MAX(list_followers) FROM eligible_users)"} {"question_id": 40, "db_id": "movie_platform", "grading_method": "set", "question": "Which movies received the most 5-star ratings among each director’s releases from 1960 through 1985? Only consider directors with at least 10 movies released during that period. List the movie titles and their 5-star rating counts, including ties.", "evidence": "a movie's 5-star count refers to SUM(CASE WHEN ratings.rating_score = 5 THEN 1 ELSE 0 END) over its ratings; consider only movies released during 1960 through 1985, and only directors with at least 10 such movies; list the titles and that count for every movie equal to its director's MAX, including ties", "SQL": "WITH qualifying_directors AS (\n SELECT `director_id`\n FROM `movies`\n WHERE `movie_release_year` BETWEEN 1960 AND 1985\n GROUP BY `director_id`\n HAVING COUNT(*) >= 10\n),\nqualifying_movies AS ( \n SELECT m.movie_id, m.director_id, m.movie_title\n FROM movies m\n JOIN qualifying_directors qd ON m.director_id = qd.director_id\n WHERE movie_release_year BETWEEN 1960 AND 1985\n GROUP BY m.movie_id\n),\nmovie_five_counts AS ( \n SELECT qm.movie_id, qm.director_id, qm.movie_title,\n SUM(CASE WHEN r.`rating_score` = 5 THEN 1 ELSE 0 END) AS five_count\n FROM qualifying_movies qm\n LEFT JOIN ratings r ON r.movie_id = qm.movie_id\n GROUP BY qm.movie_id\n),\nmax_five_counts AS (\n SELECT `director_id`, MAX(`five_count`) AS max_five\n FROM movie_five_counts\n GROUP BY `director_id`\n)\nSELECT mvfc.movie_title, mxfc.max_five\nFROM movie_five_counts mvfc\nJOIN max_five_counts mxfc\nON mvfc.director_id = mxfc.director_id AND mvfc.five_count = mxfc.max_five\n"} {"question_id": 47, "db_id": "movie_platform", "grading_method": "set", "question": "What are the titles of the movies directed by Christopher Nolan that received the highest number of five-star ratings?", "evidence": "movies.director_name records the director, including 'Christopher Nolan'; ratings.rating_score records the user’s star rating.", "SQL": "SELECT m.movie_title FROM movies AS m LEFT JOIN ratings AS r ON m.movie_id = r.movie_id AND r.rating_score = 5 WHERE m.director_name = 'Christopher Nolan' GROUP BY m.movie_id HAVING COUNT(CASE WHEN r.rating_score = 5 THEN 1 END) = (SELECT COUNT(CASE WHEN r.rating_score = 5 THEN 1 END) cnt FROM movies AS m LEFT JOIN ratings AS r ON m.movie_id = r.movie_id AND r.rating_score = 5 WHERE m.director_name = 'Christopher Nolan' GROUP BY m.movie_id ORDER BY cnt DESC LIMIT 1);"} {"question_id": 50, "db_id": "movie_platform", "grading_method": "set", "question": "How many movie lists were updated more than ten years after their creation year?", "evidence": "lists.list_creation_timestamp_utc and lists.list_update_timestamp_utc record creation and latest-update timestamps.", "SQL": "SELECT COUNT(*) FROM lists WHERE SUBSTR(list_update_timestamp_utc, 1, 4) - SUBSTR(list_creation_timestamp_utc, 1, 4) > 10"} {"question_id": 53, "db_id": "movie_platform", "grading_method": "set", "question": "How many movie lists created from January 2, 2010 onward have more than 200 followers?", "evidence": "lists.list_creation_timestamp_utc records creation timestamps with a YYYY-MM-DD date portion; lists.list_followers records follower count.", "SQL": "SELECT COUNT(*) FROM lists WHERE list_followers > 200 AND list_creation_timestamp_utc >= '2010-01-02';"} {"question_id": 54, "db_id": "movie_platform", "grading_method": "set", "question": "How many movie lists were created by user 83373278 when he or she was a subscriber?", "evidence": "the user was a subscriber when he created the list refers to user_subscriber = 1; user 83373278 refers to user_id = 83373278;", "SQL": "SELECT COUNT(*) FROM lists_users WHERE user_id = 83373278 AND user_subscriber = 1"} {"question_id": 59, "db_id": "movie_platform", "grading_method": "set", "question": "Was the user who created the list \"250 Favourite Films\" a trialist when he or she created the list? 'Yes' or 'No'", "evidence": "the user was a trialist when he created the list refers to user_trailist = 1; 250 Favourite Films is list_title;", "SQL": "SELECT CASE WHEN T2.user_trialist=1 THEN 'Yes' ELSE 'No' END FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.list_id = T2.list_id AND T1.user_id = T2.user_id WHERE T1.list_title = '250 Favourite Films'"} {"question_id": 62, "db_id": "movie_platform", "grading_method": "set", "question": "What's the description of user 85981819's movie list with the most followers?", "evidence": "user 85981819 refers to user_id = 85981819; most followers refers to Max(list_followers); description refers to list_descriptions;", "SQL": "SELECT T1.list_description FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.list_id = T2.list_id AND T1.user_id = T2.user_id WHERE T1.user_id = 85981819 AND T1.list_followers = (SELECT MAX(T3.list_followers) FROM lists AS T3 INNER JOIN lists_users AS T4 ON T3.list_id = T4.list_id AND T3.user_id = T4.user_id WHERE T3.user_id = 85981819)"} {"question_id": 64, "db_id": "movie_platform", "grading_method": "set", "question": "What's the avatar image of the user who created the movie list \"250 Favourite Films\"?", "evidence": "250 Favourite Films refers to list_title; avatar image refers to user_avatar_image_url;", "SQL": "SELECT T2.user_avatar_image_url FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.list_id = T2.list_id AND T1.user_id = T2.user_id WHERE T1.list_title = '250 Favourite Films'"} {"question_id": 70, "db_id": "movie_platform", "grading_method": "set", "question": "When did user 39115684 rate the movie \"A Way of Life\"?", "evidence": "'A Way of Life' refers to movie_title; user 39115684 refers to userid = 39115684;  when the user rate refers to rating_timestamp_utc;", "SQL": "SELECT r.rating_timestamp_utc\nFROM ratings AS r\nJOIN movies AS m ON r.movie_id = m.movie_id\nWHERE m.movie_title = 'A Way of Life'\n AND r.user_id = 39115684;"} {"question_id": 73, "db_id": "movie_platform", "grading_method": "set", "question": "How many users were trialists when they rated the movie \"A Way of Life\"?", "evidence": "'A Way of Life' refers to movie_title; the user was a trialist when he rated the movie refers to user_trialist = 1;", "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 = 'A Way of Life' AND T1.user_trialist = 1"} {"question_id": 76, "db_id": "movie_platform", "grading_method": "set", "question": "Which film did user 58149469 review with 1 like and 2 comments? Indicate the movie title.", "evidence": "ratings.critic_likes and ratings.critic_comments record likes and comments on a user’s 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 = 58149469 AND T1.critic_likes = 1 AND T1.critic_comments = 2"} {"question_id": 78, "db_id": "movie_platform", "grading_method": "set", "question": "How many ratings on the movie \"A Way of Life\" are made after the year 2011?", "evidence": "movies.movie_title records the title 'A Way of Life'. ratings.rating_timestamp_utc records the rating timestamp.", "SQL": "SELECT COUNT(DISTINCT T1.rating_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'A Way of Life' AND T1.rating_timestamp_utc >= '2012-01-01'"} {"question_id": 80, "db_id": "movie_platform", "grading_method": "set", "question": "Please list the movies rated by the user who created the movie list \"250 Favourite Films\".", "evidence": "250 Favourite Films' is list_title; movies refers to movie_title;", "SQL": "SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id INNER JOIN lists AS T3 ON T3.user_id = T1.user_id WHERE T3.list_title = '250 Favourite Films'"} {"question_id": 81, "db_id": "movie_platform", "grading_method": "set", "question": "What's the average rating score of the movie \"A Way of Life\"?", "evidence": "the movie \"A Way of Life\" refers to movies.movie_title = 'A Way of Life'; average rating score refers to AVG(ratings.rating_score) over the ratings of that movie", "SQL": "SELECT AVG(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'A Way of Life'"} {"question_id": 88, "db_id": "movie_platform", "grading_method": "set", "question": "Which of the films directed by Paul Thomas Anderson are the most popular among Mubi users? List the movie titles.", "evidence": "Paul Thomas Anderson is the director name; the most popular refers to Max(movie_popularity); films refers to movies;", "SQL": "SELECT movie_title FROM movies WHERE director_name = 'Paul Thomas Anderson' AND movie_popularity = (SELECT MAX(movie_popularity) FROM movies WHERE director_name = 'Paul Thomas Anderson')"} {"question_id": 90, "db_id": "movie_platform", "grading_method": "set", "question": "Please list the id of the director of the movie \"It's Winter\".", "evidence": "\"It's Winter\" is movie_title;", "SQL": "SELECT director_id FROM movies WHERE movie_title = 'It''s Winter'"} {"question_id": 94, "db_id": "movie_platform", "grading_method": "set", "question": "What are the names of the top three movies by total critic likes in user ratings?", "evidence": "total critic likes of a film refers to SUM(ratings.critic_likes) over that film's ratings; return movies.movie_title for the top three by that total, ordered from the largest", "SQL": "SELECT m.`movie_title`\nFROM `movies` m\nJOIN `ratings` r ON r.`movie_id` = m.`movie_id`\nGROUP BY m.`movie_id`\nORDER BY SUM(r.`critic_likes`) DESC\nLIMIT 3;"} {"question_id": 95, "db_id": "movie_platform", "grading_method": "set", "question": "How many users have more than 100 followers in the list created by users in 2009?", "evidence": "more than 100 followers refers to list_followers >100;  list created by the user in 2009 refers to list_creation_date_utc = '2009';", "SQL": "SELECT COUNT(DISTINCT T1.user_id) FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_followers > 100 AND T1.list_creation_date_utc LIKE '2009%'"} {"question_id": 100, "db_id": "movie_platform", "grading_method": "set", "question": "Please list the names of the films released in 2003 among the films scored by user 2941 .", "evidence": "released in 2003 refers to movie_release_year = 2003; user 2941 refers to user_id = 2941; film refers to movie;", "SQL": "SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_release_year = 2003 AND T1.user_id = 2941"} {"question_id": 106, "db_id": "movie_platform", "grading_method": "set", "question": "What is the average score for the movie Versailles Rive-Gauche?", "evidence": "'Versailles Rive-Gauche' is movie_title; average score refers to Avg(rating_score);", "SQL": "SELECT AVG(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title LIKE 'Versailles Rive-Gauche'"} {"question_id": 119, "db_id": "movie_platform", "grading_method": "set", "question": "How many different users gave “Downfall” a rating of 4?", "evidence": "Downfall is recorded in movies.movie_title as 'Downfall'; ratings.rating_score records the score.", "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 = 'Downfall' AND T1.rating_score = 4"} {"question_id": 133, "db_id": "movie_platform", "grading_method": "set", "question": "Which 1988 movie got the most ratings?", "evidence": "1988 movie refers to movies.movie_release_year = 1988; the most ratings refers to the greatest COUNT of ratings rows associated with a movie; return that movie", "SQL": "SELECT m.movie_title\nFROM movies m\nJOIN ratings r ON m.movie_id = r.movie_id\nWHERE m.movie_release_year = 1988\nGROUP BY m.movie_id\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 134, "db_id": "movie_platform", "grading_method": "set", "question": "How many ratings below 3 did the most popular movie released in 1995 receive?", "evidence": "the most popular movie released in 1995 refers to movies.movie_popularity = MAX(movie_popularity) among the movies released in 1995; ratings below 3 refers to ratings.rating_score < 3; how many such ratings it received refers to COUNT(rating_score) over that movie's ratings", "SQL": "SELECT COUNT(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_score < 3 AND T2.movie_release_year = 1995 AND T2.movie_popularity = ( SELECT MAX(movie_popularity) FROM movies WHERE movie_release_year = 1995 )"} {"question_id": 144, "db_id": "movie_platform", "grading_method": "set", "question": "What is the average number of followers for lists containing at least 200 movies?", "evidence": "at least 200 movies refers to lists.list_movie_number >= 200; average number of followers refers to AVG(lists.list_followers) over those lists", "SQL": "SELECT AVG(list_followers) FROM lists WHERE list_movie_number >= 200"} {"question_id": 145, "db_id": "movie_platform", "grading_method": "set", "question": "Which lists contain fewer than 50 movies and were created by subscribers? Give their titles.", "evidence": "lists.list_movie_number is the movie count; lists_users.user_subscriber = 1 means the creator was a subscriber when creating the list.", "SQL": "SELECT DISTINCT T2.list_title FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_movie_number < 50 AND T1.user_subscriber = 1"} {"question_id": 147, "db_id": "movie_platform", "grading_method": "set", "question": "Who is the user who created the list titled 'Sound and Vision'? Was he a subcriber when he created the list? 'true' or 'false'", "evidence": "list titled 'Sound and Vision' refers to list_title = 'Sound and Vision'; user_subscriber = 1 means the user was a subscriber when he created the list; user_subscriber = 0 means the user was not a subscriber when he created the list\n\n\n\n", "SQL": "SELECT T1.user_id, CASE WHEN T1.user_subscriber=1 THEN 'true' ELSE 'false' END FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id AND T1.user_id = T2.user_id WHERE T2.list_title LIKE 'Sound and Vision'"} {"question_id": 150, "db_id": "movie_platform", "grading_method": "set", "question": "List all movies rated by user 39115684. State the title, rating date and rating score.", "evidence": "user 39115684 refers to user_id = 39115684; title refers to movie_title; rating date refers to rating_timestamp_utc\n", "SQL": "SELECT T2.movie_title, T1.rating_timestamp_utc, T1.rating_score FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.user_id = 39115684"} {"question_id": 157, "db_id": "movie_platform", "grading_method": "set", "question": "What is the name of the director who directed the highest number of movies in the 70s? If multiple directors tie, list all their names and the highest rating score their movies received from users.", "evidence": "in the 70s refers to movies.movie_release_year BETWEEN 1970 AND 1979; the highest number of movies refers to the greatest COUNT(*) of such movies per director; return every movies.director_name whose count is equal to that greatest count, and with each one the MAX(ratings.rating_score) over that director's 70s movies", "SQL": "WITH movies_70s AS (\n SELECT `movie_id`, `director_id`, `director_name`\n FROM `movies`\n WHERE `movie_release_year` BETWEEN 1970 AND 1979\n),\ncounts AS (\n SELECT `director_id`, `director_name`, COUNT(*) AS num_movies\n FROM movies_70s\n GROUP BY `director_id`\n),\nmax_cnt AS (\n SELECT MAX(num_movies) AS max_num FROM counts\n),\n top_directors AS (\n SELECT c.`director_id`, c.`director_name`\n FROM counts c\n JOIN max_cnt m ON c.num_movies = m.max_num\n)\nSELECT td.`director_name`, MAX(r.`rating_score`) AS highest_rating\nFROM top_directors td\nJOIN movies_70s m ON m.`director_id` = td.`director_id`\nLEFT JOIN ratings r ON r.`movie_id` = m.`movie_id`\nGROUP BY td.`director_id`, td.`director_name`;"} {"question_id": 161, "db_id": "movie_platform", "grading_method": "set", "question": "What is the average number of followers of the lists created by the user who rated the movie \"Pavee Lackeen: The Traveller Girl\" on 3/27/2011 at 2:06:34 AM?", "evidence": "average number of followers refers to AVG(list_followers); movie \"Pavee Lackeen: The Traveller Girl\" refers to movie_title = 'Pavee Lackeen: The Traveller Girl'; on 3/27/2011 at 2:06:34 AM refers to rating_timestamp_utc = '2011-03-27 02:06:34'", "SQL": "SELECT CAST(SUM(T4.list_followers) AS REAL) / COUNT(T2.list_id) FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id INNER JOIN movies AS T3 ON T1.movie_id = T3.movie_id INNER JOIN lists AS T4 ON T2.list_id = T4.list_id WHERE T3.movie_title LIKE 'Pavee Lackeen: The Traveller Girl' AND T1.rating_timestamp_utc LIKE '2011-03-27 02:06:34'"} {"question_id": 163, "db_id": "movie_platform", "grading_method": "set", "question": "What is the average number of movies in user 8516503’s lists, and how many movies has that user rated 5?", "evidence": "user 8516503 refers to the rows of that user; the average number of movies in that user's lists = AVG(lists.list_movie_number) over that user's lists; the count of movies that user rated 5 = COUNT(DISTINCT movies) over that user's ratings with rating_score = 5, counting each of those movies only one time; return both values", "SQL": "SELECT\n (SELECT AVG(`list_movie_number`)\n FROM `lists`\n WHERE `user_id` = 8516503) AS avg_movies_in_lists,\n (SELECT COUNT(DISTINCT `movie_id`)\n FROM `ratings`\n WHERE `user_id` = 8516503\n AND `rating_score` = 5) AS count_rating_5;"} {"question_id": 166, "db_id": "movie_platform", "grading_method": "set", "question": "What are the top 10 oldest movies and what are the average rating score for each movie? Indicate the ids of the movies, the average rating scores, the name of the director, and when the movies were released. For movies with the same release year, order by title alphabetically.", "evidence": "the average rating score refers to AVG(T2.rating_score); oldest movies refers to MIN(movie_release_year)", "SQL": "SELECT\n m.`movie_id`,\n AVG(r.`rating_score`) AS avg_rating,\n m.`director_name`,\n m.`movie_release_year`\nFROM `movies` AS m\nLEFT JOIN `ratings` AS r\n ON r.`movie_id` = m.`movie_id`\nWHERE m.movie_release_year IS NOT NULL\nGROUP BY m.`movie_id`, m.`director_name`, m.`movie_release_year`\nORDER BY m.`movie_release_year` ASC,\n m.`movie_title` ASC\nLIMIT 10;"} {"question_id": 168, "db_id": "book_publishing_company", "grading_method": "set", "question": "What is the title with the most ordered quantity in year 1992?", "evidence": "total quantity refers to SUM(qty); most ordered quantity refers to order with the highest quantity where MAX(SUM(qty)); date refers to ord_date; year 1992 refers to YEAR(ord_date) = 1992", "SQL": "SELECT T2.title\nFROM sales AS T1\nJOIN titles AS T2 ON T1.title_id = T2.title_id\nWHERE STRFTIME('%Y', T1.ord_date) = '1992'\nGROUP BY T1.title_id\nORDER BY SUM(T1.qty) DESC\nLIMIT 1;"} {"question_id": 169, "db_id": "book_publishing_company", "grading_method": "set", "question": "List the title, price and publication date for all sales with 'ON invoice' payment terms.", "evidence": "publication date refers to pubdate; payment terms refers to payterms; payterms = 'ON invoice'", "SQL": "SELECT T2.title, T2.price, T2.pubdate FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id WHERE T1.payterms = 'ON invoice'"} {"question_id": 174, "db_id": "book_publishing_company", "grading_method": "set", "question": "What royalty percentages are associated with the title with the highest year-to-date sales among royalty schedules whose upper range is below 20,000?", "evidence": "royalty percentages refers to roysched.royalty of the schedules with hirange < 20000; the title with the highest year-to-date sales refers to ytd_sales = MAX(ytd_sales) among titles with such a schedule; return the royalty for that title", "SQL": "SELECT r.royalty\nFROM titles t\nJOIN roysched r ON t.title_id = r.title_id\nWHERE r.hirange < 20000\nAND t.ytd_sales = (\n SELECT MAX(t1.ytd_sales) \n FROM titles t1\n JOIN roysched r1 ON t1.title_id = r1.title_id\n WHERE r1.hirange < 20000)"} {"question_id": 175, "db_id": "book_publishing_company", "grading_method": "set", "question": "List all titles published in year 1991. Also provide notes details of the title and the publisher's name.", "evidence": "publisher name refers to pub_name; publication date refers to pubdate; published in year 1991 refers to YEAR(pubdate) = 1991", "SQL": "SELECT T1.title, T1.notes, T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991'"} {"question_id": 176, "db_id": "book_publishing_company", "grading_method": "set", "question": "List all titles with a total quantity sold of more than 20 at stores in California.", "evidence": "California is recorded as stores.state = 'CA'; sales.qty records quantity sold.", "SQL": "SELECT DISTINCT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T2.stor_id = T3.stor_id WHERE T3.state = 'CA' GROUP BY T1.title_id HAVING SUM(T2.qty) > 20"} {"question_id": 177, "db_id": "book_publishing_company", "grading_method": "set", "question": "What is the name of the store with the highest total quantity sold, and which title had the lowest quantity sold at that store?", "evidence": "the store with the highest total quantity sold refers to the store whose SUM(sales.qty) is the highest; at that store a title's quantity sold refers to SUM(qty) for that title; return both stores.stor_name and the titles.title with the lowest such per-title total", "SQL": "WITH top_store AS (\n SELECT `stor_id`\n FROM `sales`\n GROUP BY `stor_id`\n HAVING SUM(`qty`) = (\n SELECT SUM(qty) FROM sales GROUP BY stor_id ORDER BY SUM(qty) DESC LIMIT 1)\n),\ntop_store_title_quantity AS (\n SELECT st.stor_name stor_name, st.stor_id stor_id, ti.title title, SUM(sa.`qty`) title_qty\n FROM `sales` sa\n JOIN top_store ts ON sa.`stor_id` = ts.`stor_id`\n JOIN `stores` st ON st.`stor_id` = sa.`stor_id`\n JOIN `titles` ti ON ti.`title_id` = sa.`title_id`\n GROUP BY st.`stor_id`, ti.`title`\n),\ntop_store_min_title_quantity AS (\n SELECT stor_id, MIN(title_qty) min_qty\n FROM top_store_title_quantity\n GROUP BY stor_id\n)\nSELECT tstq.`stor_name` stor_name, tstq.title\nFROM top_store_title_quantity tstq\nJOIN top_store_min_title_quantity tsmtq \nON tstq.stor_id = tsmtq.stor_id AND tstq.title_qty = tsmtq.min_qty\n"} {"question_id": 181, "db_id": "book_publishing_company", "grading_method": "set", "question": "Name all employees who were hired before year 1990. List their first and last names.", "evidence": "hired before year 1990 refers to YEAR(hire_date)<1990", "SQL": "SELECT fname, lname FROM employee WHERE STRFTIME('%Y', hire_date) < '1990'"} {"question_id": 182, "db_id": "book_publishing_company", "grading_method": "set", "question": "Which employees have the lowest job level? List their first names, last names, and hire dates, including ties.", "evidence": "the lowest job level refers to employee.job_lvl = MIN(job_lvl) over all employees, so every employee at that level qualifies, including ties; list the fname, lname and hire_date of each such employee", "SQL": "SELECT fname,\n lname,\n hire_date\nFROM employee\nWHERE job_lvl = (SELECT MIN(job_lvl) FROM employee);"} {"question_id": 183, "db_id": "book_publishing_company", "grading_method": "set", "question": "In which year has the most hired employees?", "evidence": "most hired employees refers to MAX(count(emp_id))", "SQL": "SELECT STRFTIME('%Y', hire_date) FROM employee GROUP BY STRFTIME('%Y', hire_date) ORDER BY COUNT(emp_id) DESC LIMIT 1"} {"question_id": 189, "db_id": "book_publishing_company", "grading_method": "set", "question": "Name the publisher which has the most titles published in 1991.", "evidence": "most title published refers to MAX(count(title_id)); published in 1991 refers to YEAR(pubdate) = 1991", "SQL": "SELECT T2.pub_name \nFROM titles AS T1 \nINNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id \nWHERE STRFTIME('%Y', T1.pubdate) = '1991' \nGROUP BY T1.pub_id, T2.pub_name \nHAVING COUNT(T1.title_id) = (\n SELECT COUNT(T1.title_id) \n FROM titles AS T1 \n INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id \n WHERE STRFTIME('%Y', T1.pubdate) = '1991' \n GROUP BY T1.pub_id, T2.pub_name \n ORDER BY COUNT(T1.title_id) DESC \n LIMIT 1)"} {"question_id": 196, "db_id": "book_publishing_company", "grading_method": "set", "question": "What percentage of employees are editors or designers?", "evidence": "editors or designers refers to jobs.job_desc IN ('Editor', 'Designer'), reached from employee.job_id; percentage = DIVIDE(count of employees in those two jobs, COUNT(employee.job_id) over all employees joined to jobs) * 100, counting employees rather than distinct job titles", "SQL": "SELECT CAST(SUM(CASE WHEN T2.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id"} {"question_id": 206, "db_id": "book_publishing_company", "grading_method": "set", "question": "In which country is the publisher of the book \"Life Without Fear\" located?", "evidence": "Life Without Fear is book title", "SQL": "SELECT T2.country FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Life Without Fear'"} {"question_id": 214, "db_id": "book_publishing_company", "grading_method": "set", "question": "Which type of book had the most pre-paid amount?", "evidence": "most pre-paid amount refers to MAX(advance)", "SQL": "SELECT type FROM titles ORDER BY advance DESC LIMIT 1"} {"question_id": 216, "db_id": "book_publishing_company", "grading_method": "set", "question": "Which job level is O'Rourke at?", "evidence": "job level refers to job_lvl", "SQL": "SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'"} {"question_id": 222, "db_id": "book_publishing_company", "grading_method": "set", "question": "What's on the notes for the order happened on 1994/9/14?", "evidence": "order happened on refers to ord_date", "SQL": "SELECT DISTINCT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1994-09-14'"} {"question_id": 223, "db_id": "book_publishing_company", "grading_method": "set", "question": "List the type of the book for the order which was sold on 1993/5/29.", "evidence": "sold on refers to ord_date", "SQL": "SELECT DISTINCT T1.type FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1993-05-29'"} {"question_id": 226, "db_id": "book_publishing_company", "grading_method": "set", "question": "Which city did Victoria P Ashworth work in?", "evidence": "", "SQL": "SELECT T2.city FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.fname = 'Victoria' AND T1.minit = 'P' AND T1.lname = 'Ashworth'"} {"question_id": 227, "db_id": "book_publishing_company", "grading_method": "set", "question": "How many sales did the store in Remulade make?", "evidence": "Remulade is a city; sales in the store refers to ord_num", "SQL": "SELECT COUNT(DISTINCT T1.ord_num) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T2.city = 'Remulade'"} {"question_id": 228, "db_id": "book_publishing_company", "grading_method": "set", "question": "For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?", "evidence": "\"qty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE(\nSUBTRACT(SUM(qty where city = 'Fremont' and year(ord_date = 1993)), \nSUM(qty where city = 'Portland' and year(ord_date = 1993))), SUM(qty where city = 'Portland' and year(ord_date = 1993)) *100\"", "SQL": "SELECT\n (SUM(CASE WHEN st.city = 'Fremont' THEN sa.qty END) -\n SUM(CASE WHEN st.city = 'Portland' THEN sa.qty END)) * 100.0\n / SUM(CASE WHEN st.city = 'Portland' THEN sa.qty END) AS percent_more\nFROM sales AS sa\nJOIN stores AS st ON sa.stor_id = st.stor_id\nWHERE STRFTIME('%Y', sa.ord_date) = '1993';"} {"question_id": 230, "db_id": "book_publishing_company", "grading_method": "list", "question": "List the first names, middle initials, and last names of employees hired from 1990 through 1995, ordered by job level from highest to lowest.", "evidence": "job level refers to job_lvl; YEAR(hire_date) between 1990 and 1995; full name refers to fname, minit, and lname", "SQL": "SELECT fname, minit, lname FROM employee WHERE STRFTIME('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC"} {"question_id": 233, "db_id": "book_publishing_company", "grading_method": "list", "question": "List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.", "evidence": "New Moon Books is recorded in publishers.pub_name; titles.title, titles.type, and titles.price provide the requested fields.", "SQL": "SELECT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books' ORDER BY T1.price"} {"question_id": 239, "db_id": "book_publishing_company", "grading_method": "list", "question": "Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?", "evidence": "qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA'", "SQL": "WITH ca_sales AS (\n SELECT s.title_id,\n SUM(s.qty) AS total_qty\n FROM sales s\n JOIN stores st ON s.stor_id = st.stor_id\n WHERE st.state = 'CA'\n GROUP BY s.title_id\n),\navg_ca AS (\n SELECT AVG(total_qty) AS avg_qty FROM ca_sales\n)\nSELECT t.title\nFROM ca_sales cs\nJOIN avg_ca a\nJOIN titles t ON t.title_id = cs.title_id\nWHERE cs.total_qty > a.avg_qty\nORDER BY cs.total_qty DESC\nLIMIT 5;"} {"question_id": 240, "db_id": "retail_complains", "grading_method": "set", "question": "On which day was the most verbose complaint received?", "evidence": "day received refers to \"Date received\"; most verbose complaint refers to MAX(ser_time);", "SQL": "SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )"} {"question_id": 241, "db_id": "retail_complains", "grading_method": "set", "question": "When did the earliest complaint begin on 2017/3/22?", "evidence": "callcenterlogs.ser_start records the complaint’s start time; \"Date received\" records its received date, represented as '2017-03-22' for March 22, 2017.", "SQL": "SELECT MIN(ser_start) AS earliest_start\nFROM callcenterlogs\nWHERE `Date received` = '2017-03-22';"} {"question_id": 245, "db_id": "retail_complains", "grading_method": "set", "question": "What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?", "evidence": "detailed product refers to \"sub-product\"; on 2014/7/3 refers to \"Date received\" = '2014-07-03';", "SQL": "SELECT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway' AND T2.`Date received` = '2014-07-03'"} {"question_id": 248, "db_id": "retail_complains", "grading_method": "set", "question": "What is the full name of the client whose complaint on 2017/3/27 was received by MICHAL?", "evidence": "full names = first, middle, last; on 2017/3/27 refers to \"Date received\" = '2017-03-27'; MICHAL refers to server = 'MICHAL';", "SQL": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.`Date received` = '2017-03-27' AND T2.server = 'MICHAL'"} {"question_id": 257, "db_id": "retail_complains", "grading_method": "set", "question": "What was the percentage increase in complaints from New York City clients between 2016 and 2017? Round your answer to 3 decimal places.", "evidence": "client.city records 'New York City'. Each events row is a complaint; events.\"Date received\" records its receipt date. Report the increase on a percentage scale.", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * (SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2017' THEN 1 ELSE 0 END) - SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END)) / SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City'\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 265, "db_id": "retail_complains", "grading_method": "set", "question": "What was the review context from Jacksonville on 2017/7/22?", "evidence": "Jacksonville refers to city = 'Jacksonville'; on 2017/7/22 refers to Date = '2017-07-22';", "SQL": "SELECT T1.Reviews FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Jacksonville' AND T1.Date = '2017-07-22'"} {"question_id": 273, "db_id": "retail_complains", "grading_method": "set", "question": "For clients older than 65, list their first, middle, and last names, followed by their birth year, month, and day, and their email address. List the oldest clients first.", "evidence": "client.year, client.month, and client.day are birth-date components.", "SQL": "SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC"} {"question_id": 274, "db_id": "retail_complains", "grading_method": "set", "question": "Which product got the most five stars, and how many?", "evidence": "most five stars refers to MAX(COUNT(stars = 5));", "SQL": "SELECT T.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T"} {"question_id": 282, "db_id": "retail_complains", "grading_method": "set", "question": "List the first, middle, and last names of male clients born from 1980 through 2000 who complained through a referral.", "evidence": "client.year records birth year; client.sex = 'Male' denotes male clients. client.first, middle, and last record name components. events.Submitted via = 'Referral' denotes referral complaints.", "SQL": "SELECT DISTINCT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year BETWEEN 1980 AND 2000 AND T1.sex = 'Male' AND T2.`Submitted via` = 'Referral'"} {"question_id": 283, "db_id": "retail_complains", "grading_method": "set", "question": "What is the medium through which most complaints are registered in Florida?", "evidence": "events.Submitted via records the complaint channel. client.state uses 'FL' for Florida.", "SQL": "SELECT E.`Submitted via`\nFROM `events` AS E\nJOIN `client` AS C ON E.`Client_ID` = C.`client_id`\nWHERE C.`state` = 'FL'\nGROUP BY E.`Submitted via`\nHAVING COUNT(*) = (\n SELECT COUNT(*)\n FROM `events` AS E\n JOIN `client` AS C ON E.`Client_ID` = C.`client_id`\n WHERE C.`state` = 'FL'\n GROUP BY E.`Submitted via`\n ORDER BY COUNT(*) DESC LIMIT 1\n)"} {"question_id": 286, "db_id": "retail_complains", "grading_method": "set", "question": "Find the number of service members who complained in Syracuse.", "evidence": "Service-member complaints have events.Tags = 'Servicemember'. client.city records 'Syracuse'; events.Client_ID identifies the complaining client.", "SQL": "SELECT COUNT(DISTINCT T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'"} {"question_id": 302, "db_id": "retail_complains", "grading_method": "set", "question": "How many male clients born in the year 1977 were given priority 0 in their complaints?", "evidence": "male refers to sex = 'Male';", "SQL": "SELECT COUNT(DISTINCT T1.client_id) \nFROM client AS T1\nJOIN callcenterlogs AS T2 ON T1.`client_id` = T2.`rand client`\nWHERE T1.sex = 'Male'\n AND T1.year = 1977\n AND T2.priority = 0;"} {"question_id": 310, "db_id": "retail_complains", "grading_method": "set", "question": "How many complaints from female clients born in the year 2000 were not sent through the web?", "evidence": "female refers to sex = 'Female'; sent through refers to \"Submitted via\"; not sent through web refers to \"Submitted via\" ! = 'Web';\n", "SQL": "SELECT COUNT(T2.`Submitted via`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T1.year = 2000 AND T2.`Submitted via` != 'Web'"} {"question_id": 314, "db_id": "retail_complains", "grading_method": "set", "question": "What percentage of clients who sent their complaints by postal mail are aged 50 or older?", "evidence": "clients who sent complaints by postal mail refers to clients having an events row with `Submitted via` = 'Postal mail', each client counted once; aged 50 or older refers to client.age >= 50; percentage = DIVIDE(COUNT(those clients aged 50 or older), COUNT(all of those clients)) * 100", "SQL": "WITH postal_clients AS (\n SELECT DISTINCT c.client_id, c.age\n FROM events e\n JOIN client c ON c.client_id = e.Client_ID\n WHERE e.`Submitted via` = 'Postal mail'\n)\nSELECT 100.0 * SUM(CASE WHEN age >= 50 THEN 1 ELSE 0 END) / COUNT(*) AS pct_clients_50_plus\nFROM postal_clients"} {"question_id": 315, "db_id": "retail_complains", "grading_method": "set", "question": "What is the average age of Norwalk clients?", "evidence": "average age = AVG(age); Norwalk refers to city = 'Norwalk';", "SQL": "SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk'"} {"question_id": 318, "db_id": "retail_complains", "grading_method": "set", "question": "Which region does Noah Thompson live in?", "evidence": "", "SQL": "SELECT s.Region FROM client c JOIN district d ON c.district_id = d.district_id JOIN state s ON d.state_abbrev = s.StateCode WHERE c.first = 'Noah' AND c.last = 'Thompson';"} {"question_id": 321, "db_id": "retail_complains", "grading_method": "set", "question": "How long was Kendall Allen's complaint about her credit card?", "evidence": "how long refers to ser_time; credit card refers to Product = 'Credit Card';", "SQL": "SELECT T3.ser_time FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN callcenterlogs AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.first = 'Kendall' AND T2.last = 'Allen' AND T2.sex = 'Female' AND T1.Product = 'Credit card'"} {"question_id": 323, "db_id": "retail_complains", "grading_method": "set", "question": "How many clients who live in New York City submitted their complaints via fax?", "evidence": "submitted complaints via fax refers to \"Submitted via\" = 'Fax';", "SQL": "SELECT COUNT(DISTINCT T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City' AND T2.`Submitted via` = 'Fax'"} {"question_id": 324, "db_id": "retail_complains", "grading_method": "set", "question": "Among all the clients who complained about their credit cards, what is the percentage of male clients? Round your answer to 3 decimal places.", "evidence": "clients who complained about their credit cards refers to DISTINCT events.Client_ID where Product = 'Credit card', joined to client on client_id; male refers to client.sex = 'Male'; percentage = DIVIDE(SUM(CASE WHEN sex = 'Male' THEN 1 ELSE 0 END), COUNT(*)) * 100 over those distinct clients, rounded to 3 decimals", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN c.sex = 'Male' THEN 1 ELSE 0 END) / COUNT(*) AS pct_male\nFROM (\n SELECT DISTINCT Client_ID\n FROM events\n WHERE Product = 'Credit card'\n) cc\nJOIN client c ON c.client_id = cc.Client_ID\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 326, "db_id": "retail_complains", "grading_method": "set", "question": "What is the birth date of the youngest client?", "evidence": "birth date refers to year, month, day; youngest client refers to max(year, month, day)", "SQL": "SELECT year, month, day FROM client \nWHERE year || '-' || month || '-' || day = (\n SELECT year || '-' || month || '-' || day\n FROM client\n ORDER BY year DESC, month DESC, day DESC\n LIMIT 1)"} {"question_id": 330, "db_id": "retail_complains", "grading_method": "set", "question": "List the first, middle, and last names of clients who live in the Pacific division.", "evidence": "Client first, middle, and last names are recorded in client.first, client.middle, and client.last. The Pacific division is recorded as district.division = 'Pacific'.", "SQL": "SELECT T2.first, T2.middle, T2.last FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.division = 'Pacific'"} {"question_id": 331, "db_id": "retail_complains", "grading_method": "set", "question": "What is the social number of the person who made the most complaints?", "evidence": "social number refers to social; most complaints refers to max(count(event.Client_ID))", "SQL": "SELECT c.social\nFROM client AS c\nJOIN events AS e ON c.client_id = e.Client_ID\nGROUP BY c.client_id, c.social\nHAVING COUNT(*) = (\n SELECT MAX(cnt)\n FROM (\n SELECT COUNT(*) AS cnt\n FROM events\n GROUP BY Client_ID\n )\n);"} {"question_id": 333, "db_id": "retail_complains", "grading_method": "set", "question": "What is the address of the client who made a complaint via postal mail on March 14, 2012?", "evidence": "address refers to address_1, address_2; via postal mail refers to Submitted via = 'Postal mail'; March 14 2012 refers to Date received = '2012-03-14'", "SQL": "SELECT T1.address_1, T1.address_2 FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2012-03-14' AND T2.`Submitted via` = 'Postal mail'"} {"question_id": 337, "db_id": "retail_complains", "grading_method": "set", "question": "What is the name of the state that the client with the email \"skylar.ramirez@gmail.com\" lives in?", "evidence": "", "SQL": "SELECT s.State\nFROM client c\nJOIN district d ON c.district_id = d.district_id\nJOIN state s ON d.state_abbrev = s.StateCode\nWHERE c.email = 'skylar.ramirez@gmail.com';"} {"question_id": 339, "db_id": "retail_complains", "grading_method": "set", "question": "Who is the owner of the final phone number for the complaints on server \"MORIAH\" on 9/11/2013?", "evidence": "owner refers to first, middle, last; on 9/11/2013 refers to Date received = '2013-09-11'", "SQL": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.server = 'MORIAH' AND T2.`Date received` = '2013-09-11'"} {"question_id": 340, "db_id": "retail_complains", "grading_method": "set", "question": "What were the average complaint-handling times in minutes for teenagers, adults, and elders? Return one row with the three averages in that order.", "evidence": "teenagers refers to age > 13 AND age <= 19, adults to age > 19 AND age <= 65, elders to age > 65, with 'rand client' as the client of a callcenterlogs row; handling time in minutes = 60 * HH + MM + SS / 60.0 from the HH:MM:SS ser_time; per group return DIVIDE(SUM of those minutes, COUNT of its rows), teenagers then adults then elders", "SQL": "SELECT CAST(SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60.0 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END) AS teenagerAverageMins, CAST(SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60.0 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adultAverageMins , CAST(SUM(CASE WHEN T1.age > 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60.0 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS elderAverageMins FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client`"} {"question_id": 346, "db_id": "retail_complains", "grading_method": "set", "question": "List the email addresses of clients whose complaint type is \"PS\".", "evidence": "", "SQL": "SELECT DISTINCT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS'"} {"question_id": 353, "db_id": "retail_complains", "grading_method": "subset,=,5", "question": "Pick 5 clients with 0 priority and write down their last name.", "evidence": "0 priority refers to priority = 0; last name refers to last", "SQL": "SELECT T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = 0;"} {"question_id": 354, "db_id": "retail_complains", "grading_method": "set", "question": "Write down the call id of clients whose first name start with alphabet \"B\".", "evidence": "first name start with alphabet \"B\" refers to first like 'B%'", "SQL": "SELECT T2.call_id FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.first LIKE 'B%'"} {"question_id": 360, "db_id": "retail_complains", "grading_method": "set", "question": "Write down the dates received for complaints sent via fax.", "evidence": "Fax submissions are recorded as events.\"Submitted via\" = 'Fax'; events.\"Date received\" records the received date.", "SQL": "SELECT DISTINCT `Date received` FROM events WHERE `Submitted via` = 'Fax'"} {"question_id": 363, "db_id": "retail_complains", "grading_method": "set", "question": "What is the average age of clients who have had at least one complaint closed with relief? Round your answer to 2 decimal places.", "evidence": "closed with relief refers to events.`Company response to consumer` = 'Closed with relief'; average age refers to AVG(client.age) over the DISTINCT client_id values having at least one such event, each client counted once, rounded to 2 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(age)\nFROM (\n SELECT DISTINCT c.client_id, c.age\n FROM client AS c\n JOIN events AS e ON c.client_id = e.Client_ID\n WHERE e.`Company response to consumer` = 'Closed with relief'\n)\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 365, "db_id": "retail_complains", "grading_method": "set", "question": "Write the complaint ID, call ID, and final phone number of complaints through AVIDAN server from 1/1/2014 to 12/30/2014.", "evidence": "The final phone number is stored in phonefinal. Date received contains valid dates in YYYY-MM-DD format, without a time component. Include both January 1 and December 30, 2014, using Date received BETWEEN '2014-01-01' AND '2014-12-30'.", "SQL": "SELECT `Complaint ID`, call_id, phonefinal FROM callcenterlogs WHERE server = 'AVIDAN' AND `Date received` BETWEEN '2014-01-01' AND '2014-12-30';"} {"question_id": 367, "db_id": "retail_complains", "grading_method": "set", "question": "How many times did credit-card customers complain about over-limit fees in each year? List the years and corresponding complaint counts.", "evidence": "events.product uses 'Credit card'; events.issue uses 'Overlimit fee'. events.\"Date received\" records the complaint’s date.", "SQL": "SELECT strftime('%Y', `Date received`), COUNT(`Date received`) FROM events WHERE product = 'Credit card' AND issue = 'Overlimit fee' GROUP BY strftime('%Y', `Date received`) HAVING COUNT(`Date received`)"} {"question_id": 368, "db_id": "retail_complains", "grading_method": "set", "question": "Among clients in the Middle Atlantic, how many are female and no more than 18 years old?", "evidence": "district.division uses 'Middle Atlantic'; client.sex = 'Female' denotes female and client.age records age in years.", "SQL": "SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Middle Atlantic' AND T1.sex = 'Female' AND T1.age <= 18"} {"question_id": 369, "db_id": "retail_complains", "grading_method": "set", "question": "Give me the full birthdate, email and phone number of the youngest client in Indianapolis .", "evidence": "full birthdate = year, month, day; youngest refers to max(year, month, day); in Indianapolis refers to city = 'Indianapolis'", "SQL": "SELECT T1.year, T1.month, T1.day, T1.email, T1.phone \nFROM client AS T1 \nINNER JOIN district AS T2 ON T1.district_id = T2.district_id \nWHERE T2.city = 'Indianapolis' \nAND T1.year || '-' || T1.month || '-' || T1.day = (\n SELECT T1.year || '-' || T1.month || '-' || T1.day \n FROM client AS T1 \n INNER JOIN district AS T2 ON T1.district_id = T2.district_id \n WHERE T2.city = 'Indianapolis' \n ORDER BY T1.year DESC, T1.month DESC, T1.day DESC LIMIT 1)\n"} {"question_id": 371, "db_id": "retail_complains", "grading_method": "set", "question": "What is the longest server time when the call is about the issue of arbitration?", "evidence": "longest server time refers to max(ser_time)", "SQL": "SELECT MAX(T1.ser_time) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.issue = 'Arbitration'"} {"question_id": 376, "db_id": "retail_complains", "grading_method": "set", "question": "Please list all first and last names of clients who live in New York city.", "evidence": "New York City refers to city = 'New York City'", "SQL": "SELECT first, last FROM client WHERE city = 'New York City'"} {"question_id": 380, "db_id": "retail_complains", "grading_method": "set", "question": "What is the average age of clients in South Atlantic?", "evidence": "in South Atlantic refers to division = 'South Atlantic'; average age refers to avg(age)", "SQL": "SELECT AVG(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic'"} {"question_id": 381, "db_id": "retail_complains", "grading_method": "set", "question": "Which cities in the Midwest region have the least number of clients?", "evidence": "least number of clients refers to min(count(client_id))", "SQL": "SELECT T2.city FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest' GROUP BY T2.city HAVING COUNT(T1.client_id) = ( SELECT MIN(client_count) FROM ( SELECT COUNT(T1.client_id) AS client_count FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest' GROUP BY T2.city ) AS ClientCounts );"} {"question_id": 385, "db_id": "retail_complains", "grading_method": "set", "question": "Which state has the most cities?", "evidence": "state refers to state_abbrev; most cities refers to max(count(city))", "SQL": "SELECT state_abbrev FROM district GROUP BY state_abbrev \nHAVING COUNT(DISTINCT city) = (\n SELECT COUNT(DISTINCT city)\n FROM district\n GROUP BY state_abbrev\n ORDER BY COUNT(DISTINCT city) DESC\n LIMIT 1)"} {"question_id": 388, "db_id": "retail_complains", "grading_method": "set", "question": "In 2012, how many complaints about Credit card product came from clients in Omaha?", "evidence": "in 2012 refers to Date received LIKE'2012%'; in Omaha refers to city = 'Omaha'", "SQL": "SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'Omaha' AND strftime('%Y', T2.`Date received`) = '2012' AND T2.Product = 'Credit card'"} {"question_id": 402, "db_id": "retail_complains", "grading_method": "set", "question": "List the products involved in the complaints received on March 2017 via TOVA server.", "evidence": "on March 2017 refers to Date received LIKE '%03%' AND Date received LIKE '2017%'", "SQL": "SELECT DISTINCT T2.Product FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.server = 'TOVA' AND T2.`Date received` LIKE '2017-03%'"} {"question_id": 406, "db_id": "retail_complains", "grading_method": "set", "question": "List the product and its issues of the complains of clients with age greater than the 60% of average age of all clients.", "evidence": "age greater than the 60% of average age refers to age > multiply(avg(age) , 0.6)", "SQL": "SELECT DISTINCT T2.Product, T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.age * 100 > ( SELECT AVG(age) * 60 FROM client )"} {"question_id": 408, "db_id": "movies_4", "grading_method": "set", "question": "Please list the names of the production companies for the movie “Four Rooms.”", "evidence": "production_company.company_name records production-company names; Four Rooms is recorded in movie.title as 'Four Rooms'.", "SQL": "SELECT T1.company_name 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 T3.title = 'Four Rooms'"} {"question_id": 410, "db_id": "movies_4", "grading_method": "set", "question": "Please list the titles of all movies produced by ‘Universal Pictures’.", "evidence": "The company name is production_company.company_name = 'Universal Pictures'; movie.title records movie titles.", "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 = 'Universal Pictures'"} {"question_id": 414, "db_id": "movies_4", "grading_method": "set", "question": "Please list the names of all the crew members of the movie \"Pirates of the Caribbean: At World's End\".", "evidence": "names refers to person_name; \"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'"} {"question_id": 416, "db_id": "movies_4", "grading_method": "set", "question": "Please list the names of all the producers in the movie \"Pirates of the Caribbean: At World's End\".", "evidence": "names refers to person_name; producers refers to job = 'Producer'; \"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 = 'Producer'"} {"question_id": 420, "db_id": "movies_4", "grading_method": "set", "question": "What percentage of movies with Dariusz Wolski as director of photography have an average rating above 5.0?", "evidence": "Dariusz Wolski as director of photography refers to a movie_crew row for Dariusz Wolski with job = 'Director of Photography'; average rating above 5.0 refers to vote_average > 5; percentage = DIVIDE(COUNT(DISTINCT such movies with vote_average > 5), COUNT(DISTINCT such movies)) * 100", "SQL": "SELECT CAST(COUNT(CASE WHEN vote_average > 5 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(*) \nFROM (\n SELECT T1.vote_average vote_average\n FROM movie AS T1 \n INNER JOIN movie_crew AS T2 ON T1.movie_id = T2.movie_id \n INNER JOIN person AS T3 ON T2.person_id = T3.person_id \n WHERE T3.person_name = 'Dariusz Wolski' AND T2.job = 'Director of Photography'\n GROUP BY T1.movie_id) "} {"question_id": 431, "db_id": "movies_4", "grading_method": "set", "question": "What are production companies of the movie \"Crazy Heart\"?", "evidence": "movie \"Crazy Heart\" refers to title = 'Crazy Heart'; production company refers to company_name", "SQL": "SELECT T1.company_name 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 T3.title = 'Crazy Heart'"} {"question_id": 437, "db_id": "movies_4", "grading_method": "set", "question": "Which movies have the largest budget? List their titles, including ties.", "evidence": "", "SQL": "SELECT title FROM movie WHERE budget = (SELECT MAX(budget) FROM movie);"} {"question_id": 440, "db_id": "movies_4", "grading_method": "set", "question": "How many crew members are named John Young?", "evidence": "person.person_name records crew members’ names, including 'John Young'; movie_crew records crew credits.", "SQL": "SELECT COUNT(DISTINCT p.`person_id`)\nFROM `person` p\nJOIN `movie_crew` mc ON p.`person_id` = mc.`person_id`\nWHERE p.`person_name` = 'John Young';"} {"question_id": 445, "db_id": "movies_4", "grading_method": "set", "question": "What is Walt Disney Pictures' most popular movie?", "evidence": "Walt Disney Pictures refers to company_name = 'Walt Disney Pictures'; most popular movie refers to max(popularity)", "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 = 'Walt Disney Pictures' AND T3.popularity = (SELECT MAX(T6.popularity) FROM production_company AS T4 INNER JOIN movie_company AS T5 ON T4.company_id = T5.company_id INNER JOIN movie AS T6 ON T5.movie_id = T6.movie_id WHERE T4.company_name = 'Walt Disney Pictures')"} {"question_id": 447, "db_id": "movies_4", "grading_method": "set", "question": "Which production companies produced the movies that made the most money at the box office?", "evidence": "Which production company refers to company_name; most money at the box office refers to max(revenue)", "SQL": "SELECT pc.company_name FROM production_company AS pc JOIN movie_company AS mc ON pc.company_id = mc.company_id JOIN movie AS m ON mc.movie_id = m.movie_id WHERE m.revenue = (SELECT MAX(revenue) FROM movie);"} {"question_id": 449, "db_id": "movies_4", "grading_method": "set", "question": "List the names of the production companies that made at least 200 movies.", "evidence": "names of the production companies refers to company_name; at least 200 movies refers to COUNT(company_name) > = 200", "SQL": "SELECT T1.company_name FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING COUNT(T2.movie_id) >= 200"} {"question_id": 450, "db_id": "movies_4", "grading_method": "set", "question": "How many movies did Harrison Ford appear in total?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT T2.movie_id) FROM person AS T1 INNER JOIN movie_cast AS T2 ON T1.person_id = T2.person_id WHERE T1.person_name = 'Harrison Ford'"} {"question_id": 454, "db_id": "movies_4", "grading_method": "set", "question": "How many horror movies are there?", "evidence": "horror movies refers to genre_name = 'Horror'", "SQL": "SELECT COUNT(DISTINCT T1.movie_id) FROM movie_genres AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.genre_id WHERE T2.genre_name = 'Horror'"} {"question_id": 471, "db_id": "movies_4", "grading_method": "set", "question": "Calculate the 2016 gap between the average revenue for Indian and American films.", "evidence": "2016 refers to release_date LIKE '2016%'; Indian and American films refers to country_name = 'India' and country_name = 'United States of America'; gap between the average revenue refers to subtract(divide(sum(revenue), count(movie_id)) when country_name = 'United States of America', divide(sum(revenue), count(movie_id)) when country_name = 'India')", "SQL": "SELECT AVG(CASE WHEN T3.COUNTry_name = 'United States of America' THEN T1.revenue END) - AVG(CASE WHEN T3.COUNTry_name = 'India' THEN T1.revenue END) AS CALCULATE FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE CAST(STRFTIME('%Y', T1.release_date) AS INT) = 2016"} {"question_id": 474, "db_id": "movies_4", "grading_method": "set", "question": "What is the gender of the character 'USAF Master Sgt. Epps?'", "evidence": "character 'USAF Master Sgt. Epps' refers to character_name = 'USAF Master Sgt. Epps'", "SQL": "SELECT T2.gender FROM movie_cast AS T1 INNER JOIN gender AS T2 ON T1.gender_id = T2.gender_id WHERE T1.character_name = 'USAF Master Sgt. Epps'"} {"question_id": 478, "db_id": "movies_4", "grading_method": "set", "question": "Write all the keywords belonging to the movie 'Sky Captain and the World of Tomorrow.'", "evidence": "keywords refers to keyword_name; movie 'Sky Captain and the World of Tomorrow' refers to title = 'Sky Captain and the World of Tomorrow'", "SQL": "SELECT T3.keyword_name FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T1.title = 'Sky Captain and the World of Tomorrow'"} {"question_id": 480, "db_id": "movies_4", "grading_method": "set", "question": "Which movie has the keyword 'extremis?'", "evidence": "Which movie refers to title; keyword 'extremis' refers to keyword_name = 'extremis'", "SQL": "SELECT T1.title FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'extremis'"} {"question_id": 483, "db_id": "movies_4", "grading_method": "subset,=,10", "question": "List 10 crew members and their jobs from the movie \"Mad Max: Fury Road.\"", "evidence": "person.person_name records crew members’ names; movie_crew.job records their jobs. The film title is movie.title = 'Mad Max: Fury Road'.", "SQL": "SELECT T3.person_name, T2.job 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 = 'Mad Max: Fury Road'"} {"question_id": 487, "db_id": "movies_4", "grading_method": "set", "question": "What are the keyword IDs of the movie with the title of \"Sin City\"?", "evidence": "title of \"Sin City\" refers to title = 'Sin City'", "SQL": "SELECT T2.keyword_id FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id WHERE T1.title = 'Sin City'"} {"question_id": 489, "db_id": "movies_4", "grading_method": "set", "question": "Which keywords belong to the movie titles with the highest popularity?", "evidence": "Which keywords refers to keyword_name; highest popularity refers to max(popularity)", "SQL": "SELECT T3.keyword_name FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id AND T1.popularity = (SELECT MAX(popularity) FROM movie)"} {"question_id": 500, "db_id": "movies_4", "grading_method": "set", "question": "For movies with the keyword of \"civil war\", calculate the average revenue generated by these movies.", "evidence": "keyword of \"civil war\" refers to keyword_name = 'civil war'; average revenue = AVG(revenue)", "SQL": "SELECT AVG(T1.revenue) FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'civil war'"} {"question_id": 503, "db_id": "movies_4", "grading_method": "set", "question": "What is the ID of the production company which produced the movie \"Gladiator\"?", "evidence": "ID of the production company refers to company_id; movie \"Gladiator\" refers to title = 'Gladiator'", "SQL": "SELECT T2.company_id FROM movie AS T1 INNER JOIN movie_company AS T2 ON T1.movie_id = T2.movie_id WHERE T1.title = 'Gladiator'"} {"question_id": 504, "db_id": "movies_4", "grading_method": "set", "question": "List the IDs of the production companies that released movies in 1916.", "evidence": "movie.release_date records the release date; movie_company records production-company associations.", "SQL": "SELECT T2.company_id FROM movie AS T1 INNER JOIN movie_company AS T2 ON T1.movie_id = T2.movie_id WHERE CAST(STRFTIME('%Y', T1.release_date) AS INT) = 1916"} {"question_id": 511, "db_id": "movies_4", "grading_method": "set", "question": "Are there any post-production movies in Nederlands? 'YES' or 'NO'", "evidence": "post-production movies refers to movie_status = 'Post Production'; Nederlands refers to language_name = 'Nederlands';", "SQL": "SELECT CASE\n WHEN EXISTS ( SELECT 1\n FROM `movie` m\n JOIN `movie_languages` ml ON m.`movie_id` = ml.`movie_id`\n JOIN `language` l ON ml.`language_id` = l.`language_id`\n WHERE m.`movie_status` = 'Post Production'\n AND l.`language_name` = 'Nederlands')\n THEN 'YES'\n ELSE 'NO'\n END AS answer;"} {"question_id": 518, "db_id": "movies_4", "grading_method": "set", "question": "What is the average number of crew members per movie?", "evidence": "movie_crew records crew membership; person_id identifies a crew member and movie_id identifies the movie.", "SQL": "SELECT AVG(crew_cnt) AS avg_crew_per_movie FROM ( SELECT `movie_id`, COUNT(DISTINCT `person_id`) AS crew_cnt FROM `movie_crew` GROUP BY `movie_id` );"} {"question_id": 526, "db_id": "movies_4", "grading_method": "set", "question": "How many movies have \"vi\" as their language code?", "evidence": "\"vi\" as their language code refers to language_code = 'vi'", "SQL": "SELECT COUNT(DISTINCT T1.movie_id) FROM movie_languages AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_code = 'vi'"} {"question_id": 535, "db_id": "movies_4", "grading_method": "set", "question": "What percentage of movies in the movie catalog have the US listed as a production country?", "evidence": "movies in the movie catalog refers to the movie table, including movies with no production_country row; the US refers to country.country_iso_code = 'US' reached through production_country; percentage = DIVIDE(COUNT(DISTINCT movie_id with a US production country), COUNT(DISTINCT movie.movie_id)) * 100", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN c.country_iso_code = 'US' THEN m.movie_id END) / COUNT(DISTINCT m.movie_id) AS us_movie_percentage\nFROM movie AS m\nLEFT JOIN production_country AS pc ON pc.movie_id = m.movie_id\nLEFT JOIN country AS c ON c.country_id = pc.country_id;"} {"question_id": 536, "db_id": "movies_4", "grading_method": "set", "question": "Among movies with both female and male characters, what is the average of their female-to-male character ratios?", "evidence": "female refers to gender.gender = 'Female' and male refers to gender = 'Male'; for each movie_cast.movie_id the ratio = DIVIDE(COUNT(its female cast entries), COUNT(its male cast entries)), keeping only movies with at least one of each; answer = AVG of those per-movie ratios, unscaled", "SQL": "SELECT AVG(1.0 * female_cnt / male_cnt) AS avg_female_male_ratio\nFROM (\n SELECT mc.movie_id,\n SUM(CASE WHEN g.gender = 'Female' THEN 1 ELSE 0 END) AS female_cnt,\n SUM(CASE WHEN g.gender = 'Male' THEN 1 ELSE 0 END) AS male_cnt\n FROM movie_cast mc\n JOIN gender g ON mc.gender_id = g.gender_id\n GROUP BY mc.movie_id\n HAVING male_cnt > 0 AND female_cnt > 0\n) sub;"} {"question_id": 546, "db_id": "movies_4", "grading_method": "set", "question": "List the job titles of Sally Menke in the crew.", "evidence": "job titles refers to job", "SQL": "SELECT DISTINCT T2.job FROM person AS T1 INNER JOIN movie_crew AS T2 ON T1.person_id = T2.person_id WHERE T1.person_name = 'Sally Menke'"} {"question_id": 558, "db_id": "movies_4", "grading_method": "set", "question": "How many production companies made more than 150 movies?", "evidence": "more than 150 movies refers to COUNT(company_name) > 150", "SQL": "SELECT COUNT(*) FROM ( SELECT T1.company_name AS CNAME FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING COUNT(T1.company_name) > 150 )"} {"question_id": 559, "db_id": "movies_4", "grading_method": "set", "question": "What is the role of Mark Hammel?", "evidence": "role refers to job", "SQL": "SELECT T2.job FROM person AS T1 INNER JOIN movie_crew AS T2 ON T1.person_id = T2.person_id WHERE T1.person_name = 'Mark Hammel'"} {"question_id": 563, "db_id": "movies_4", "grading_method": "set", "question": "What percentage of the movies in the movie catalog are horror movies?", "evidence": "movies in the catalog refers to COUNT(DISTINCT movie.movie_id), including catalog movies with no movie_genres assignments; horror movies refers to catalog movies whose movie_genres assignments give genre.genre_name = 'Horror'; percentage = DIVIDE(100.0 * COUNT(DISTINCT movie_id of those horror movies), COUNT(DISTINCT movie.movie_id))", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN g.genre_name = 'Horror' THEN m.movie_id END) / COUNT(DISTINCT m.movie_id) FROM movie m LEFT JOIN movie_genres mg ON m.movie_id=mg.movie_id LEFT JOIN genre g ON mg.genre_id=g.genre_id"} {"question_id": 566, "db_id": "codebase_comments", "grading_method": "set", "question": "How many methods marked as English have comments in XML format?", "evidence": "Method.Lang = 'en' denotes English; Method.CommentIsXml = 1 denotes an XML comment.", "SQL": "SELECT COUNT(Lang) FROM Method WHERE Lang = 'en' AND CommentIsXml = 1"} {"question_id": 567, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the task of the method whose tokenized name is \"online median filter test median window filling\"?", "evidence": "tokenized name refers to NameTokenized; task of the method refers to the second part of name deliminated by \".\"; for example, the task of 'LinqToDelicious.HttpWebRequestFactory.Create' is 'HttpWebRequestFactory'", "SQL": "SELECT SUBSTR(SUBSTR(Name, INSTR(Name, '.') + 1), 1, INSTR(SUBSTR(Name, INSTR(Name, '.') + 1), '.') - 1) task FROM Method WHERE NameTokenized = 'online median filter test median window filling'"} {"question_id": 574, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the github address of the \"nofear_Mara\\Mara.sln\" solution path?", "evidence": "github address of repository refers to Url;", "SQL": "SELECT Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE Path = 'nofear_Mara\\Mara.sln'"} {"question_id": 575, "db_id": "codebase_comments", "grading_method": "set", "question": "Which repository has the longest download processing time, and can all its solutions run without compilation? Give the repository ID and answer Yes or No.", "evidence": "longest download processing time refers to Repo.ProcessedTime = MAX(ProcessedTime) over Repo; answer 'Yes' only if every solution of that repository has Solution.NeedsCompilation = 0, otherwise 'No', so a NULL NeedsCompilation or a repository with no solutions gives 'No'; return both the repository Id and that Yes/No answer", "SQL": "SELECT r.Id AS RepoId,\n CASE WHEN MIN(CASE WHEN s.NeedsCompilation = 0 THEN 1 ELSE 0 END) = 1 THEN 'Yes' ELSE 'No' END AS CanRunWithoutCompilation\nFROM Repo r\nLEFT JOIN Solution s ON s.RepoId = r.Id\nWHERE r.ProcessedTime = (SELECT MAX(ProcessedTime) FROM Repo)\nGROUP BY r.Id;"} {"question_id": 579, "db_id": "codebase_comments", "grading_method": "set", "question": "How many solution paths are there inside the 2nd most popular repository?", "evidence": "more watchers mean that this repository is more popular; most popular repository refers to max(Watchers);", "SQL": "SELECT COUNT(DISTINCT T2.Path) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Watchers = ( SELECT Watchers FROM Repo ORDER BY Watchers DESC LIMIT 1, 1 )"} {"question_id": 581, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the full comment on the method whose solution path is \"bmatzelle_nini\\Source\\Nini.sln\" with a tokenized name of \"alias text add alias\"?", "evidence": "", "SQL": "SELECT T2.FullComment FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'bmatzelle_nini\\Source\\Nini.sln' AND T2.NameTokenized = 'alias text add alias'"} {"question_id": 582, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the linearized sequence of API calls for methods in the solution whose path is “mauriciodeamorim_tdd.encontro2\\Tdd.Encontro2.sln”?", "evidence": "Linearized API-call sequences are Method.ApiCalls. Solution paths are Solution.Path; the requested path is 'mauriciodeamorim_tdd.encontro2\\Tdd.Encontro2.sln'.", "SQL": "SELECT T2.ApiCalls FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'mauriciodeamorim_tdd.encontro2\\Tdd.Encontro2.sln'"} {"question_id": 586, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the language of the method used in the solution path \"opendns_diagnosticapp\\windows\\OpenDnsDiagnostic.sln\"?", "evidence": "language refers to Lang;", "SQL": "SELECT DISTINCT T2.Lang FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'opendns_diagnosticapp\\windows\\OpenDnsDiagnostic.sln'"} {"question_id": 588, "db_id": "codebase_comments", "grading_method": "set", "question": "Are the comments for the method \"HtmlSharp.HtmlParser.Feed\" in XML format? Yes or No.", "evidence": "the comment for this method is not XML refers to CommentsXML = 0; the comments for this method is XML refers to CommentsXML = 1", "SQL": "SELECT CASE WHEN CommentIsXml = 0 THEN 'No' WHEN CommentIsXml = 1 THEN 'Yes' END isXMLFormat FROM Method WHERE Name = 'HtmlSharp.HtmlParser.Feed'"} {"question_id": 592, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the github address of the repository that contains files used by solution ID12?", "evidence": "github address refers to Url;", "SQL": "SELECT T1.Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Id = 12"} {"question_id": 593, "db_id": "codebase_comments", "grading_method": "set", "question": "How many solutions in repositories with more than 1,000 forks do not require compilation?", "evidence": "Repo.Forks records the number of forks. Solution.NeedsCompilation uses 1 for compilation required and 0 for compilation not required; NULL means unknown.", "SQL": "SELECT COUNT(T2.RepoId) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Forks > 1000 AND T2.NeedsCompilation = 0"} {"question_id": 594, "db_id": "codebase_comments", "grading_method": "set", "question": "Which of solutions 18 and 19 belongs to the repository with more watchers? Give the solution ID.", "evidence": "Repo.Watchers records the watcher count. Solution.Id is the solution ID and Solution.RepoId identifies its repository.", "SQL": "SELECT s.Id FROM Solution s JOIN Repo r ON r.Id=s.RepoId WHERE s.Id IN (18,19) AND r.Watchers=(SELECT MAX(r2.Watchers) FROM Solution s2 JOIN Repo r2 ON r2.Id=s2.RepoId WHERE s2.Id IN (18,19))"} {"question_id": 596, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the processed time to download the repository whose files are contained in the solution with the path \"jeffdik_tachy\\src\\Tachy.sln\".", "evidence": "", "SQL": "SELECT DISTINCT T1.ProcessedTime FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Path = 'jeffdik_tachy\\src\\Tachy.sln'"} {"question_id": 598, "db_id": "codebase_comments", "grading_method": "set", "question": "Please list all the paths of the solutions containing files within the repository whose url is \"https://github.com/maxild/playground.git\".", "evidence": "", "SQL": "SELECT T2.Path FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Url = 'https://github.com/maxild/playground.git'"} {"question_id": 608, "db_id": "codebase_comments", "grading_method": "set", "question": "For the repository which got '8094' Stars, how many solutions does it contain?", "evidence": "repository refers to Repo.Id;", "SQL": "SELECT COUNT(T2.RepoId) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Stars = 8094"} {"question_id": 610, "db_id": "codebase_comments", "grading_method": "set", "question": "For the method which got the tokenized name as 'interp parser expr', what is the processed time for its solution?", "evidence": "tokenized name refers to NameTokenized; NameTokenized = 'interp parser expr'; processed time for its solution refers to ProcessedTime;", "SQL": "SELECT T1.ProcessedTime FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.NameTokenized = 'interp parser expr'"} {"question_id": 611, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the repository number for the solution of method \"SCore.Poisson.ngtIndex\"?", "evidence": "repository number refers to RepoId; method refers to Name; Name = 'SCore.Poisson.ngtIndex'", "SQL": "SELECT T1.RepoId FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Name = 'SCore.Poisson.ngtIndex'"} {"question_id": 613, "db_id": "codebase_comments", "grading_method": "set", "question": "For the repository with '8094' watchers , how many solutions does it contain?", "evidence": "repository refers to Repo.Id and RepoId; solutions a repository contains refers to Solution.Id;", "SQL": "SELECT COUNT(T2.RepoId) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Watchers = 8094"} {"question_id": 617, "db_id": "codebase_comments", "grading_method": "set", "question": "How many watchers does the repository containing the solution with ID 326689 have?", "evidence": "Solution.RepoId identifies the repository containing a solution.", "SQL": "SELECT T1.Watchers FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Id = 326689"} {"question_id": 618, "db_id": "codebase_comments", "grading_method": "set", "question": "For each repository with 189 stars, give its ID and the number of solutions that require compilation.", "evidence": "Repo.Stars records the number of stars; Repo.Id identifies the repository. Solution.NeedsCompilation uses 1 for compilation required and 0 for compilation not required; NULL means unknown.", "SQL": "SELECT r.Id AS RepoId,\n COUNT(s.Id) AS NumSolutionsNeedingCompile\nFROM Repo r\nLEFT JOIN Solution s\n ON r.Id = s.RepoId AND s.NeedsCompilation = 1\nWHERE r.Stars = 189\nGROUP BY r.Id;"} {"question_id": 620, "db_id": "codebase_comments", "grading_method": "set", "question": "For the methods which got the tokenized name as 't jadwal entity get single mpic', what are the path times for their solution?", "evidence": "tokenized name refers to NameTokenized; NameTokenized = 't jadwal entity get single mpic'; path time for its solution refers to ProcessedTime;", "SQL": "SELECT T1.ProcessedTime FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.NameTokenized = 't jadwal entity get single mpic'"} {"question_id": 621, "db_id": "codebase_comments", "grading_method": "set", "question": "Give the repository ID for the solution of method \"Kalibrasi.Data.EntityClasses.THistoryJadwalEntity.GetSingleTjadwal\".", "evidence": "repository ID refers to RepoID; method refers to Name; Name = 'Kalibrasi.Data.EntityClasses.THistoryJadwalEntity.GetSingleTjadwal';", "SQL": "SELECT DISTINCT T1.RepoId FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Name = 'Kalibrasi.Data.EntityClasses.THistoryJadwalEntity.GetSingleTjadwal'"} {"question_id": 623, "db_id": "codebase_comments", "grading_method": "set", "question": "Give the number of solutions that the repository, which has 3060 Stars, contains.", "evidence": "solutions refers to Solution.Id; repository refers to Repository.Id;", "SQL": "SELECT COUNT(T2.RepoId) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Stars = 3060"} {"question_id": 624, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the path of the solution with the most methods written in the language “sw”?", "evidence": "methods written in the language “sw” refers to Method.Lang = 'sw'; a method belongs to a solution through Method.SolutionId = Solution.Id; the solution with the most such methods refers to the SolutionId whose COUNT of 'sw' methods equals the MAX of those per-solution counts; return Solution.Path", "SQL": "WITH sw_counts AS (SELECT `SolutionId`, COUNT(*) AS cnt FROM `Method` WHERE `Lang` = 'sw' GROUP BY `SolutionId`), max_cnt AS (SELECT MAX(cnt) AS max_cnt FROM sw_counts) SELECT `S`.`Path` FROM `Solution` AS `S` JOIN sw_counts AS `C` ON `C`.`SolutionId` = `S`.`Id` JOIN max_cnt AS `M` ON `C`.`cnt` = `M`.`max_cnt`;"} {"question_id": 628, "db_id": "codebase_comments", "grading_method": "set", "question": "List all the methods with a solution with a \"636449701378925547\" processed time.", "evidence": "methods refers to Name; solution refers to SolutionId;", "SQL": "SELECT DISTINCT T2.Name FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.ProcessedTime = 636449701378925547"} {"question_id": 630, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the total processed time of all solutions from the repository with the most forks?", "evidence": "total processed time = SUM(ProcessedTime where MAX(Forks)); repository with the most forks refers to MAX(Forks);", "SQL": "SELECT SUM(T2.ProcessedTime) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Forks = ( SELECT MAX(Forks) FROM Repo )"} {"question_id": 633, "db_id": "codebase_comments", "grading_method": "set", "question": "What are the \"en\" methods with solutions from repository \"1093?\" List ids of such methods.", "evidence": "en methods refers to lang = 'en'; solution refers to Solution.Id; repository refers to RepoId; RepoId = 1093;", "SQL": "SELECT DISTINCT T2.id FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.RepoId = 1093 AND T2.Lang = 'en'"} {"question_id": 636, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the repository id of the method with tokenized name \"crc parameters get hash code\"?", "evidence": "repository id refers to RepoId; tokenized name refers to NameTokenized; NameTokenized = 'crc parameters get hash code';", "SQL": "SELECT T1.RepoId FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.NameTokenized = 'crc parameters get hash code'"} {"question_id": 637, "db_id": "codebase_comments", "grading_method": "set", "question": "How many methods have solutions with the path ‘maravillas_linq-to-delicious\\tasty.sln’?", "evidence": "Methods are associated with solutions by Method.SolutionId. The requested solution path is Solution.Path = 'maravillas_linq-to-delicious\\tasty.sln'.", "SQL": "SELECT COUNT(T2.SolutionId) FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'maravillas_linq-to-delicious\\tasty.sln'"} {"question_id": 638, "db_id": "codebase_comments", "grading_method": "set", "question": "List all the solution IDs for the repository with processed time \"636430968896066073\".", "evidence": "Repository processing time is Repo.ProcessedTime; the requested value is 636430968896066073. Solution IDs are Solution.Id.", "SQL": "SELECT T2.Id FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.ProcessedTime = 636430968896066073"} {"question_id": 646, "db_id": "codebase_comments", "grading_method": "set", "question": "Please provide the number of stars that the repository of the solution 20 have.", "evidence": "solution refers to Solution.ID; Solution.Id = 20;", "SQL": "SELECT T1.Stars FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Id = 20"} {"question_id": 649, "db_id": "codebase_comments", "grading_method": "set", "question": "Please list the names of methods with the solution path \"wallerdev_htmlsharp\\HtmlSharp.sln\".", "evidence": "name of the methods refers to Name; solution path refers to Path; Path = 'wallerdev_htmlsharp\\HtmlSharp.sln';", "SQL": "SELECT T2.Name FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'wallerdev_htmlsharp\\HtmlSharp.sln'"} {"question_id": 651, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the url of solution 1?", "evidence": "solution refers to Solution.Id; Solution.Id = 1;", "SQL": "SELECT T1.Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Id = 1"} {"question_id": 654, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the solution path for the method whose tokenized name is ‘html parser feed’?", "evidence": "Solution path is Solution.Path. A method’s tokenized name is Method.NameTokenized; the requested value is 'html parser feed'.", "SQL": "SELECT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.NameTokenized = 'html parser feed'"} {"question_id": 659, "db_id": "codebase_comments", "grading_method": "set", "question": "How many methods in the repository with ID 3 have comments in XML format?", "evidence": "Method.CommentIsXml = 1 denotes an XML comment. Solution.RepoId identifies the repository containing the method’s solution.", "SQL": "SELECT COUNT(T2.SolutionId) FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.RepoId = 3 AND T2.CommentIsXml = 1"} {"question_id": 665, "db_id": "codebase_comments", "grading_method": "set", "question": "Please provide a link to the most well-known repository's Github address.", "evidence": "link refers to Url; well-known repository refers to MAX(Watchers);", "SQL": "SELECT Url FROM Repo WHERE Watchers = ( SELECT MAX(Watchers) FROM Repo )"} {"question_id": 668, "db_id": "codebase_comments", "grading_method": "set", "question": "What is the language of method number 28 that can be found in the repository number 3?", "evidence": "language of method refers to Lang; method number refers to Method_100k.Id; Method_100k.Id = 28; repository number refers to RepoId; RepoID = 3;", "SQL": "SELECT T2.Lang FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Id = 28 AND T1.RepoId = 3"} {"question_id": 670, "db_id": "codebase_comments", "grading_method": "set", "question": "How many methods have tokenized names beginning with \"query language\" in repositories with more than one such method?", "evidence": "A method’s tokenized name is Method.NameTokenized; names beginning with “query language” use 'query language%'. A method belongs to a solution through Method.SolutionId, and the solution’s repository is Solution.RepoId.", "SQL": "SELECT SUM(cnt)\nFROM (\n SELECT s.`RepoId` AS RepoId, COUNT(*) AS cnt\n FROM `Method` m\n JOIN `Solution` s ON s.`Id` = m.`SolutionId`\n WHERE m.`NameTokenized` LIKE 'query language%'\n GROUP BY s.`RepoId`\n HAVING COUNT(*) > 1\n);"} {"question_id": 675, "db_id": "codebase_comments", "grading_method": "set", "question": "Provide the tokenized name of the method \"Sky.Excel.ExcelBook.TypeConvert\".", "evidence": "tokenized name refers to NameTokenized; Name = 'Sky.Excel.ExcelBook.TypeConvert';", "SQL": "SELECT NameTokenized FROM Method WHERE Name = 'Sky.Excel.ExcelBook.TypeConvert'"} {"question_id": 678, "db_id": "codebase_comments", "grading_method": "subset,=,5", "question": "List any five GitHub repository URLs containing a solution that does not require compilation", "evidence": "Repo.Url records the GitHub repository URL. Solution.NeedsCompilation uses 1 for compilation required and 0 for compilation not required; NULL means unknown.", "SQL": "SELECT T1.Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.NeedsCompilation = 0"} {"question_id": 681, "db_id": "codebase_comments", "grading_method": "set", "question": "List all solution paths that have sampling time of 636482822660118007.", "evidence": "solution path refers to Path; sampling time refers to SampledAt; SampledAt = 636482822660118007;", "SQL": "SELECT DISTINCT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.SampledAt = 636482822660118007"} {"question_id": 683, "db_id": "codebase_comments", "grading_method": "set", "question": "List all the method names for the solution path \"graffen_NLog.Targets.Syslog\\src\\NLog.Targets.Syslog.sln\".", "evidence": "Method names are Method.Name. Solution path is Solution.Path; the requested path is 'graffen_NLog.Targets.Syslog\\src\\NLog.Targets.Syslog.sln'.", "SQL": "SELECT DISTINCT T2.Name FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T1.Path = 'graffen_NLog.Targets.Syslog\\src\\NLog.Targets.Syslog.sln'"} {"question_id": 686, "db_id": "codebase_comments", "grading_method": "set", "question": "How many stars does the repository for solution path “ninject_Ninject\\Ninject.sln” have?", "evidence": "Repository star count is Repo.Stars. Solution path is Solution.Path; the requested path is 'ninject_Ninject\\Ninject.sln'.", "SQL": "SELECT DISTINCT T1.Stars FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Path = 'ninject_Ninject\\Ninject.sln'"} {"question_id": 697, "db_id": "trains", "grading_method": "set", "question": "Please list the IDs of all the trains that run in the east direction and have less than 4 cars.", "evidence": "less than 4 cars refers to COUNT(cars) < 4", "SQL": "SELECT t.id\nFROM trains AS t\nLEFT JOIN cars AS c ON t.id = c.train_id\nWHERE t.direction = 'east'\nGROUP BY t.id\nHAVING COUNT(DISTINCT c.id) < 4;"} {"question_id": 701, "db_id": "trains", "grading_method": "set", "question": "In which direction does the train with an ellipse-shape car run?", "evidence": "shape = 'ellipse'", "SQL": "SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.shape = 'ellipse'"} {"question_id": 708, "db_id": "trains", "grading_method": "set", "question": "What is the average number of cars per eastbound train, including trains with no cars?", "evidence": "eastbound trains refers to trains.direction = 'east'; average number of cars per eastbound train = DIVIDE(COUNT(cars.id), COUNT(DISTINCT trains.id)), keeping eastbound trains that have no cars in the denominator", "SQL": "SELECT COUNT(c.id) * 1.0 / COUNT(DISTINCT t.id)\nFROM trains AS t LEFT JOIN cars AS c ON c.train_id=t.id\nWHERE t.direction='east';"} {"question_id": 711, "db_id": "trains", "grading_method": "set", "question": "How many trains are running west?", "evidence": "west is a direction", "SQL": "SELECT COUNT(id) FROM trains WHERE direction = 'west'"} {"question_id": 720, "db_id": "trains", "grading_method": "set", "question": "Among the trains running west, how many trains have no more than one car with an open roof?", "evidence": "running west refers to direction = 'west'; open roof refers to roof = 'none'", "SQL": "WITH one_car AS (\n SELECT t.id AS id\n FROM trains AS t\n JOIN cars AS c ON t.id = c.train_id\n WHERE t.direction = 'west' AND c.roof = 'none'\n GROUP BY t.id\n HAVING COUNT(c.id) <= 1),\nzero_car AS (\n SELECT t.id AS id\n FROM trains AS t\n LEFT JOIN cars AS c ON t.id = c.train_id AND c.roof = 'none'\n WHERE t.direction = 'west' AND c.train_id IS NULL\n GROUP BY t.id)\nSELECT COUNT(DISTINCT id) FROM (SELECT id FROM one_car UNION SELECT id FROM zero_car);"} {"question_id": 727, "db_id": "trains", "grading_method": "set", "question": "Provide the directions for all the trains that have 2 or less cars.", "evidence": "2 or less cars refers to COUNT(cars) < = 2", "SQL": "SELECT t.direction\nFROM trains AS t\nLEFT JOIN cars AS c ON t.id = c.train_id\nGROUP BY t.id\nHAVING COUNT(c.id) <= 2;"} {"question_id": 731, "db_id": "movie", "grading_method": "set", "question": "Which character has the longest screen time in the movie Batman?", "evidence": "longest screen time refers to max(screentime); movie Batman refers to title = 'Batman'", "SQL": "SELECT T2.`Character Name` FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID WHERE T1.Title = 'Batman' AND T2.screentime = \n(SELECT MAX(T4.screentime) FROM movie AS T3 INNER JOIN characters AS T4 ON T3.MovieID = T4.MovieID WHERE T3.Title = 'Batman')"} {"question_id": 733, "db_id": "movie", "grading_method": "set", "question": "Please list the names of the actors who played a role in the movie Batman.", "evidence": "movie Batman refers to title = 'Batman'", "SQL": "SELECT T3.Name 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.Title = 'Batman'"} {"question_id": 742, "db_id": "movie", "grading_method": "set", "question": "What is the average rating of all the movies starring Tom Cruise?", "evidence": "starring Tom Cruise refers to name = 'Tom Cruise'; average rating = divide(sum(rating where name = 'Tom Cruise'), count(movieid where name = 'Tom Cruise'))", "SQL": "SELECT AVG(rating) FROM (\n SELECT T1.Rating rating 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 T3.Name = 'Tom Cruise' GROUP BY T1.MovieID)"} {"question_id": 743, "db_id": "movie", "grading_method": "set", "question": "By what percentage is Batman’s most important character’s screen time greater than the least important character’s?", "evidence": "Batman refers to movie.Title = 'Batman'; screen time refers to characters.screentime converted from hours:minutes:seconds to seconds; the most and least important character refers to the MAX and MIN of that screen time for Batman; percentage greater refers to DIVIDE(SUBTRACT(MAX, MIN), MIN) * 100", "SQL": "WITH t AS ( SELECT a.Name Name, CAST(substr(c.`screentime`,1,instr(c.`screentime`,':')-1) AS REAL) * 3600 + CAST(substr(c.screentime, -5, 2) AS REAL) * 60 + CAST(substr(c.screentime, -2, 2) AS REAL) total_seconds FROM movie m join characters c on m.MovieID = c.MovieID join actor a on a.ActorID = c.ActorID where m.`Title` = 'Batman' AND c.`screentime` IS NOT NULL) SELECT (MAX(total_seconds) - MIN(total_seconds)) / MIN(total_seconds) * 100 FROM t"} {"question_id": 747, "db_id": "movie", "grading_method": "set", "question": "Which actors had the longest screen time in the movie ‘Batman’?", "evidence": "'Batman' refers to movie.Title = 'Batman'; screen time refers to characters.screentime, read as hours * 3600 + minutes * 60 + seconds; the longest screen time refers to the MAX of that value; return actor.Name for every actor tied at it", "SQL": "WITH t AS ( SELECT a.Name Name, CAST(substr(c.`screentime`,1,instr(c.`screentime`,':')-1) AS INTEGER) hours, CAST(substr(c.screentime, -5, 2) AS INTEGER) minutes, CAST(substr(c.screentime, -2, 2) AS INTEGER) seconds FROM movie m join characters c on m.MovieID = c.MovieID join actor a on a.ActorID = c.ActorID where m.`Title` = 'Batman' AND c.`screentime` IS NOT NULL) SELECT Name FROM t WHERE hours*3600 + minutes * 60 + seconds = ( SELECT MAX(hours*3600 + minutes * 60 + seconds) FROM t );"} {"question_id": 748, "db_id": "movie", "grading_method": "set", "question": "How many movies has the actor with the highest net worth acted in?", "evidence": "highest net worth refers to the MAX of actor.NetWorth taken as a number from its formatted currency text; how many movies refers to COUNT(*) of the characters rows of every actor whose net worth is equal to that MAX", "SQL": "SELECT COUNT(*) FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE CAST(REPLACE(REPLACE(T2.NetWorth, ',', ''), '$', '') AS REAL) = ( SELECT MAX(CAST(REPLACE(REPLACE(NetWorth, ',', ''), '$', '') AS REAL)) FROM actor)"} {"question_id": 753, "db_id": "movie", "grading_method": "set", "question": "How tall is the actor who played \"Lurch\"?", "evidence": "tall refers to Height (Inches); \"Lurch\" refers to Character Name = 'Lurch'", "SQL": "SELECT T2.`Height (Inches)` FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE T1.`Character Name` = 'Lurch'"} {"question_id": 755, "db_id": "movie", "grading_method": "set", "question": "Which actor played the No. 2 character in the credit list of ‘American Hustle’?", "evidence": "characters.creditOrder records credit-list position; American Hustle is recorded in movie.Title as 'American Hustle'.", "SQL": "SELECT T3.Name 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.Title = 'American Hustle' AND T2.creditOrder = '2'"} {"question_id": 761, "db_id": "movie", "grading_method": "set", "question": "What is the name of male and white actor with actor ID 439?", "evidence": "male refers to Gender = 'Male'; white refers to Ethnicity = 'White'", "SQL": "SELECT Name FROM actor WHERE ActorID = 439 AND Gender = 'Male' AND Ethnicity = 'White'"} {"question_id": 765, "db_id": "movie", "grading_method": "set", "question": "Among the actors who appear in PG rated movies, what are the genres of the PG rated movies starred by those with the highest net worth?", "evidence": "PG rated refers to MPAA Rating = 'PG';  highest net worth refers to max(NetWorth)", "SQL": "SELECT T1.Genre 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.`MPAA Rating` = 'PG' AND CAST(REPLACE(REPLACE(T3.NetWorth, ',', ''), '$', '') AS REAL) = (SELECT MAX(CAST(REPLACE(REPLACE(T3.NetWorth, ',', ''), '$', '') AS REAL)) 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.`MPAA Rating` = 'PG' );"} {"question_id": 771, "db_id": "movie", "grading_method": "set", "question": "Find the actor's name that played as Don Altobello in a drama movie that has a gross of 136766062.", "evidence": "actor's name refers to Name; as Don Altobello refers to Character Name = 'Don Altobello'; drama movie refers to Genre = 'Drama'", "SQL": "SELECT T3.Name 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.Gross = 136766062 AND T2.`Character Name` = 'Don Altobello' AND T1.Genre = 'Drama'"} {"question_id": 774, "db_id": "movie", "grading_method": "set", "question": "Among the movies with drama genre, what is the percentage of the actors with net worth greater than $400,000,000.00?", "evidence": "drama genre refers to movie.Genre = 'Drama'; net worth refers to CAST(REPLACE(REPLACE(actor.NetWorth, ',', ''), '$', '') AS REAL), so greater than $400,000,000.00 refers to that value > 400000000; percentage = DIVIDE(COUNT(DISTINCT ActorID with that net worth), COUNT(DISTINCT ActorID)) * 100 over the actors cast in drama movies", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN CAST(REPLACE(REPLACE(`actor`.`NetWorth`, ',', ''), '$', '') AS REAL) > 400000000 THEN `actor`.`ActorID` END) / COUNT(DISTINCT `actor`.`ActorID`) AS percentage FROM `movie` JOIN `characters` ON `movie`.`MovieID` = `characters`.`MovieID` JOIN `actor` ON `actor`.`ActorID` = `characters`.`ActorID` WHERE `movie`.`Genre` = 'Drama';"} {"question_id": 782, "db_id": "social_media", "grading_method": "subset,>=,1", "question": "How many tweets in total were posted by a user in Argentina?", "evidence": "\"Argentina\" is the Country", "SQL": "SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.Country = 'Argentina'"} {"question_id": 783, "db_id": "social_media", "grading_method": "set", "question": "In which Argentine city do users post the most tweets?\n", "evidence": "\"Argentina\" is the Country; post the most tweets refers to Max(Count(TweetID))", "SQL": "SELECT T2.City \nFROM twitter AS T1 \nINNER JOIN location AS T2 ON T2.LocationID = T1.LocationID \nWHERE T2.Country = 'Argentina' \nGROUP BY T2.City \nHAVING COUNT(T1.TweetID) = (\n SELECT COUNT(T3.TweetID)\n FROM twitter AS T3 \n INNER JOIN location AS T4 ON T4.LocationID = T3.LocationID \n WHERE T4.Country = 'Argentina' \n GROUP BY T4.City\n ORDER BY COUNT(T3.TweetID) DESC LIMIT 1) "} {"question_id": 784, "db_id": "social_media", "grading_method": "set", "question": "Among all the tweets that are reshared, how many of them are posted by a user in Buenos Aires?", "evidence": "reshared refers to Isreshare = 'TRUE'; 'Buenos Aires' is the City", "SQL": "SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T2.City = 'Buenos Aires' AND T1.IsReshare = 'TRUE'"} {"question_id": 789, "db_id": "social_media", "grading_method": "set", "question": "Among all the users that have posted a tweet with over 1000 likes, how many of them are male?", "evidence": "over 1000 likes refers to Likes > 1000; 'Male' is the Gender of user", "SQL": "SELECT COUNT(DISTINCT T1.UserID) FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T1.Likes > 1000 AND T2.Gender = 'Male'"} {"question_id": 799, "db_id": "social_media", "grading_method": "set", "question": "Give the location id of West Sussex State.", "evidence": "", "SQL": "SELECT DISTINCT LocationID FROM location WHERE State = 'West Sussex'"} {"question_id": 801, "db_id": "social_media", "grading_method": "set", "question": "For the tweet which got a reach number of 547851, which country did it come from?", "evidence": "reach number of 547851 refers to Reach = 547851", "SQL": "SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Reach = 547851"} {"question_id": 802, "db_id": "social_media", "grading_method": "set", "question": "State the number of positive tweets from Ha Noi.", "evidence": "positive tweet refers to Sentiment > 0; 'Ha Noi' is the State", "SQL": "SELECT COUNT(T1.TweetID) FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Sentiment > 0 AND T2.State = 'Ha Noi'"} {"question_id": 826, "db_id": "social_media", "grading_method": "set", "question": "Which country's tweets collected the most likes?", "evidence": "country collected the most likes refers to Country where Max(Sum(Likes))", "SQL": "WITH country_num AS (\n SELECT T2.Country, SUM(T1.Likes) AS num \n FROM twitter AS T1 \n INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID \n GROUP BY T2.Country )\nSELECT Country FROM country_num\nWHERe num = (SELECT MAX(num) FROM country_num)"} {"question_id": 831, "db_id": "social_media", "grading_method": "set", "question": "State the country where the most positive sentiment tweets were posted.", "evidence": "country with the most positive sentiment tweet refers to Country where Max(Count(Sentiment > 0))", "SQL": "WITH country_num AS (\n SELECT T2.Country, COUNT(*) AS num \n FROM twitter AS T1 \n INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID \n WHERE T1.Sentiment > 0 \n GROUP BY T2.Country)\nSELECT Country FROM country_num \nWHERE num = (SELECt MAX(num) FROM country_num)"} {"question_id": 851, "db_id": "social_media", "grading_method": "set", "question": "Which tweets by male users in Argentina received the most likes? List their text, including ties.", "evidence": "male user refers to Gender = 'Male'; 'Argentina' is the Country; most number of likes refers to Max(Likes)", "SQL": "SELECT T2.text FROM user AS T1 INNER JOIN twitter AS T2 ON T1.UserID = T2.UserID INNER JOIN location AS T3 ON T2.LocationID = T3.LocationID WHERE T3.Country = 'Argentina' AND T1.Gender = 'Male' AND T2.Likes = (SELECT MAX(T5.Likes) FROM user AS T4 INNER JOIN twitter AS T5 ON T4.UserID = T5.UserID INNER JOIN location AS T6 ON T5.LocationID = T6.LocationID WHERE T6.Country = 'Argentina' AND T4.Gender = 'Male')"} {"question_id": 855, "db_id": "cs_semester", "grading_method": "set", "question": "Please list the names of the courses that are less important than Machine Learning Theory.", "evidence": "lower credit means less important;", "SQL": "SELECT name FROM course WHERE credit < ( SELECT credit FROM course WHERE name = 'Machine Learning Theory' )"} {"question_id": 857, "db_id": "cs_semester", "grading_method": "set", "question": "What is the phone number of Kerry Pryor?", "evidence": "", "SQL": "SELECT phone_number FROM student WHERE l_name = 'Pryor' AND f_name = 'Kerry'"} {"question_id": 859, "db_id": "cs_semester", "grading_method": "set", "question": "How many research assistants does Sauveur Skyme have?", "evidence": "research assistant refers to the student who serves for research where the abbreviation is RA;", "SQL": "SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.first_name = 'Sauveur' AND T2.last_name = 'Skyme'"} {"question_id": 862, "db_id": "cs_semester", "grading_method": "set", "question": "Please list the full names of all the students who took the course Machine Learning Theory.", "evidence": "full name refers to f_name and l_name;", "SQL": "SELECT T1.f_name, T1.l_name 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 = 'Machine Learning Theory'"} {"question_id": 864, "db_id": "cs_semester", "grading_method": "set", "question": "Please list the names of the courses taken by Laughton Antonio.", "evidence": "", "SQL": "SELECT T3.name 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 T1.f_name = 'Laughton' AND T1.l_name = 'Antonio'"} {"question_id": 866, "db_id": "cs_semester", "grading_method": "set", "question": "Which student is more satisfied with the course Machine Learning Theory, Willie Rechert or Laughton Antonio?", "evidence": "sat refers to student's satisfaction degree with the course; more satisfied refers to MAX(sat);", "SQL": "SELECT T1.f_name, T1.l_name 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 (T1.f_name = 'Laughton' OR T1.f_name = 'Willie') AND (T1.l_name = 'Antonio' OR T1.l_name = 'Rechert') AND T3.name = 'Machine Learning Theory' ORDER BY T2.sat DESC LIMIT 1"} {"question_id": 868, "db_id": "cs_semester", "grading_method": "set", "question": "Among the students who took the course Machine Learning Theory, how many of them are undergraduates?", "evidence": "UG is an abbreviated name of undergraduate student in which type = 'UG';", "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 = 'Machine Learning Theory' AND T1.type = 'UG'"} {"question_id": 869, "db_id": "cs_semester", "grading_method": "set", "question": "Which professor advised Willie Rechert as a research assistant? Give the professor’s first and last names.", "evidence": "RA records research-assistant appointments; RA.prof_id identifies the advising professor. prof.first_name and prof.last_name record the professor’s name; student.f_name and student.l_name record the student’s name.", "SQL": "SELECT T1.first_name, T1.last_name FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T3.f_name = 'Willie' AND T3.l_name = 'Rechert'"} {"question_id": 871, "db_id": "cs_semester", "grading_method": "set", "question": "What is the average satisfaction score for the course Machine Learning Theory?", "evidence": "Student satisfaction for a course is registration.sat. Course name is course.name; Machine Learning Theory is stored as 'Machine Learning Theory'.", "SQL": "SELECT CAST(SUM(T1.sat) AS REAL) / COUNT(T1.student_id) FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.name = 'Machine Learning Theory'"} {"question_id": 883, "db_id": "cs_semester", "grading_method": "set", "question": "Provide the number of students enrolled in the \"Statistical Learning\" course.", "evidence": "", "SQL": "SELECT COUNT(DISTINCT T2.student_id) FROM course AS T1 INNER JOIN registration AS T2 ON T1.course_id = T2.course_id WHERE T1.name = 'Statistical learning'"} {"question_id": 886, "db_id": "cs_semester", "grading_method": "set", "question": "What is the percentage of Professor Ogdon Zywicki's research assistants are taught postgraduate students?", "evidence": "research assistant refers to the student who serves for research where the abbreviation is RA; taught postgraduate student refers to type = 'TPG'; DIVIDE(COUNT(student_id where type = 'TPG' and first_name = 'Ogdon', last_name = 'Zywicki'), COUNT(first_name = 'Ogdon', last_name = 'Zywicki')) * 100 as percentage;", "SQL": "SELECT CAST(SUM(CASE WHEN T3.type = 'TPG' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T1.student_id = T3.student_id WHERE T2.first_name = 'Ogdon' AND T2.last_name = 'Zywicki'"} {"question_id": 888, "db_id": "cs_semester", "grading_method": "set", "question": "How many courses have the highest difficulty?", "evidence": "diff refers to difficulty; diff is higher means the course is more difficult in which highest difficulty is expessed as diff = 5;", "SQL": "SELECT COUNT(*)\nFROM course\nWHERE diff = (SELECT MAX(diff) FROM course);"} {"question_id": 889, "db_id": "cs_semester", "grading_method": "set", "question": "What are the first and last names of professors who graduated from an Ivy League university?", "evidence": "Ivy League school is assembled by 8 universities: Brown University, Columbia University, Cornell University, Dartmouth College, Harvard University, Princeton University, University of Pennsylvania and Yale University;", "SQL": "SELECT first_name, last_name FROM prof WHERE graduate_from IN ( 'Brown University', 'Columbia University', 'Cornell University', 'Dartmouth College', 'Harvard University', 'Princeton University', 'University of Pennsylvania', 'Yale University' )"} {"question_id": 892, "db_id": "cs_semester", "grading_method": "set", "question": "Among the most popular professors, how many are females?", "evidence": "the most popular professors refers to prof.popularity = MAX(popularity) over prof; females refers to prof.gender = 'Female'; how many refers to COUNT of the prof records with both", "SQL": "SELECT COUNT(prof_id) FROM prof WHERE gender = 'Female' AND popularity = ( SELECT MAX(popularity) FROM prof )"} {"question_id": 896, "db_id": "cs_semester", "grading_method": "set", "question": "Among the easiest courses, what is the name of the course where most students got an A?", "evidence": "diff refers to difficulty; the easiest courses refers to diff = 1; A refers to an excellent grade in which grade = 'A' for the course;", "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.diff = 1 GROUP BY T2.name ORDER BY COUNT(T1.student_id) DESC LIMIT 1"} {"question_id": 898, "db_id": "cs_semester", "grading_method": "set", "question": "How many students does Ogdon Zywicki advise?", "evidence": "Ogdon Zywicki is a professor;", "SQL": "SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.first_name = 'Ogdon' AND T2.last_name = 'Zywicki'"} {"question_id": 900, "db_id": "cs_semester", "grading_method": "set", "question": "What are the names of the courses that the students with the lowest intelligence are least satisfied with?", "evidence": "lower intelligence refers to intelligence = 1; sat refers to student's satisfaction degree with the course where least satisfaction refers to sat = 1;", "SQL": "SELECT T3.name 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.sat = 1 AND T1.intelligence = 1"} {"question_id": 902, "db_id": "cs_semester", "grading_method": "set", "question": "What is the popularity of the professor who advises the highest number of students with the highest research ability?", "evidence": "professor with the highest research ability refers to prof_id where MAX(capability);", "SQL": "WITH prof_ra_num AS (\n SELECT p.popularity, COUNT(*) num\n FROM prof p\n JOIN RA r ON r.prof_id = p.prof_id\n WHERE r.capability = (SELECT MAX(capability) FROM RA)\n GROUP BY p.prof_id)\nSELECT popularity FROM prof_ra_num WHERE num = (SELECT MAX(num) FROm prof_ra_num)"} {"question_id": 904, "db_id": "cs_semester", "grading_method": "set", "question": "How many students, who have a GPA between 3 to 4, failed a course?", "evidence": "GPA is an abbreviated name of Grade Point Average where GPA between 3 to 4 refers to gpa BETWEEN 3 AND 4; If grade is null or empty, it means that this student fails to pass this course;", "SQL": "SELECT COUNT(DISTINCT T2.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id WHERE T2.grade IS NULL AND T1.gpa BETWEEN 3 AND 4"} {"question_id": 905, "db_id": "cs_semester", "grading_method": "set", "question": "How many students taking a bachelor's degree received an A in all of the courses that they took?", "evidence": "bachelor's degree is an undergraduate degree in which type = 'UG'; A refers to an excellent grade in which grade = 'A';", "SQL": "SELECT COUNT(*)\nFROM `student` AS s\nWHERE s.`type` = 'UG'\n AND EXISTS (SELECT 1\n FROM `registration` AS r1\n WHERE r1.`student_id` = s.`student_id`)\n AND NOT EXISTS (\n SELECT 1\n FROM `registration` AS r2\n WHERE r2.`student_id` = s.`student_id`\n AND (r2.`grade` IS NULL OR r2.`grade` <> 'A')\n );"} {"question_id": 907, "db_id": "cs_semester", "grading_method": "set", "question": "List the professors' IDs and students' IDs with the lowest research ability.", "evidence": "the lowest research ability refers to MIN(capability); professor’s ID refers to prof_id;", "SQL": "SELECT prof_id, student_id FROM RA WHERE capability = ( SELECT MIN(capability) FROM RA )"} {"question_id": 916, "db_id": "cs_semester", "grading_method": "set", "question": "What are the first and last names of students who earned an A in any course tied for the highest difficulty?", "evidence": "a course tied for the highest difficulty refers to course.diff = MAX(diff) over course; earned an A refers to registration.grade = 'A'; return the distinct student.f_name and student.l_name of the students with such a registration", "SQL": "SELECT DISTINCT s.`f_name`, s.`l_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 c.`diff` = (SELECT MAX(`diff`) FROM `course`)\n AND r.`grade` = 'A';"} {"question_id": 919, "db_id": "cs_semester", "grading_method": "set", "question": "Calculate Laughton Antonio's overall GPA from this semester.", "evidence": "Semester GPA is the credit-weighted average of registration grades: A = 4, B = 3, C = 2, D = 1, and a missing or empty grade = 0. Include the credits of failed courses in the denominator.", "SQL": "SELECT SUM(c.credit * CASE r.grade WHEN 'A' THEN 4 WHEN 'B' THEN 3 WHEN 'C' THEN 2 WHEN 'D' THEN 1 ELSE 0 END) * 1.0 / SUM(c.credit) AS semester_gpa FROM student AS s INNER JOIN registration AS r ON s.student_id = r.student_id INNER JOIN course AS c ON r.course_id = c.course_id WHERE s.f_name = 'Laughton' AND s.l_name = 'Antonio' GROUP BY s.student_id"} {"question_id": 921, "db_id": "cs_semester", "grading_method": "set", "question": "Describe the names and capability of the students who were advised by professors graduated from the University of Washington.", "evidence": "names of the students = f_name, l_name;", "SQL": "SELECT T3.f_name, T3.l_name, T2.capability FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T1.graduate_from = 'University of Washington'"} {"question_id": 927, "db_id": "cs_semester", "grading_method": "set", "question": "What is the credit of the course named \"Computer Vision\"?", "evidence": "", "SQL": "SELECT credit FROM course WHERE name = 'Computer Vision'"} {"question_id": 930, "db_id": "cs_semester", "grading_method": "set", "question": "Among the students with high salary, what is total number of students with a GPA higher than 3?", "evidence": "high salary refers to salary = 'high'; GPA higher than 3 refers to gpa > 3;", "SQL": "SELECT COUNT(DISTINCT T1.student_id) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'high' AND T2.gpa > 3"} {"question_id": 932, "db_id": "cs_semester", "grading_method": "set", "question": "List the distinct capabilities of research postgraduate students with an intelligence level of 4 or above.", "evidence": "Research postgraduate students use student.type = 'RPG'. Intelligence level is student.intelligence, with 4 or above represented by >= 4. Capability is RA.capability.", "SQL": "SELECT DISTINCT T1.capability FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.type = 'RPG' AND T2.intelligence >= 4"} {"question_id": 933, "db_id": "cs_semester", "grading_method": "set", "question": "Among students with a grade of B, how many have an intelligence level of 3?", "evidence": "Student course grade is registration.grade; grade B is stored as 'B'. Student intelligence level is student.intelligence; the requested value is 3.", "SQL": "SELECT COUNT(DISTINCT T1.student_id) FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.grade = 'B' AND T2.intelligence = 3"} {"question_id": 938, "db_id": "cs_semester", "grading_method": "set", "question": "For 3-credit courses, how many students have a GPA of 3.2?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT 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.credit = 3 AND T1.gpa = 3.2"} {"question_id": 940, "db_id": "cs_semester", "grading_method": "set", "question": "List the email addresses of students with grade B in courses whose difficulty exceeds 80% of the average difficulty of all courses.", "evidence": "grade B refers to registration.grade = 'B'; difficulty refers to course.diff; difficulty exceeding 80% of the average difficulty of all courses refers to diff > MULTIPLY(AVG(diff) over the whole course table, 0.8); return student.email", "SQL": "SELECT T2.email FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T1.course_id = T3.course_id WHERE T1.grade = 'B' AND T3.diff > (SELECT AVG(diff) * 0.8 FROM course);"} {"question_id": 945, "db_id": "cs_semester", "grading_method": "set", "question": "Among the students with less than four intelligence, list the full name and phone number of students with a greater than 3 GPA.", "evidence": "intelligence < 4; full name = f_name, l_name; gpa > 3;", "SQL": "SELECT f_name, l_name, phone_number FROM student WHERE gpa > 3 AND intelligence < 4"} {"question_id": 951, "db_id": "cs_semester", "grading_method": "set", "question": "Give the full name and capability of RAs who failed in any courses.", "evidence": "full name of students = f_name, l_name; failed refers to grade IS NULL or grade is empty;", "SQL": "SELECT DISTINCT T2.f_name, T2.l_name, T1.capability FROM RA AS T1 INNER JOIN student AS T2 ON T2.student_id = T1.student_id INNER JOIN registration AS T3 ON T2.student_id = T3.student_id WHERE T3.grade IS NULL OR T3.grade = ''"} {"question_id": 955, "db_id": "cs_semester", "grading_method": "set", "question": "Calculate the difference in average satisfaction between students with 'high' salaries and those with 'free' salaries, based on each student's mean satisfaction score.", "evidence": "average satisfaction difference = SUBTRACT(AVG(sat where salary = 'high')), (AVG(sat where salary = 'free')); satisfaction refers to sat; no salary refers to salary = 'free';", "SQL": "WITH ra_flag AS (\n SELECT `student_id`,\n MAX(CASE WHEN `salary` = 'high' THEN 1 END) AS high_flag,\n MAX(CASE WHEN `salary` = 'free' THEN 1 END) AS free_flag\n FROM `RA`\n GROUP BY `student_id`\n),\nstudent_sat AS (\n SELECT `student_id`, AVG(`sat`) AS avg_sat\n FROM `registration`\n GROUP BY `student_id`\n)\nSELECT AVG(CASE WHEN high_flag = 1 THEN avg_sat END) -\n AVG(CASE WHEN free_flag = 1 THEN avg_sat END) AS diff\nFROM ra_flag\nJOIN student_sat USING (`student_id`);"} {"question_id": 956, "db_id": "cs_semester", "grading_method": "set", "question": "Find the university from which the professor who advised most undergraduate students graduated.", "evidence": "university from which the professor graduated refers to graduate_from; undergraduate students refers to type = 'UG';", "SQL": "SELECT T1.graduate_from FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T3.type = 'UG' GROUP BY T1.prof_id ORDER BY COUNT(T2.student_id) DESC LIMIT 1"} {"question_id": 957, "db_id": "cs_semester", "grading_method": "set", "question": "Among the professors with more than average teaching ability, list the full name and email address of the professors who advise two or more students.", "evidence": "more than average teaching ability refers to teachingability > AVG(teachingability); full_name of the professor = first_name, last_name; email address of the professor refers to email; advises two or more students refers to COUNT(student_id) > = 2;\n", "SQL": "SELECT T2.first_name, T2.last_name, T2.email FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.teachingability > ( SELECT AVG(teachingability) FROM prof ) GROUP BY T2.prof_id HAVING COUNT(T1.student_id) >= 2"} {"question_id": 960, "db_id": "cs_semester", "grading_method": "set", "question": "How many students of professors with the highest teachability have high salaries?", "evidence": "highest teachability refers to prof.teachingability = MAX(teachingability) over all professors; high salaries refers to RA.salary = 'high'; how many students refers to COUNT(DISTINCT RA.student_id) among those RA rows", "SQL": "SELECT COUNT(DISTINCT `RA`.`student_id`) FROM `RA` JOIN `prof` ON `RA`.`prof_id` = `prof`.`prof_id` WHERE `RA`.`salary` = 'high' AND `prof`.`teachingability` = (SELECT MAX(`teachingability`) FROM `prof`);"} {"question_id": 963, "db_id": "cs_semester", "grading_method": "set", "question": "How many students with an intelligence level of 2 are registered for at least one course with difficulty level 3?", "evidence": "course.diff records course difficulty; registration records students’ course registrations.", "SQL": "SELECT COUNT(DISTINCT 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.diff = 3 AND T1.intelligence = 2"} {"question_id": 964, "db_id": "cs_semester", "grading_method": "set", "question": "List the student's first and last name that got a C in the course named \"Applied Deep Learning\".", "evidence": "student's first name refers to f_name; student's last name refers to l_name; got a C refers to grade = 'C';", "SQL": "SELECT T1.f_name, T1.l_name 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 = 'Applied Deep Learning' AND T2.grade = 'C'"} {"question_id": 967, "db_id": "computer_student", "grading_method": "set", "question": "What is the average number of students that an advisor supervises?", "evidence": "students refers to advisedBy.p_id; advisor refers to p_id_dummy; average number = avg(count(advisedBy.p_id))", "SQL": "SELECT CAST(COUNT(p_id) AS REAL) / COUNT(DISTINCT p_id_dummy) AS avgnum FROM advisedBy"} {"question_id": 968, "db_id": "computer_student", "grading_method": "set", "question": "How many professors are teaching course ID 18?", "evidence": "professors refers to taughtBy.p_id; course ID 18 refers to taughtBy.course_id", "SQL": "SELECT COUNT(DISTINCT t.`p_id`)\nFROM `taughtBy` AS t\nJOIN `person` AS p ON t.`p_id` = p.`p_id`\nWHERE t.`course_id` = 18\n AND p.`professor` = 1;"} {"question_id": 969, "db_id": "computer_student", "grading_method": "set", "question": "List all the course IDs for professional or master/graduate courses.", "evidence": "professional or master/graduate courses refers to courseLevel = 'Level_500'", "SQL": "SELECT course_id FROM course WHERE courseLevel = 'Level_500'"} {"question_id": 970, "db_id": "computer_student", "grading_method": "set", "question": "How many courses are there for basic or medium undergraduate courses?", "evidence": "basic or medium undergraduate courses refers to courseLevel = 'Level_300'; courses refers to course.course_id", "SQL": "SELECT COUNT(course_id) FROM course WHERE courseLevel = 'Level_300'"} {"question_id": 971, "db_id": "computer_student", "grading_method": "set", "question": "List the IDs of all professors who are not faculty members, along with the courses they teach.", "evidence": "ID of all professors refers to person.p_id where professor = 1; not faculty member refers to hasPosition = 0; courses refers to taughtBy.course_id", "SQL": "SELECT T2.p_id, T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition = 0"} {"question_id": 972, "db_id": "computer_student", "grading_method": "set", "question": "Which professors teach Level 400 undergraduate courses? Give their IDs.", "evidence": "course.courseLevel = 'Level_400' denotes the requested undergraduate course level. person.professor = 1 identifies professors; taughtBy.p_id identifies an instructor.", "SQL": "SELECT DISTINCT tb.`p_id`\nFROM `taughtBy` tb\nJOIN `course` c ON c.`course_id` = tb.`course_id`\nJOIN `person` p ON p.`p_id` = tb.`p_id`\nWHERE c.`courseLevel` = 'Level_400'\n AND p.`professor` = 1;"} {"question_id": 974, "db_id": "computer_student", "grading_method": "set", "question": "List the advisor IDs for students in their third program year.", "evidence": "advisedBy.p_id identifies the student and advisedBy.p_id_dummy identifies the advisor. person.yearsInProgram uses Year_3 for the third program year.", "SQL": "SELECT DISTINCT `T1`.`p_id_dummy`\nFROM `advisedBy` AS `T1`\nJOIN `person` AS `S` ON `S`.`p_id` = `T1`.`p_id`\nWHERE `S`.`yearsInProgram` = 'Year_3';"} {"question_id": 975, "db_id": "computer_student", "grading_method": "set", "question": "Which level of courses is taught by professor ID 297?", "evidence": "professor ID 297 refers to taughtBy.p_id = 297", "SQL": "SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 297"} {"question_id": 980, "db_id": "computer_student", "grading_method": "set", "question": "Provide the ID of professors who teach in both harder undergraduate course and master/graduate courses.", "evidence": "harder undergraduate course refers to courseLevel = 'Level_400'; master/graduate courses refers to courseLevel = 'Level_500'; ID of professors refers to taughtBy.p_id", "SQL": "SELECT DISTINCT tb.`p_id`\nFROM `taughtBy` AS tb\nJOIN `course` AS c ON tb.`course_id` = c.`course_id`\nJOIN `person` AS p ON p.`p_id` = tb.`p_id`\nWHERE p.`professor` = 1\nGROUP BY tb.`p_id`\nHAVING SUM(CASE WHEN c.`courseLevel` = 'Level_400' THEN 1 ELSE 0 END) > 0\n AND SUM(CASE WHEN c.`courseLevel` = 'Level_500' THEN 1 ELSE 0 END) > 0;"} {"question_id": 983, "db_id": "computer_student", "grading_method": "set", "question": "How many undergraduate courses are classified as basic and medium level?", "evidence": "Basic and medium undergraduate courses use course.courseLevel = 'Level_300'.", "SQL": "SELECT COUNT(*) FROM course WHERE courseLevel = 'Level_300'"} {"question_id": 984, "db_id": "computer_student", "grading_method": "set", "question": "How many professors teach the course with ID 11?", "evidence": "taughtBy records instructors’ course assignments. person.professor = 1 identifies professors.", "SQL": "SELECT COUNT(T1.p_id) FROM taughtBy T1 JOIN person T2 ON T1.p_id = T2.p_id WHERE T1.course_id = 11 AND T2.professor = 1;"} {"question_id": 988, "db_id": "computer_student", "grading_method": "set", "question": "How many basic or medium undergraduate courses are taught by professors?", "evidence": "course.courseLevel = 'Level_300' identifies basic or medium undergraduate courses. person.professor = 1 identifies professors; taughtBy links courses to instructors.", "SQL": "SELECT COUNT(DISTINCT T1.`course_id`)\nFROM `course` AS T1\nJOIN `taughtBy` AS T2 ON T1.`course_id` = T2.`course_id`\nJOIN `person` AS T3 ON T3.`p_id` = T2.`p_id`\nWHERE T1.`courseLevel` = 'Level_300' AND T3.`professor` = 1;"} {"question_id": 989, "db_id": "computer_student", "grading_method": "set", "question": "List the IDs of faculty employees who teach a basic or medium-level undergraduate course.", "evidence": "person.hasPosition = 'Faculty_eme' denotes faculty employees. course.courseLevel = 'Level_300' denotes basic or medium-level undergraduate courses. taughtBy records teaching assignments.", "SQL": "SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id INNER JOIN person AS T3 ON T3.p_id = T2.p_id WHERE T1.courseLevel = 'Level_300' AND T3.hasPosition = 'Faculty_eme'"} {"question_id": 991, "db_id": "computer_student", "grading_method": "set", "question": "Please list the levels of all courses taught by teacher no. 79.", "evidence": "Course level is course.courseLevel. Teacher number 79 is taughtBy.p_id = 79.", "SQL": "SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 79"} {"question_id": 992, "db_id": "computer_student", "grading_method": "set", "question": "Please list the IDs of the advisors of the students who are in the 5th year of their program.", "evidence": "IDs of the advisors refers to p_id_dummy; in the 5th year of their program refers to yearsInProgram = 'Year_5'", "SQL": "SELECT T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_5'"} {"question_id": 994, "db_id": "computer_student", "grading_method": "set", "question": "Among the courses that are basic or medium undergraduate courses, how many of them are taught by a faculty member?", "evidence": "courses that are basic or medium undergraduate courses refers to courseLevel = 'Level_300'; faculty member refers to hasPosition ! = 0", "SQL": "SELECT COUNT(DISTINCT c.`course_id`)\nFROM `course` AS c\nJOIN `taughtBy` AS t ON c.`course_id` = t.`course_id`\nJOIN `person` AS p ON t.`p_id` = p.`p_id`\nWHERE c.`courseLevel` = 'Level_300'\n AND p.`hasPosition` <> '0';"} {"question_id": 996, "db_id": "computer_student", "grading_method": "set", "question": "What is the level of the course with the most teachers?", "evidence": "a course's number of teachers refers to COUNT(DISTINCT taughtBy.p_id) grouped by taughtBy.course_id; the course with the most teachers refers to the course whose count equals the greatest such count; return course.courseLevel for every course at that maximum", "SQL": "SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING COUNT(DISTINCT T2.p_id) = ( \nSELECT COUNT(DISTINCT T4.p_id) FROM course AS T3 INNER JOIN taughtBy AS T4 ON T3.course_id = T4.course_id GROUP BY T4.course_id ORDER BY COUNT(DISTINCT T4.p_id) DESC LIMIT 1)"} {"question_id": 1000, "db_id": "computer_student", "grading_method": "set", "question": "Among professors who teach at least one course, what is the average number of courses taught per professor?", "evidence": "professors refers to person.professor = 1; courses taught refers to taughtBy assignments; average number of courses taught per professor = DIVIDE(COUNT(taughtBy assignments), COUNT(DISTINCT professors with at least one assignment))", "SQL": "SELECT CAST(COUNT(tb.course_id) AS REAL) / COUNT(DISTINCT p.p_id) AS avg_courses_per_prof\nFROM person AS p\nINNER JOIN taughtBy AS tb ON p.p_id = tb.p_id\nWHERE p.professor = 1 AND tb.course_id IS NOT NULL;"} {"question_id": 1006, "db_id": "computer_student", "grading_method": "set", "question": "For the student with the most advisors, what year of the program are they in, and what is their qualification phase?", "evidence": "the student refers to the advisee advisedBy.p_id and their advisors to that p_id's advisedBy rows; the student with the most advisors refers to the p_id with the largest COUNT of those rows, taking a single one; return that person's yearsInProgram (Year_N form, 0 for no program) and inPhase (0 means not in that phase)", "SQL": "SELECT T2.yearsInProgram, T2.inPhase FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(*) DESC LIMIT 1"} {"question_id": 1007, "db_id": "computer_student", "grading_method": "set", "question": "List down the advised student IDs and IDs of employing professor in faculty.", "evidence": "advised student IDs refers to person.p_id; IDs of employing professor in faculty refers to p_id_dummy and hasPosition = 'Faculty_eme'", "SQL": "SELECT T1.p_id, T2.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE hasPosition = 'Faculty_eme'"} {"question_id": 1010, "db_id": "computer_student", "grading_method": "set", "question": "Which faculty professors taught the course with ID 104? Give their person IDs and the course level.", "evidence": "person.p_id identifies the person; person.professor = 1 denotes a professor. person.hasPosition records faculty membership, with 0 denoting a nonmember. course.courseLevel records the course level.", "SQL": "SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T3.course_id = 104 AND T1.hasPosition <> 0 AND T1.professor = 1;"} {"question_id": 1018, "db_id": "computer_student", "grading_method": "set", "question": "Among professors who have taught at least one course, which have taught the fewest courses? List their IDs.", "evidence": "professors refers to person.professor = 1; courses taught refers to the number of taughtBy rows per taughtBy.p_id; the fewest courses refers to the MIN of those per-professor counts; list the p_id of every professor whose count equals that minimum, ties included", "SQL": "SELECT t.`p_id` FROM `taughtBy` t JOIN `person` p ON p.`p_id` = t.`p_id` WHERE p.`professor` = 1 GROUP BY t.`p_id` HAVING COUNT(*) = (SELECT MIN(cnt) FROM (SELECT COUNT(*) AS cnt FROM `taughtBy` t2 JOIN `person` p2 ON p2.`p_id` = t2.`p_id` WHERE p2.`professor` = 1 GROUP BY t2.`p_id`))"} {"question_id": 1020, "db_id": "computer_student", "grading_method": "set", "question": "Which professors teach the highest number of professional or master/graduate courses?", "evidence": "professor refers to taughtBy.p_id; highest number of professional or master/graduate courses refers to max(count(taughtBy.course_id)) where courseLevel = 'Level_500'", "SQL": "SELECT tb.p_id FROM taughtBy tb JOIN course c ON c.course_id = tb.course_id WHERE c.courseLevel = 'Level_500' GROUP BY tb.p_id HAVING COUNT(*) = ( SELECT MAX(cnt) FROM ( SELECT COUNT(*) AS cnt FROM taughtBy tb2 JOIN course c2 ON c2.course_id = tb2.course_id WHERE c2.courseLevel = 'Level_500' GROUP BY tb2.p_id))"} {"question_id": 1023, "db_id": "computer_student", "grading_method": "set", "question": "How many advisors are in charge of advising at least one 1st-year student?", "evidence": "advisors refers to p_id_dummy; students in 1st year refers to student = 1 and yearsInProgram = 'Year_1'", "SQL": "SELECT COUNT(DISTINCT T1.`p_id_dummy`)\nFROM `advisedBy` AS T1\nJOIN `person` AS T2 ON T1.`p_id` = T2.`p_id`\nWHERE T2.`student` = 1\n AND T2.`yearsInProgram` = 'Year_1';"} {"question_id": 1024, "db_id": "computer_student", "grading_method": "set", "question": "How many professors teach no more than two high-level undergraduate courses, including professors who teach none?", "evidence": "professors refers to person.professor = 1; high-level undergraduate courses refers to course.courseLevel = 'Level_400'; a professor's teaching assignments are that professor's taughtBy records; teach no more than two refers to COUNT(DISTINCT Level_400 courses in those assignments) <= 2, which is 0 for a professor with none; the answer is the COUNT of professors that satisfy it", "SQL": "SELECT COUNT(*)\nFROM (\n SELECT p.`p_id`\n FROM `person` AS p\n LEFT JOIN `taughtBy` AS tb ON p.`p_id` = tb.`p_id`\n LEFT JOIN `course` AS c \n ON tb.`course_id` = c.`course_id` \n AND c.`courseLevel` = 'Level_400'\n WHERE p.`professor` = 1\n GROUP BY p.`p_id`\n HAVING COUNT(DISTINCT c.`course_id`) <= 2\n);"} {"question_id": 1025, "db_id": "computer_student", "grading_method": "set", "question": "Among faculty employee professors, how many teach high-level or harder undergraduate courses?", "evidence": "Faculty employee professors use person.hasPosition = 'Faculty_eme' and person.professor = 1. High-level undergraduate courses use course.courseLevel = 'Level_400'. Professor identifier is person.p_id.", "SQL": "SELECT COUNT(DISTINCT T1.`p_id`) AS num_professors\nFROM `person` AS T1\nJOIN `taughtBy` AS T2 ON T1.`p_id` = T2.`p_id`\nJOIN `course` AS T3 ON T3.`course_id` = T2.`course_id`\nWHERE T1.`hasPosition` = 'Faculty_eme'\n AND T1.`professor` = 1\n AND T3.`courseLevel` = 'Level_400';"} {"question_id": 1028, "db_id": "computer_student", "grading_method": "set", "question": "How many professors teach basic or medium-level undergraduate courses?", "evidence": "person.professor = 1 denotes professors. course.courseLevel = 'Level_300' denotes basic or medium-level undergraduate courses.", "SQL": "SELECT COUNT(DISTINCT tb.`p_id`)\nFROM `taughtBy` AS tb\nJOIN `course` AS c ON c.`course_id` = tb.`course_id`\nJOIN `person` AS p ON p.`p_id` = tb.`p_id`\nWHERE c.`courseLevel` = 'Level_300'\n AND p.`professor` = 1;"} {"question_id": 1029, "db_id": "computer_student", "grading_method": "set", "question": "Which year in the program is most common among students who are advised by an advisor?", "evidence": "students refers to person.student = 1; advised by an advisor refers to person.p_id appearing in advisedBy.p_id; most common year in the program refers to person.yearsInProgram with the greatest COUNT of such students, returning only that single top value", "SQL": "SELECT `yearsInProgram`\nFROM `person`\nWHERE `student` = 1\n AND `p_id` IN (SELECT `p_id` FROM `advisedBy`)\nGROUP BY `yearsInProgram`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 1031, "db_id": "computer_student", "grading_method": "set", "question": "Among professors who taught at least one professional, master’s, or graduate course, what was the average number of such courses taught per professor?", "evidence": "professional or master/graduate courses refers to courseLevel = 'Level_500'; average number = divide(count(taughtBy.course_id), count(taughtBy.p_id))", "SQL": "SELECT CAST(COUNT(*) AS REAL) / COUNT(DISTINCT p.`p_id`) AS avg_level500_per_prof\nFROM taughtBy t\nJOIN course c ON c.`course_id` = t.`course_id`\nJOIN person p ON p.`p_id` = t.`p_id`\nWHERE c.`courseLevel` = 'Level_500'\n AND p.`professor` = 1;"} {"question_id": 1036, "db_id": "computer_student", "grading_method": "set", "question": "Which professor taught the most courses and what is the position of this person in the university?", "evidence": "professor refers to taughtBy.p_id; most courses refers to max(taughtBy.p_id); position refers to hasPosition", "SQL": "SELECT T1.p_id, T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1"} {"question_id": 1049, "db_id": "talkingdata", "grading_method": "set", "question": "How many female users use ZenFone 5 devices?", "evidence": "female refers to gender = 'F'; ZenFone 5 refers to device_model = 'ZenFone 5';", "SQL": "SELECT COUNT(DISTINCT T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.gender = 'F' AND T2.device_model = 'ZenFone 5';"} {"question_id": 1050, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age of the oldest active user that participated in the event held on 5/2/2016 at coordinates 120, 32?", "evidence": "active participation refers to app_events.is_active = 1; the event held on 5/2/2016 at coordinates 120, 32 refers to the events row for 2016-05-02 with events.longitude = 120 and events.latitude = 32; the age of the oldest active user who participated in that event refers to MAX(gender_age.age), returning that one age", "SQL": "SELECT T3.age FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE T1.is_active = 1 AND T2.longitude = 120 AND T2.latitude = 32 AND SUBSTR(T2.timestamp, 1, 10) = '2016-05-02' ORDER BY T3.age DESC LIMIT 1"} {"question_id": 1053, "db_id": "talkingdata", "grading_method": "set", "question": "What is the gender of the majority of Vivo phone users? Do not count devices with missing gender information.", "evidence": "majority of Vivo phone users refers to MAX(COUNT(phone_brand = 'vivo'));", "SQL": "SELECT T.gender FROM ( SELECT T2.gender, COUNT(T2.gender) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo' GROUP BY T2.gender ) AS T ORDER BY T.num DESC LIMIT 1"} {"question_id": 1055, "db_id": "talkingdata", "grading_method": "set", "question": "How many users belong to the MOBA category?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'MOBA'"} {"question_id": 1057, "db_id": "talkingdata", "grading_method": "set", "question": "What were the locations of the events on 8th May, 2016?", "evidence": "location = longitude, latitude; on 8th May, 2016 refers to `timestamp` LIKE '2016-05-08%';", "SQL": "SELECT longitude, latitude FROM `events` WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-08'"} {"question_id": 1061, "db_id": "talkingdata", "grading_method": "set", "question": "What is the ratio of male users to female users in the 27–28 age group? Round your answer to 3 decimal places.", "evidence": "male users in the 27-28 age group refers to gender_age.gender = 'M' AND `group` = 'M27-28'; female users refers to gender = 'F' AND `group` = 'F27-28'; ratio = DIVIDE(COUNT(male-user rows in gender_age), COUNT(female-user rows in gender_age)), rounded to 3 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT SUM(IIF(gender = 'M' AND `group` = 'M27-28', 1.0, 0.0)) / SUM(IIF(gender = 'F' AND `group` = 'F27-28', 1.0, 0.0)) AS r FROM gender_age\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 1063, "db_id": "talkingdata", "grading_method": "set", "question": "Describe the phone brands and models of the users who participated in events on 5th May, 2016 at the coordinates of (112,36).", "evidence": "models refers to device_model; on 5th May, 2016 refers to timestamp LIKE '2016-05-05%'; coordinates of (112,36) refers to longitude = 112 AND latitude = 36;", "SQL": "SELECT DISTINCT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.timestamp LIKE '2016-05-05%' AND T1.longitude = 112 AND T1.latitude = 36"} {"question_id": 1064, "db_id": "talkingdata", "grading_method": "set", "question": "Provide the app users IDs and time for the event ID of 82.", "evidence": "app user IDs refers to app_id; time refers to timestamp;", "SQL": "SELECT T1.app_id, T2.timestamp FROM app_events AS T1 INNER JOIN events AS T2 ON T2.event_id = T1.event_id WHERE T2.event_id = 82"} {"question_id": 1065, "db_id": "talkingdata", "grading_method": "set", "question": "What are the gender and age of the user associated with event ID 15251?", "evidence": "", "SQL": "SELECT T1.gender, T1.age FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.event_id = 15251"} {"question_id": 1067, "db_id": "talkingdata", "grading_method": "set", "question": "Describe the ages, genders and numbers of events participated by the users at coordinates of (-102,38).", "evidence": "coordinates of (-102,38) refers to longitude = -102, latitude = 38;", "SQL": "SELECT ga.age,\n ga.gender,\n COUNT(e.event_id) AS num_events\nFROM gender_age AS ga\nJOIN events AS e\n ON e.`device_id` = ga.`device_id`\nWHERE e.`longitude` = -102\n AND e.`latitude` = 38\nGROUP BY ga.`device_id`;"} {"question_id": 1068, "db_id": "talkingdata", "grading_method": "set", "question": "Provide the phone brands and models of the users who were at the coordinates of (80,44).", "evidence": "models refers to device_model; coordinates of (80,44) refers to longitude = 80 AND latitude = 44;", "SQL": "SELECT DISTINCT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.longitude = 80 AND T2.latitude = 44"} {"question_id": 1076, "db_id": "talkingdata", "grading_method": "set", "question": "How many events in total have happened on the devices in 2016?", "evidence": "in 2016 refers to `timestamp` LIKE '2016%';", "SQL": "SELECT COUNT(event_id) FROM `events` WHERE SUBSTR(`timestamp`, 1, 4) = '2016'"} {"question_id": 1079, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age of the oldest device user?", "evidence": "oldest device user refers to MAX(age);", "SQL": "SELECT MAX(age) FROM gender_age"} {"question_id": 1091, "db_id": "talkingdata", "grading_method": "set", "question": "Among the devices with event no.4 happening, how many of them are vivo devices?", "evidence": "event no. refers to event_id; event_id = 4; vivo devices refers to phone_brand = 'vivo';", "SQL": "SELECT COUNT(DISTINCT T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo' AND T2.event_id = 4"} {"question_id": 1098, "db_id": "talkingdata", "grading_method": "set", "question": "What percentage of vivo devices belong to users in the M23-26 demographic group? Round your answer to 4 decimal places.", "evidence": "vivo devices refers to phone_brand = 'vivo' in phone_brand_device_model2, one count per record; M23-26 group refers to gender_age.\"group\" = 'M23-26' matched on device_id, records with no demographic match staying in the denominator; percentage = DIVIDE(SUM(CASE WHEN \"group\" = 'M23-26' THEN 1 ELSE 0 END), COUNT(*)) * 100, rounded to 4 decimals", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN g.`group` = 'M23-26' THEN 1 ELSE 0 END) / COUNT(*) FROM phone_brand_device_model2 p LEFT JOIN gender_age g ON g.device_id=p.device_id WHERE p.phone_brand='vivo'\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 1101, "db_id": "talkingdata", "grading_method": "set", "question": "How many female users belong to the age group of 27 to 28?", "evidence": "gender_age records user demographics. gender_age.gender = 'F' denotes female users; gender_age.\"group\" = 'F27-28' denotes the female 27–28 age group.", "SQL": "SELECT COUNT(device_id) FROM gender_age WHERE `group` = 'F27-28' AND gender = 'F'"} {"question_id": 1102, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age of the oldest male user of the app?", "evidence": "oldest user refers to MAX(age); male refers to gender = 'M';", "SQL": "SELECT MAX(age) FROM (SELECT age, gender FROM gender_age UNION SELECT age, gender FROM gender_age_train) WHERE gender = 'M'"} {"question_id": 1104, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age of the youngest female user of the app?", "evidence": "youngest user refers to MIN(age); female refers to gender = 'F';", "SQL": "SELECT MIN(age) FROM gender_age WHERE gender = 'F'"} {"question_id": 1105, "db_id": "talkingdata", "grading_method": "set", "question": "How many distinct phone models are recorded for VIVO?", "evidence": "phone_brand_device_model2.phone_brand uses 'vivo'. device_model identifies the model; multiple device records can share a model.", "SQL": "SELECT COUNT(DISTINCT device_model)\nFROM phone_brand_device_model2\nWHERE phone_brand = 'vivo';"} {"question_id": 1112, "db_id": "talkingdata", "grading_method": "set", "question": "What is the brand of the oldest user's device?", "evidence": "brand of the device refers to phone_brand; oldest user refers to MAX(age);", "SQL": "SELECT DISTINCT `phone_brand` FROM `phone_brand_device_model2` WHERE `device_id` IN (SELECT `device_id` FROM `gender_age` WHERE `age` = (SELECT MAX(`age`) FROM `gender_age`));"} {"question_id": 1116, "db_id": "talkingdata", "grading_method": "set", "question": "List 5 device models that are commonly used by female users.", "evidence": "device models that are commonly used refers to MAX(COUNT(device_model)); female refers to gender = 'F';", "SQL": "SELECT T.device_model FROM ( SELECT T2.device_model, COUNT(*) AS num FROM (SELECT device_id, gender FROM gender_age UNION SELECT device_id, gender FROM gender_age_train) AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 5"} {"question_id": 1132, "db_id": "talkingdata", "grading_method": "set", "question": "Which categories do the app id No.894384172610331350 belong to?", "evidence": "", "SQL": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 894384172610331350"} {"question_id": 1133, "db_id": "talkingdata", "grading_method": "set", "question": "For the event which happened at 14:09:49 on 2016/5/6, in the location coordinate(116, 40), how many apps were active?", "evidence": "at 14:09:49 on 2016/5/6 refers to timestamp = '2016-05-06 14:09:49.0'; location coordinate(116, 40) refers to longitude = '116' AND latitude = '40'; active refers to is_active = '1';", "SQL": "SELECT COUNT(DISTINCT T1.app_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE T2.timestamp = '2016-05-06 14:09:49.0' AND T1.is_active = '1' AND T2.longitude = '116' AND T2.latitude = '40'"} {"question_id": 1135, "db_id": "talkingdata", "grading_method": "set", "question": "How many devices are of the brand vivo?", "evidence": "brand vivo refers to phone_brand = 'vivo';", "SQL": "SELECT COUNT(DISTINCT device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo'"} {"question_id": 1139, "db_id": "talkingdata", "grading_method": "set", "question": "What are the genders of the oldest device user? 'F' or 'M'", "evidence": "MAX(Age) AND gender = 'M' means that the oldest device user is male; MAX(Age) AND gender = 'F' means that the oldest device user is female;", "SQL": "SELECT gender FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age )"} {"question_id": 1142, "db_id": "talkingdata", "grading_method": "set", "question": "Please list the app IDs of all the users in the Securities category.", "evidence": "", "SQL": "SELECT DISTINCT T2.app_id FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'Securities'"} {"question_id": 1144, "db_id": "talkingdata", "grading_method": "set", "question": "Among the devices with an event occurring in 2016, how many of them are owned by a user in the M23-26 user group?", "evidence": "in 2016 refers to year(timestamp) = 2016; M23-26 user group refers to `group` = 'M23-26';", "SQL": "SELECT COUNT(DISTINCT T1.device_id) FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE STRFTIME('%Y', T2.timestamp) = '2016' AND T1.`group` = 'M23-26'"} {"question_id": 1145, "db_id": "talkingdata", "grading_method": "set", "question": "What are the brands of the devices used by the most users in the M23-26 user group?", "evidence": "brand of the device refers to phone_brand; M23-26 user group refers to `group` = 'M23-26';", "SQL": "WITH T AS ( SELECT T2.phone_brand, COUNT(T1.device_id) AS num, T2.device_id FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'M23-26' GROUP BY T2.phone_brand ) SELECT T.phone_brand FROM T WHERE T.num = ( SELECT MAX(num) FROM T );"} {"question_id": 1155, "db_id": "talkingdata", "grading_method": "set", "question": "How many events have happened on the device of the youngest female user?", "evidence": "youngest refers to MIN(age); female refers to gender = 'F';", "SQL": "SELECT COUNT(*) FROM `events` e WHERE e.`device_id` IN ( SELECT ga.`device_id` FROM `gender_age` ga WHERE ga.`gender` = 'F' AND ga.`age` = (SELECT MIN(`age`) FROM `gender_age` WHERE `gender` = 'F'));"} {"question_id": 1156, "db_id": "talkingdata", "grading_method": "set", "question": "Among the devices on which an event happened on 2016/5/1, how many of them are used by a male user?", "evidence": "events.timestamp records the event date and time; its date portion uses YYYY-MM-DD. gender_age.gender = 'M' denotes male users.", "SQL": "SELECT COUNT(DISTINCT e.device_id) FROM `events` AS e JOIN `gender_age` AS g ON e.device_id = g.device_id WHERE date(e.`timestamp`) = '2016-05-01' AND g.gender = 'M';"} {"question_id": 1157, "db_id": "talkingdata", "grading_method": "set", "question": "Which category has more app users, Securities or Finance?", "evidence": "more app users refers to SUBTRACT(IF(SUM(category = 'Securities'), SUM(category = 'Finance')) > 0,'Securities','Finance') as more;", "SQL": "SELECT CASE\n WHEN COUNT(DISTINCT CASE WHEN T2.category='Securities' THEN T1.app_id END) >\n COUNT(DISTINCT CASE WHEN T2.category='Finance' THEN T1.app_id END)\n THEN 'Securities'\n ELSE 'Finance'\n END AS category_with_more_app_users\nFROM app_labels AS T1\nJOIN label_categories AS T2 ON T1.label_id = T2.label_id\nWHERE T2.category IN ('Securities','Finance');"} {"question_id": 1162, "db_id": "talkingdata", "grading_method": "set", "question": "What is the label ID of \"Third-party card management\" category?", "evidence": "", "SQL": "SELECT label_id FROM label_categories WHERE category = 'Third-party card management'"} {"question_id": 1166, "db_id": "talkingdata", "grading_method": "set", "question": "How many events were participated by the users at longitude of \"-156\"?", "evidence": "", "SQL": "SELECT COUNT(event_id) FROM events WHERE longitude = -156"} {"question_id": 1167, "db_id": "talkingdata", "grading_method": "set", "question": "How many apps have label ID 48?", "evidence": "app_labels.app_id identifies an app; app_labels.label_id identifies its assigned label.", "SQL": "SELECT COUNT(DISTINCT app_id) FROM app_labels WHERE label_id = 48"} {"question_id": 1175, "db_id": "talkingdata", "grading_method": "set", "question": "How many OPPO users participated in events which were held around 12 AM on 1st May,2016?", "evidence": "OPPO refers to phone_brand = 'OPPO'; around 12 AM on 1st May, 2016 refers to a timestamp starting with '2016-05-01 00'", "SQL": "SELECT COUNT(DISTINCT e.device_id) AS oppo_users_midnight FROM events e JOIN phone_brand_device_model2 p ON e.device_id = p.device_id WHERE p.phone_brand = 'OPPO' AND STRFTIME('%Y-%m-%d', e.`timestamp`) = '2016-05-01' AND STRFTIME('%H', e.`timestamp`) = '00'"} {"question_id": 1180, "db_id": "talkingdata", "grading_method": "set", "question": "Which phone brand and model was used for event ID \"6701\"?", "evidence": "model refers to device_model;", "SQL": "SELECT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.event_id = 6701"} {"question_id": 1182, "db_id": "talkingdata", "grading_method": "set", "question": "List out the time of the event id 12.", "evidence": "time refers to timestamp;", "SQL": "SELECT timestamp FROM events WHERE event_id = 12"} {"question_id": 1183, "db_id": "talkingdata", "grading_method": "set", "question": "How many distinct devices were active across all recorded events?", "evidence": "app_events.app_id identifies the application, not the user; the device is the unit, reached from app_events through events.event_id to events.device_id. app_events.is_active = 1 denotes activity. A device qualifies if it is active in any recorded event.", "SQL": "SELECT COUNT(DISTINCT e.`device_id`)\nFROM `app_events` ae\nJOIN `events` e ON ae.`event_id` = e.`event_id`\nWHERE ae.`is_active` = 1"} {"question_id": 1187, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age group of users who use phone brand of vivo?", "evidence": "age group refers to group;", "SQL": "SELECT DISTINCT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo'"} {"question_id": 1192, "db_id": "talkingdata", "grading_method": "set", "question": "Mention the group of age of users who use phone brand of LG.", "evidence": "group of age refers to group;", "SQL": "SELECT DISTINCT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'LG'"} {"question_id": 1195, "db_id": "talkingdata", "grading_method": "set", "question": "Among the male users, how many users use device model of Desire 820?", "evidence": "male refers to gender = 'M';", "SQL": "SELECT COUNT(DISTINCT T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Desire 820' AND T1.gender = 'M'"} {"question_id": 1205, "db_id": "talkingdata", "grading_method": "set", "question": "Identify by ID all devices used by women aged 29 to 31.", "evidence": "gender_age and gender_age_train record device-associated demographics. device_id identifies the device and gender = 'F' denotes female.", "SQL": "SELECT device_id FROM (SELECT device_id, age, gender FROM gender_age_train UNION SELECT device_id, age, gender FROM gender_age) WHERE age BETWEEN 29 AND 31 AND gender = 'F'"} {"question_id": 1217, "db_id": "talkingdata", "grading_method": "subset,=,3", "question": "Please list the ids of any three events that happened on the 1st of May 2016 that have the same latitude of 31.", "evidence": "on the 1st of May 2016 refers to timestamp like '2016-05-01%';", "SQL": "SELECT event_id FROM events WHERE timestamp LIKE '2016-05-01%' AND latitude = 31"} {"question_id": 1220, "db_id": "talkingdata", "grading_method": "subset,=,3", "question": "Please list the ids of any three devices that are owned by female users.", "evidence": "female refers to gender = 'F';", "SQL": "SELECT device_id FROM gender_age WHERE gender = 'F'"} {"question_id": 1224, "db_id": "talkingdata", "grading_method": "set", "question": "Which gender owned more Galaxy Note 2 devices?", "evidence": "Galaxy Note 2 devices refers to phone_brand_device_model2.device_model = 'Galaxy Note 2'; gender refers to gender_age.gender, which uses 'M' for male and 'F' for female; the gender that owned more = IIF(SUBTRACT(SUM(gender = 'M'), SUM(gender = 'F')) > 0, 'M', 'F'), returning that one gender", "SQL": "SELECT IIF(SUM(IIF(T1.gender = 'M', 1, 0)) - SUM(IIF(T1.gender = 'F', 1, 0)) > 0, 'M', 'F') AS gender FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 2'"} {"question_id": 1228, "db_id": "talkingdata", "grading_method": "set", "question": "What is the age and gender of the person who uses the device number 29182687948017175 on event number 1?", "evidence": "device number refers to device_id; device_id = 29182687948017175; event number refers to event_id; and event_id = 1;", "SQL": "SELECT T1.age, T1.gender FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T1.device_id = 29182687948017175 AND T2.event_id = 1"} {"question_id": 1234, "db_id": "talkingdata", "grading_method": "set", "question": "Among apps with at least one category label, what percentage are labeled “Academic Information”?", "evidence": "apps with at least one category label refers to COUNT(DISTINCT app_labels.app_id); labeled 'Academic Information' refers to the label assignments whose label_categories.category = 'Academic Information'; percentage = DIVIDE(COUNT(DISTINCT app_id so labeled), COUNT(DISTINCT app_labels.app_id)) * 100", "SQL": "WITH selected_app_ids AS (\n SELECT DISTINCT app_id\n FROM label_categories AS T1 \n INNER JOIN app_labels AS T2 \n ON T1.label_id = T2.label_id AND T1.category = 'Academic Information'\n) SELECT (SELECT COUNT(*) FROM selected_app_ids) * 100.0 / (SELECT COUNT(DISTINCT app_id) FROM app_labels)"} {"question_id": 1235, "db_id": "talkingdata", "grading_method": "set", "question": "Among device users with recorded demographic information who had an event on May 3, 2016, what percentage were in the F27-28 group?", "evidence": "device users with recorded demographic information refers to the device users in gender_age whose gender, age and group are recorded; a device can appear in gender_age with all three left empty, and those are not recorded demographic information; had an event on May 3, 2016 refers to events.timestamp on that day, each device user once; percentage in the F27-28 group = DIVIDE(SUM(CASE WHEN gender_age.group = 'F27-28' THEN 1 ELSE 0 END), COUNT(those device users)) * 100.0", "SQL": "WITH device_on_day AS (\n SELECT DISTINCT `device_id`\n FROM `events`\n WHERE SUBSTR(`timestamp`,1,10) = '2016-05-03'\n)\nSELECT 100.0 * SUM(CASE WHEN ga.`group` = 'F27-28' THEN 1 ELSE 0 END) / COUNT(*) AS percentage_F27_28\nFROM device_on_day d\nJOIN gender_age ga ON ga.`device_id` = d.`device_id`\nWHERE ga.`group` IS NOT NULL;"} {"question_id": 1242, "db_id": "talkingdata", "grading_method": "set", "question": "List the brands and models of devices involved in events on 5/7/2016 at 6:03:22 AM.", "evidence": "phone_brand_device_model2.phone_brand and device_model record the brand and model. events.timestamp represents the requested time as '2016-05-07 06:03:22.0'.", "SQL": "SELECT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-07 06:03:22.0'"} {"question_id": 1244, "db_id": "talkingdata", "grading_method": "set", "question": "What percentage of vivo devices have no recorded gender, age, or demographic group for their users? Round your answer to 4 decimal places.", "evidence": "vivo devices refers to phone_brand_device_model2 rows with phone_brand = 'vivo'; no demographic information refers to a vivo row with no gender_age record at all, or with gender, age and group all NULL; percentage = DIVIDE(COUNT(vivo rows with no demographic information), COUNT(vivo rows)) * 100, then ROUND to 4 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT SUM(CASE WHEN GA.`gender` IS NULL AND GA.`age` IS NULL AND GA.`group` IS NULL THEN 1 ELSE 0 END)*100.0/COUNT(*) AS percentage_no_info\nFROM `phone_brand_device_model2` P\nLEFT JOIN `gender_age` GA ON GA.`device_id` = P.`device_id`\nWHERE P.`phone_brand` = 'vivo'\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 1245, "db_id": "law_episode", "grading_method": "set", "question": "Please list all the keywords of the episode \"Refuge: Part 1\".", "evidence": "episode \"Refuge: Part 1\" refers to title = 'Refuge: Part 1'", "SQL": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Refuge: Part 1'"} {"question_id": 1250, "db_id": "law_episode", "grading_method": "set", "question": "How many votes did the episode titled \"Cherished\" get in total?", "evidence": "titled \"Cherished\" refers to title = 'Cherished'", "SQL": "SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished'"} {"question_id": 1254, "db_id": "law_episode", "grading_method": "set", "question": "Who was credited as \"technical advisor\" in the episode titled \"Cherished\"?", "evidence": "who refers to name; credited refers to credited = 'true'; as \"technical advisor\" refers to role = 'technical advisor'; titled \"Cherished\" refers to title = 'Cherished'", "SQL": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T2.credited = 'true' AND T2.role = 'technical advisor'"} {"question_id": 1262, "db_id": "law_episode", "grading_method": "set", "question": "Describe what happened in the episode of award no.296.", "evidence": "description of what happened refers to summary; award no.296 refers to award_id = '296'", "SQL": "SELECT T1.summary FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.award_id = 296"} {"question_id": 1269, "db_id": "law_episode", "grading_method": "set", "question": "How many times as many keywords does the episode \"Refuge: Part 1\" have as the episode \"Shield\"?", "evidence": "\"Refuge: Part 1\" episode refers to Episode.title = 'Refuge: Part 1'; \"Shield\" episode refers to Episode.title = 'Shield'; how many times as many keywords = DIVIDE(COUNT(Keyword rows joined to the 'Refuge: Part 1' episode), COUNT(Keyword rows joined to the 'Shield' episode)), an unscaled ratio", "SQL": "SELECT CAST(SUM(CASE WHEN T1.title = 'Refuge: Part 1' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.title = 'Shield' THEN 1 ELSE 0 END) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id"} {"question_id": 1281, "db_id": "law_episode", "grading_method": "set", "question": "Among the episodes that were aired in 1998, how many won an International Monitor Awards?", "evidence": "aired in 1998 refers to air_date like '1998%'; won refers to result = 'Winner'; International Monitor Awards refers to organization = 'International Monitor Awards'", "SQL": "SELECT COUNT(DISTINCT T1.episode_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE strftime('%Y', T1.air_date) = '1998' AND T2.organization = 'International Monitor Awards' AND T2.result = 'Winner'"} {"question_id": 1285, "db_id": "law_episode", "grading_method": "set", "question": "How many awards did the \"Agony\" win?", "evidence": "the \"Agony\" refers to title = 'Agony'; win refers to result = 'Winner'", "SQL": "SELECT COUNT(DISTINCT T2.award_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Agony' AND T2.result = 'Winner'"} {"question_id": 1287, "db_id": "law_episode", "grading_method": "set", "question": "In which organizations did Constantine Makris win the most awards?", "evidence": "win refers to result = 'Winner'; the most awards refers to max(count(award_id))", "SQL": "SELECT T2.organization FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Constantine Makris' AND T2.result = 'Winner' GROUP BY T2.organization HAVING COUNT(T2.award_id) = ( SELECT COUNT(T2.award_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Constantine Makris' AND T2.result = 'Winner' GROUP BY T2.organization ORDER BY COUNT(T2.award_id) DESC LIMIT 1 );"} {"question_id": 1293, "db_id": "law_episode", "grading_method": "set", "question": "Among people who have played a clerk role in the series, who is youngest by birth date? Include ties.", "evidence": "Clerk roles contain 'clerk' in Credit.role. Person.birthdate records date of birth; NULL indicates an unavailable birth date.", "SQL": "SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role LIKE '%clerk%' AND T2.birthdate = (SELECT MAX(T4.birthdate) FROM Credit AS T3 INNER JOIN Person AS T4 ON T3.person_id = T4.person_id WHERE T3.role LIKE '%clerk%')"} {"question_id": 1295, "db_id": "law_episode", "grading_method": "set", "question": "List the unique names of all the cast members.", "evidence": "cast member refers to category = 'Cast'", "SQL": "SELECT DISTINCT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.category = 'Cast'"} {"question_id": 1296, "db_id": "law_episode", "grading_method": "set", "question": "Who is the person who appeared the most in the series? Calculate in percentage of episodes he or she appeared.", "evidence": "who refers to name; appear the most refers to max(count(person_id)); percentage = divide(count(person_id where max(count(person_id))), count(episode)) * 100%; \"appeared\" refers to `category` = 'Cast' ", "SQL": "SELECT p.`name`, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM `Episode`) AS appearance_pct\nFROM `Credit` c\nJOIN `Person` p ON p.`person_id` = c.`person_id`\nWHERE c.category = 'Cast'\nGROUP BY p.`person_id`\nHAVING COUNT(*) = (SELECT MAX(cnt) FROM (SELECT COUNT(*) AS cnt FROM `Credit` WHERE category = 'Cast' GROUP BY `person_id`)) ;"} {"question_id": 1297, "db_id": "law_episode", "grading_method": "set", "question": "Which episodes of the Law & Order have been nominated for the Primetime Emmy Awards? List the titles of these episodes.", "evidence": "episode refers to award; the Primetime Emmy Awards refers to award_category like 'Primetime Emmy'", "SQL": "SELECT DISTINCT e.`title` FROM `Award` a JOIN `Episode` e ON a.`episode_id` = e.`episode_id` WHERE a.`award_category` = 'Primetime Emmy' AND a.`series` = 'Law and Order';"} {"question_id": 1300, "db_id": "law_episode", "grading_method": "set", "question": "What is the title of the 3 worst rated episodes?", "evidence": "worst rated refers to min(rating)", "SQL": "SELECT title FROM Episode ORDER BY rating LIMIT 3"} {"question_id": 1302, "db_id": "law_episode", "grading_method": "set", "question": "What are the names of the actors born in the USA?", "evidence": "Person.birth_country uses 'USA' for the United States; Credit.category = 'Cast' denotes acting credits.", "SQL": "SELECT DISTINCT p.name\nFROM Person AS p\nJOIN Credit AS c ON p.person_id = c.person_id\nWHERE p.birth_country = 'USA'\n AND c.category = 'Cast';"} {"question_id": 1305, "db_id": "law_episode", "grading_method": "set", "question": "How many votes did the episode titled Juvenile get?", "evidence": "the episode titled Juvenile refers to title = 'Juvenile'", "SQL": "SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Juvenile'"} {"question_id": 1313, "db_id": "law_episode", "grading_method": "set", "question": "What was the rating of the episodes that Jace Alexander worked on?", "evidence": "", "SQL": "SELECT T1.rating FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T3.name = 'Jace Alexander'"} {"question_id": 1315, "db_id": "law_episode", "grading_method": "set", "question": "What is the average recorded episode rating for episodes Jim Bracchitta worked on?", "evidence": "Jim Bracchitta refers to Person.name = 'Jim Bracchitta'; episodes he worked on refers to the DISTINCT Episode rows where Credit records his work; average recorded episode rating refers to AVG(Episode.rating) over those episodes", "SQL": "SELECT AVG(`rating`) FROM (SELECT DISTINCT e.`episode_id`, e.`rating` FROM `Episode` e JOIN `Credit` c ON c.`episode_id` = e.`episode_id` JOIN `Person` p ON p.`person_id` = c.`person_id` WHERE p.`name` = 'Jim Bracchitta');"} {"question_id": 1318, "db_id": "law_episode", "grading_method": "set", "question": "How many 6-star votes did episode 12 get? Please include the air date and rating.", "evidence": "6-star vote refers to stars = 6", "SQL": "SELECT V.votes AS six_star_votes, E.air_date, E.rating FROM `Episode` E JOIN `Vote` V ON V.episode_id = E.episode_id WHERE E.episode = 12 AND V.stars = 6;"} {"question_id": 1322, "db_id": "law_episode", "grading_method": "set", "question": "Who was the Law and Order series writer who also won the Television Silver Gavel Award at the American Bar Association Silver Gavel Awards for Media and the Arts for two consecutive years?", "evidence": "who refers to name; writer refers to role = 'writer'; won refers to result = 'Winner'; the Television refers to award = 'Television'; Silver Gavel Award refers to award_category = 'Silver Gavel Award'; the American Bar Association Silver Gavel Awards for Media and the Arts refers to organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'", "SQL": "WITH winners AS (\n SELECT person_id, year\n FROM Award\n WHERE organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'\n AND award_category = 'Silver Gavel Award'\n AND award = 'Television'\n AND series = 'Law and Order'\n AND role = 'writer'\n AND result = 'Winner'\n),\ntagged AS (\n SELECT person_id,\n year,\n LAG(year) OVER (PARTITION BY person_id ORDER BY year) AS prev_year\n FROM winners\n)\nSELECT DISTINCT Person.name\nFROM tagged\nJOIN Person ON Person.person_id = tagged.person_id\nWHERE prev_year = year - 1;"} {"question_id": 1326, "db_id": "law_episode", "grading_method": "set", "question": "Among the American casts, how many were uncredited on episode ID tt0629228?", "evidence": "American refers to birth_country = 'USA'; cast refers to category = 'Cast'; uncredited refers to credited = ''", "SQL": "SELECT COUNT(T1.person_id) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.episode_id = 'tt0629228' AND T1.category = 'Cast' AND T1.credited = 'false' AND T2.birth_country = 'USA'"} {"question_id": 1330, "db_id": "law_episode", "grading_method": "set", "question": "Among all roles on episode 2 of the series, what is the ratio of American casts?", "evidence": "American refers to birth_country = 'USA'; cast refers to category = 'Cast'; ratio = divide(count(person_id where birth_country = 'USA' and category = 'Cast' and episode = 2), count(person_id where episode = 2))", "SQL": "WITH episode_2 AS (\n SELECT DISTINCT person_id, c.category\n FROM Credit AS c\n JOIN Episode as e\n ON c.episode_id = e.episode_id\n WHERE e.episode = 2\n), american_cast_episode_2 AS (\n SELECT DISTINCT p.person_id\n FROM episode_2 e2\n JOIN Person p\n ON p.person_id = e2.person_id\n WHERE e2.category = 'Cast' AND p.birth_country = 'USA'\n) SELECT (SELECT COUNT(*) FROM american_cast_episode_2) * 1.0 / (SELECT COUNT(*) FROM episode_2)"} {"question_id": 1339, "db_id": "law_episode", "grading_method": "set", "question": "What is the difference of 10 stars votes between the first episode and the last episode?", "evidence": "the first episode refers to episode = 1; the last episode refers to episode = 24; 10 stars vote refers to stars = 10; the difference = subtract(votes where episode = 1, votes where episode = 24) where stars = 10", "SQL": "SELECT SUM(CASE WHEN T2.episode = 1 THEN T1.votes ELSE 0 END) - SUM(CASE WHEN T2.episode = 24 THEN T1.votes ELSE 0 END) FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10"} {"question_id": 1351, "db_id": "law_episode", "grading_method": "set", "question": "Which episode has the highest total number of viewer votes?", "evidence": "episode refers to title; the highest total number of viewer votes refers to max(sum(votes))", "SQL": "SELECT `title`\nFROM `Episode`\nWHERE `votes` = (SELECT MAX(votes) FROM Episode)"} {"question_id": 1358, "db_id": "law_episode", "grading_method": "subset,=,3", "question": "Please list any three episodes that were most enjoyed by the viewers.", "evidence": "episode refers to title; most enjoyed by the viewers meas that there exist a vote with stars = 10", "SQL": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10"} {"question_id": 1364, "db_id": "synthea", "grading_method": "set", "question": "For how many days was Elly Koss required to take acetaminophen?", "evidence": "how many days means julianday(STOP) - julianday(START); Acetaminophen means description LIKE 'Acetaminophen%'", "SQL": "SELECT julianday(T2.STOP) - julianday(T2.START) AS days FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'"} {"question_id": 1365, "db_id": "synthea", "grading_method": "set", "question": "List all medications prescribed to Elly Koss.", "evidence": "medications.DESCRIPTION contains the medication name or description.", "SQL": "SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss'"} {"question_id": 1374, "db_id": "synthea", "grading_method": "set", "question": "How many distinct care plans has Mrs. Norman Berge taken?", "evidence": "", "SQL": "SELECT COUNT(distinct T2.ID) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Norman' AND T1.last = 'Berge'"} {"question_id": 1377, "db_id": "synthea", "grading_method": "set", "question": "State the prevalence rate of condition no. 368581000119106.", "evidence": "condition no. 368581000119106 refers to conditions where CODE = '368581000119106';", "SQL": "SELECT DISTINCT T1.\"PREVALENCE RATE\" FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) WHERE T2.code = '368581000119106'"} {"question_id": 1378, "db_id": "synthea", "grading_method": "set", "question": "Give the procedure description of Ms. Jacquelyn Shanahan on 2009/8/9.", "evidence": "on 2009/8/9 refers to DATE = '2009-08-09';", "SQL": "SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Jacquelyn' AND T1.last = 'Shanahan' AND T2.DATE = '2009-08-09'"} {"question_id": 1392, "db_id": "synthea", "grading_method": "set", "question": "What is/are the ids of the tallest patient/s?", "evidence": "id of the tallest patient/s refers to PATIENT from observations where MAX(DESCRIPTION = 'Body Height');", "SQL": "SELECT DISTINCT `PATIENT`\nFROM `observations`\nWHERE `DESCRIPTION` = 'Body Height'\n AND `VALUE` = (SELECT MAX(`VALUE`) FROM `observations` WHERE `DESCRIPTION` = 'Body Height');"} {"question_id": 1393, "db_id": "synthea", "grading_method": "set", "question": "What are the most common conditions among female patients whose ethnicity is American?", "evidence": "patients.gender = 'F' denotes female; patients.ethnicity uses 'american'. conditions.DESCRIPTION records the condition name.", "SQL": "SELECT c.`DESCRIPTION` FROM `conditions` c JOIN `patients` p ON p.`patient` = c.`PATIENT` WHERE p.`gender` = 'F' AND p.`ethnicity` LIKE 'american' GROUP BY c.`DESCRIPTION` HAVING COUNT(DISTINCT c.`PATIENT`) = (SELECT MAX(cnt) FROM (SELECT COUNT(DISTINCT c2.`PATIENT`) AS cnt FROM `conditions` c2 JOIN `patients` p2 ON p2.`patient` = c2.`PATIENT` WHERE p2.`gender` = 'F' AND p2.`ethnicity` LIKE 'american' GROUP BY c2.`DESCRIPTION` ) AS counts );"} {"question_id": 1404, "db_id": "synthea", "grading_method": "set", "question": "Among the patients with prediabetes, how many are female?", "evidence": "patients with prediabetes refer to PATIENT from conditions where DESCRIPTION = 'Prediabetes'; female refers to gender = 'F';", "SQL": "SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.gender = 'F' AND T1.DESCRIPTION = 'Prediabetes'"} {"question_id": 1415, "db_id": "synthea", "grading_method": "set", "question": "What is the code of the prevalent disease with the highest occurrences?", "evidence": "", "SQL": "SELECT DISTINCT c.`CODE`\nFROM `all_prevalences` p\nJOIN `conditions` c\n ON lower(p.`ITEM`) = lower(c.`DESCRIPTION`)\nWHERE p.`OCCURRENCES` = (SELECT MAX(`OCCURRENCES`) FROM `all_prevalences`);"} {"question_id": 1431, "db_id": "synthea", "grading_method": "set", "question": "Among the immunizations in 2017, calculate the percentage of patients who received the Influenza seasonal injectable preservative free. Among patients who received immunizations in 2017 and received the influenza seasonal injectable preservative free, how many patients are English?", "evidence": "DIVIDE(COUNT(PATIENT when DESCRIPTION LIKE 'Influenza%seasonal%injectable%preservative%free') * 100, COUNT(PATIENT)) as percentage where strftime('%Y', 2017); English refers ethnicity = 'english';", "SQL": "WITH imm2017 AS (\n SELECT DISTINCT `PATIENT`\n FROM `immunizations`\n WHERE strftime('%Y', `DATE`) = '2017'\n),\nflu_patients AS (\n SELECT DISTINCT `PATIENT`\n FROM `immunizations`\n WHERE strftime('%Y', `DATE`) = '2017'\n AND `DESCRIPTION` LIKE 'Influenza%seasonal%injectable%preservative%free'\n)\nSELECT\n 100.0 * (SELECT COUNT(*) FROM flu_patients) / (SELECT COUNT(*) FROM imm2017) AS percentage_flu_patients,\n (SELECT COUNT(*)\n FROM flu_patients fp\n JOIN patients p ON p.patient = fp.`PATIENT`\n WHERE LOWER(p.ethnicity) = 'english') AS english_flu_patients;"} {"question_id": 1432, "db_id": "synthea", "grading_method": "set", "question": "List down the first name of patients who encountered normal pregnancy.", "evidence": "encountered normal pregnancy refers to encounters where REASONDESCRIPTION = 'Normal pregnancy';", "SQL": "SELECT DISTINCT T1.first FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'Normal pregnancy'"} {"question_id": 1434, "db_id": "synthea", "grading_method": "set", "question": "List down the first name of patients who have cystitis condition.", "evidence": "cystitis refers to conditions where DESCRIPTION = 'Cystitis';", "SQL": "SELECT DISTINCT T1.first FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Cystitis'"} {"question_id": 1449, "db_id": "synthea", "grading_method": "set", "question": "How many patients with 'allergy to eggs' have been immunized with 'Td (adult) preservative free'?", "evidence": "allergy to eggs' refers to allergies where DESCRIPTION = 'Allergy to eggs'; immunized with 'Td (adult) preservative free' refers to immunizations where DESCRIPTION = 'Td (adult) preservative free';", "SQL": "SELECT COUNT(DISTINCT T2.patient) FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN immunizations AS T3 ON T2.patient = T3.PATIENT WHERE T1.DESCRIPTION = 'Allergy to eggs' AND T3.DESCRIPTION = 'Td (adult) preservative free'"} {"question_id": 1452, "db_id": "synthea", "grading_method": "set", "question": "On what distinct dates did the billable period begin for patients with the last name Dickinson?", "evidence": "dates when the billable period begin refers to BILLABLEPERIOD;", "SQL": "SELECT DISTINCT T2.BILLABLEPERIOD FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T1.last = 'Dickinson'"} {"question_id": 1456, "db_id": "synthea", "grading_method": "set", "question": "How many patients immunized against 'monovalent rotavirus' ceased their care plan on 11/23/2013?", "evidence": "immunized against monovalent rotavirus refers to immunizations.DESCRIPTION = 'rotavirus monovalent'; ceased their care plan on 11/23/2013 refers to careplans.STOP = '2013-11-23';", "SQL": "SELECT COUNT(DISTINCT T1.patient) FROM careplans AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'rotavirus monovalent' AND T1.STOP = '2013-11-23'"} {"question_id": 1458, "db_id": "synthea", "grading_method": "set", "question": "What percentage of patients born in 'Pembroke MA US' have 'allergy to grass pollen'?", "evidence": "born in Pembroke MA US refers to patients.birthplace = 'Pembroke MA US'; allergy to grass pollen refers to allergies.DESCRIPTION = 'Allergy to grass pollen', with allergies.PATIENT identifying the patient; percentage = DIVIDE(COUNT(DISTINCT such patients having that allergy), COUNT(such patients)) * 100", "SQL": "WITH pembroke AS (\n SELECT `patient` FROM `patients` WHERE `birthplace` = 'Pembroke MA US'\n),\ngrass AS (\n SELECT DISTINCT `PATIENT` FROM `allergies` WHERE `DESCRIPTION` = 'Allergy to grass pollen'\n)\nSELECT 100.0 * (SELECT COUNT(*) FROM pembroke p JOIN grass g ON p.patient = g.PATIENT)\n / (SELECT COUNT(*) FROM pembroke) AS percentage;"} {"question_id": 1468, "db_id": "synthea", "grading_method": "set", "question": "In 2010, how many single patients took Nitrofurantoin 5 mg/ML [Furadantin] to cure cystitis?", "evidence": "in 2010 refers to substr(medications.START, 1, 4) = '2010' AND substr(medications.stop, 1, 4) = '2010'; Nitrofurantoin 5 mg/ML [Furadantin] refers to medications.DESCRIPTION = 'Nitrofurantoin 5 MG/ML [Furadantin]'; cystitis refers to medications.REASONDESCRIPTION = 'Cystitis';", "SQL": "SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.marital = 'S' AND T2.REASONDESCRIPTION = 'Cystitis' AND T2.DESCRIPTION = 'Nitrofurantoin 5 MG/ML [Furadantin]' AND strftime('%Y', T2.START) = '2010' AND strftime('%Y', T2.STOP) = '2010'"} {"question_id": 1476, "db_id": "synthea", "grading_method": "set", "question": "List out all the observation information collected for the patient named Bella Rolfson.", "evidence": "observation information refers to observations.DESCRIPTION AND observations.VALUE AND observations.UNITS;", "SQL": "SELECT T2.DESCRIPTION, T2.VALUE, T2.UNITS FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Bella' AND T1.last = 'Rolfson'"} {"question_id": 1483, "db_id": "synthea", "grading_method": "set", "question": "How many unmarried women were checked for normal pregnancy?", "evidence": "unmarried refers to marital = 'S'; women refers to gender = 'F'; normal pregnancy refers to conditions.DESCRIPTION = 'normal pregnancy';", "SQL": "SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Normal pregnancy' AND T2.gender = 'F' AND T2.marital = 'S'"} {"question_id": 1484, "db_id": "synthea", "grading_method": "set", "question": "List out all the procedures prescribed for patients who have ever had a drug overdose.", "evidence": "procedure refers to procedures.DESCRIPTION; drug overdose refers to encounters.REASONDESCRIPTION = 'Drug overdose';", "SQL": "SELECT DISTINCT T2.DESCRIPTION FROM encounters AS T1 INNER JOIN procedures AS T2 ON T1.PATIENT = T2.PATIENT WHERE T1.REASONDESCRIPTION = 'Drug overdose'"} {"question_id": 1490, "db_id": "synthea", "grading_method": "set", "question": "What drug is administered most often to treat child attention deficit disorder?", "evidence": "drug that was administered refers to medications.DESCRIPTION; child attention deficit disorder refers to medications.REASONDESCRIPTION = 'Child attention deficit disorder';", "SQL": "SELECT DESCRIPTION FROM medications WHERE REASONDESCRIPTION = 'Child attention deficit disorder' GROUP BY DESCRIPTION HAVING COUNT(*) = (\n SELECT COUNT(*) FROM medications WHERE REASONDESCRIPTION = 'Child attention deficit disorder' GROUP BY DESCRIPTION ORDER BY COUNT(*) DESC LIMIT 1)"} {"question_id": 1501, "db_id": "synthea", "grading_method": "set", "question": "How many medical encounters did Lorri Simonis have from 2010 through 2017, and what percentage of those were prenatal visits? Round the percentage to two decimal places.", "evidence": "from 2010 through 2017 refers to encounters.DATE with year BETWEEN '2010' AND '2017'; prenatal visits refers to DESCRIPTION IN ('Prenatal visit', 'Prenatal initial visit'); return both the COUNT of Lorri Simonis's medical encounters in that span and ROUND(DIVIDE(COUNT of prenatal visits, that COUNT) * 100, 2)", "SQL": "SELECT COUNT(*) AS total_encounters,\n ROUND(100.0 *\n SUM(CASE WHEN E.`DESCRIPTION` IN ('Prenatal visit',\n 'Prenatal initial visit')\n THEN 1 ELSE 0 END) / COUNT(*), 2) AS prenatal_percentage\nFROM `encounters` E\nJOIN `patients` P ON P.`patient` = E.`PATIENT`\nWHERE P.`first` = 'Lorri'\n AND P.`last` = 'Simonis'\n AND strftime('%Y', E.`DATE`) BETWEEN '2010' AND '2017';"} {"question_id": 1503, "db_id": "synthea", "grading_method": "set", "question": "What are the start dates of all the care plans of the patient whose maiden name is Adams?", "evidence": "start date of the care plan refers to careplans.START;", "SQL": "SELECT DISTINCT T1.START FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.maiden = 'Adams' GROUP BY T1.ID"} {"question_id": 1504, "db_id": "synthea", "grading_method": "set", "question": "Among the male patients, who has the earliest starting date of the care plan?", "evidence": "male patients refers to gender = 'M'; earliest starting date of the care plan refers to MIN(careplans.START);", "SQL": "SELECT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.gender = 'M' AND T1.START = (\n SELECT MIN(T3.START) FROM careplans AS T3 INNER JOIN patients AS T4 ON T3.PATIENT = T4.patient WHERE T4.gender = 'M') GROUP BY T2.patient"} {"question_id": 1512, "db_id": "synthea", "grading_method": "set", "question": "List out the unique stop date of the care plan of dead patients.", "evidence": "stop date of the care plan refers to careplans.STOP; dead patients refers to deathdate is not null;", "SQL": "SELECT DISTINCT T1.STOP FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NOT NULL AND T1.STOP IS NOT NULL"} {"question_id": 1519, "db_id": "synthea", "grading_method": "set", "question": "How many patients with viral sinusitis are there in each gender group? List the gender code (F or M) and the number of patients.", "evidence": "Viral sinusitis is recorded as conditions.DESCRIPTION = 'Viral sinusitis (disorder)'.", "SQL": "SELECT p.gender,\n COUNT(DISTINCT p.patient) AS num_patients\nFROM patients p\nJOIN conditions c ON p.patient = c.PATIENT\nWHERE c.DESCRIPTION = 'Viral sinusitis (disorder)'\nGROUP BY p.gender;"} {"question_id": 1520, "db_id": "synthea", "grading_method": "set", "question": "Provide the full names of patients who were taking Penicillin V Potassium 250 MG in 1948 or later.", "evidence": "full names = first, last; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'; in 1948 or later refers to substr(medications.START, 1, 4) > = '1948';", "SQL": "SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Penicillin V Potassium 250 MG' AND strftime('%Y', T2.START) >= '1948'"} {"question_id": 1530, "db_id": "synthea", "grading_method": "set", "question": "Among white patients, what is the average of each patient's average recorded body height?", "evidence": "body height refers to observations.DESCRIPTION = 'Body Height', with the measurement in observations.VALUE (cm); each patient's average body height refers to AVG(observations.VALUE) grouped by observations.PATIENT, over white patients only; the answer refers to AVG of those per-patient averages", "SQL": "SELECT AVG(patient_height) FROM ( SELECT AVG(o.`VALUE`) AS patient_height FROM observations o JOIN patients p ON o.`PATIENT` = p.`patient` WHERE p.`race` = 'white' AND o.`DESCRIPTION` = 'Body Height' GROUP BY o.`PATIENT`);"} {"question_id": 1538, "db_id": "synthea", "grading_method": "set", "question": "What is the average age of male patients with a recorded hypertension diagnosis, using their age at death if deceased and their age on January 1, 2030 otherwise? Round your answer to 2 decimal places.", "evidence": "male patients refers to patients.gender = 'M'; hypertension refers to having a conditions row with DESCRIPTION = 'Hypertension', counted once per patient; age refers to DIVIDE(SUBTRACT(julianday(COALESCE(deathdate, '2030-01-01')), julianday(birthdate)), 365.0); average age refers to ROUND(AVG(age), 2)", "SQL": "WITH unrounded(value) AS (\nSELECT AVG((julianday(COALESCE(p.deathdate, '2030-01-01')) - julianday(p.birthdate)) / 365.0) FROM patients p WHERE p.gender='M' AND EXISTS (SELECT 1 FROM conditions c WHERE c.PATIENT=p.patient AND c.DESCRIPTION='Hypertension')\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 1547, "db_id": "car_retails", "grading_method": "set", "question": "What was the total price of the products shipped to Rovelli Gifts Distributors Ltd. between 1/1/2003 and 12/31/2003?", "evidence": "Rovelli Gifts is the customer name; shippedDate between '2003-01-01' and '2003-12-31'; total price = MULTIPLY(quantityOrdered, priceEach);", "SQL": "SELECT SUM(od.quantityOrdered * od.priceEach) AS total_price\nFROM customers c\nJOIN orders o ON c.customerNumber = o.customerNumber\nJOIN orderdetails od ON o.orderNumber = od.orderNumber\nWHERE c.customerName = 'Rovelli Gifts'\n AND date(o.shippedDate) BETWEEN '2003-01-01' AND '2003-12-31' AND o.status = 'Shipped';"} {"question_id": 1558, "db_id": "car_retails", "grading_method": "set", "question": "How many orders placed in 2003 contained fewer than 30 units in total?", "evidence": "orders.orderDate records the order date. orderdetails.quantityOrdered records the units on an order line; orderNumber identifies the order.", "SQL": "SELECT COUNT(*) FROM ( SELECT T1.orderNumber FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE STRFTIME('%Y', T2.orderDate) = '2003' GROUP BY T1.orderNumber HAVING SUM(T1.quantityOrdered) < 30 )"} {"question_id": 1562, "db_id": "car_retails", "grading_method": "set", "question": "How many orders had expected profits greater than 100?", "evidence": "expected profit of an order refers to SUM(MULTIPLY(quantityOrdered, SUBTRACT(MSRP, buyPrice))) over that order's orderdetails rows; expected profits greater than 100 refers to that per-order total > 100; the answer is the COUNT of orders that reach it", "SQL": "SELECT COUNT(*) FROM ( SELECT `orders`.`orderNumber`, SUM(`quantityOrdered` * (`MSRP` - `buyPrice`)) AS order_profit FROM `orders` JOIN `orderdetails` USING (`orderNumber`) JOIN `products` USING (`productCode`) GROUP BY `orders`.`orderNumber` HAVING order_profit > 100) AS sub;"} {"question_id": 1566, "db_id": "car_retails", "grading_method": "set", "question": "Please calculate the total payment amount of customers who come from the USA.", "evidence": "USA is a country; total amount payment refers to SUM(amount);", "SQL": "SELECT SUM(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.country = 'USA'"} {"question_id": 1567, "db_id": "car_retails", "grading_method": "set", "question": "What are the total payments of all customers with credit limits larger than 10000 in 2003?", "evidence": "credit limits larger than 10000 refers to customers.creditLimit > 10000; in 2003 refers to payments whose paymentDate is in 2003; total payments = SUM(payments.amount) over the 2003 payments of those customers", "SQL": "SELECT SUM(amount) FROM payments WHERE STRFTIME('%Y', paymentDate) = '2003' AND customerNumber IN ( SELECT customerNumber FROM customers WHERE creditLimit > 10000 )"} {"question_id": 1568, "db_id": "car_retails", "grading_method": "set", "question": "Please list the name and phone number of the customer whose order was cancelled.", "evidence": "cancelled order refers to status = 'Cancelled';", "SQL": "SELECT T2.customerName, T2.phone FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Cancelled'"} {"question_id": 1569, "db_id": "car_retails", "grading_method": "set", "question": "How many French customers have exactly two cancelled orders?", "evidence": "French customers have customers.country = 'France'; cancelled orders have orders.status = 'Cancelled'.", "SQL": "SELECT COUNT(*) FROM ( SELECT o.`customerNumber` FROM `orders` o JOIN `customers` c ON c.`customerNumber` = o.`customerNumber` WHERE c.`country` = 'France' AND o.`status` = 'Cancelled' GROUP BY o.`customerNumber` HAVING COUNT(*) = 2 ) AS sub;"} {"question_id": 1573, "db_id": "car_retails", "grading_method": "set", "question": "What are the email addresses of employees reporting to Diane Murphy (employee number 1002) who work in San Francisco?", "evidence": "An employee’s manager is recorded in employees.reportsTo; employee email is employees.email. Office location is offices.city, and San Francisco is stored as 'San Francisco'.", "SQL": "SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1002 AND T2.city = 'San Francisco'"} {"question_id": 1575, "db_id": "car_retails", "grading_method": "set", "question": "List out the emails of Sales Manager who are working in Sydney.", "evidence": "Sales Manager is a job title; Sydney is a city;", "SQL": "SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.jobTitle LIKE '%Sales Manager%' AND T2.city = 'Sydney'"} {"question_id": 1576, "db_id": "car_retails", "grading_method": "set", "question": "How many employees who are living in Australia and have at least one customer whose credit limit is under 200000?", "evidence": "Australia is a country; creditLimit < 200000;", "SQL": "SELECT COUNT(*) AS num_employees\nFROM (\n SELECT DISTINCT e.`employeeNumber`\n FROM `employees` e\n JOIN `offices` o ON e.`officeCode` = o.`officeCode`\n JOIN `customers` c ON c.`salesRepEmployeeNumber` = e.`employeeNumber`\n WHERE o.`country` = 'Australia'\n AND c.`creditLimit` < 200000\n) sub;"} {"question_id": 1578, "db_id": "car_retails", "grading_method": "set", "question": "How many Australian customers who have credit line under 220000?", "evidence": "Australian is a nationality of country = 'Australia'; credit line refers to creditLimit; creditLimit < 220000;", "SQL": "SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Australia'"} {"question_id": 1579, "db_id": "car_retails", "grading_method": "set", "question": "List three customer numbers with the highest total payment amounts.", "evidence": "Payment amounts are stored in payments.amount; the paying customer is identified by payments.customerNumber.", "SQL": "SELECT customerNumber FROM payments GROUP BY customerNumber ORDER BY SUM(amount) DESC LIMIT 3"} {"question_id": 1582, "db_id": "car_retails", "grading_method": "set", "question": "What are the email addresses of the sales reps for the three UK customers with the highest credit limits?", "evidence": "UK customers refers to customers.country = 'UK'; sales reps refers to employees.jobTitle = 'Sales Rep'; credit limits refers to customers.creditLimit;", "SQL": "WITh customers_uk AS (SELECT T1.salesRepEmployeeNumber FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' ORDER BY T1.creditLimit DESC LIMIT 3)\nSELECT DISTINCT T2.email FROm customers_uk T1 JOIN employees T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber\n"} {"question_id": 1583, "db_id": "car_retails", "grading_method": "set", "question": "How many customers who are in Norway and have credit line under 220000?", "evidence": "Norway is a country; stored country names may carry trailing spaces, so 'Norway' and 'Norway ' denote the same country; credit line refers to creditLimit; creditLimit<220000;", "SQL": "SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND TRIM(country) = 'Norway'"} {"question_id": 1584, "db_id": "car_retails", "grading_method": "set", "question": "List the first names, last names, and email addresses of employees working in Paris.", "evidence": "employees.firstName, employees.lastName, and employees.email record the requested details; offices.city identifies the office city.", "SQL": "SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Paris'"} {"question_id": 1589, "db_id": "car_retails", "grading_method": "set", "question": "Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers?", "evidence": "motorcycle is a product line; American is a nationality of country = 'USA';", "SQL": "WITH product_num AS (\n SELECT T1.productName, SUM(T2.quantityOrdered) num \n FROM products AS T1 \n INNER JOIN orderdetails AS T2 \n ON T1.productCode = T2.productCode \n INNER JOIN orders AS T3 \n ON T2.orderNumber = T3.orderNumber \n INNER JOIN customers AS T4 \n ON T3.customerNumber = T4.customerNumber \n WHERE T1.productLine = 'Motorcycles' AND T1.productScale = '1:10' AND T4.country = 'USA' \n GROUP BY T1.productName\n) SELECT productName FROM product_num WHERE num = (SELECT MAX(num) FROM product_num)"} {"question_id": 1590, "db_id": "car_retails", "grading_method": "set", "question": "List all the checks issued by Mini Gifts Distributors Ltd. between 8/1/2003 and 8/30/2004.", "evidence": "paymentDate BETWEEN '2003-08-01' AND '2004-08-30'; Mini Gifts Distributors Ltd. Is a customer name;", "SQL": "SELECT T1.checkNumber FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate >= '2003-08-01' AND T1.paymentDate <= '2004-08-30' AND T2.customerName = 'Mini Gifts Distributors Ltd.'"} {"question_id": 1592, "db_id": "car_retails", "grading_method": "set", "question": "What is the total value of shipped vintage car orders from 2003-2004?", "evidence": "total value = SUM(MULTIPLY(quantityOrdered, priceEach)); shipped orders refers to status = 'Shipped'; vintage car is a product line; year(orderDate) between 2003 and 2004;", "SQL": "SELECT SUM(T2.priceEach * T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T3.status = 'Shipped' AND T3.orderDate BETWEEN '2003-01-01' AND '2004-12-31' AND T1.productLine = 'Vintage Cars'"} {"question_id": 1595, "db_id": "car_retails", "grading_method": "set", "question": "What was the total profit from orders placed by customers in the USA from January 6, 2003, through May 9, 2005, inclusive?", "evidence": "customers in the USA refers to customers.country = 'USA'; the period refers to orders.orderDate BETWEEN '2003-01-06' AND '2005-05-09'; total profit = SUM(MULTIPLY(SUBTRACT(orderdetails.priceEach, products.buyPrice), orderdetails.quantityOrdered)) over those orders' detail lines", "SQL": "SELECT SUM((od.priceEach - p.buyPrice) * od.quantityOrdered) AS total_actual_profit FROM orders o JOIN customers c ON o.customerNumber = c.customerNumber JOIN orderdetails od ON o.orderNumber = od.orderNumber JOIN products p ON od.productCode = p.productCode WHERE c.country = 'USA' AND o.orderDate BETWEEN '2003-01-06' AND '2005-05-09';"} {"question_id": 1596, "db_id": "car_retails", "grading_method": "set", "question": "Which sales representative made the most sales in 2005? Provide the employee number, full address, and phone number.", "evidence": "Sales representatives have employees.jobTitle = 'Sales Rep'; orders.orderDate records the order date. offices.addressLine1 and offices.addressLine2 record the office address, and offices.phone records its phone number.", "SQL": "WITH rep_sales AS (\n SELECT c.salesRepEmployeeNumber AS employeeNumber,\n SUM(od.quantityOrdered*od.priceEach) AS total_sales\n FROM orders o\n JOIN orderdetails od ON od.orderNumber = o.orderNumber\n JOIN customers c ON c.customerNumber = o.customerNumber\n JOIN employees e ON e.employeeNumber = c.salesRepEmployeeNumber\n WHERE e.jobTitle='Sales Rep' AND strftime(\"%Y\",o.orderDate)='2005'\n GROUP BY c.salesRepEmployeeNumber\n), top_sales AS (\n SELECT employeeNumber\n FROM rep_sales\n WHERE total_sales = (SELECT MAX(total_sales) FROM rep_sales)\n) SELECT e.employeeNumber, of.addressLine1, of.addressLine2, of.phone\nFROM top_sales rs\nJOIN employees e ON e.employeeNumber = rs.employeeNumber\nJOIN offices of ON of.officeCode = e.officeCode"} {"question_id": 1597, "db_id": "car_retails", "grading_method": "set", "question": "List the phone numbers of companies outside Germany whose contact person’s last name starts with M.", "evidence": "Customer phone numbers are customers.phone. A customer contact’s surname is customers.contactLastName; surnames beginning with M use 'M%'. Customer country is customers.country, and Germany is stored as 'Germany'.", "SQL": "SELECT phone FROM customers WHERE contactLastName LIKE 'M%' AND country != 'Germany'"} {"question_id": 1599, "db_id": "car_retails", "grading_method": "set", "question": "What percentage of orders both placed and shipped in 2005 corresponded to customer number 186?", "evidence": "orders both placed and shipped in 2005 refers to orders.status = 'Shipped' with orderDate and shippedDate each BETWEEN '2005-01-01' AND '2005-12-31'; percentage = DIVIDE(COUNT(those orders with customerNumber = 186), COUNT(all those orders)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN `customerNumber` = 186 THEN 1 ELSE 0 END) AS REAL) * 100.0 / COUNT(*) AS pct\nFROM `orders`\nWHERE `status` = 'Shipped'\n AND `orderDate` BETWEEN '2005-01-01' AND '2005-12-31'\n AND `shippedDate` BETWEEN '2005-01-01' AND '2005-12-31';"} {"question_id": 1606, "db_id": "car_retails", "grading_method": "set", "question": "What profit would Carousel DieCast Legends make by selling all its stock in the product line described as “The perfect holiday or anniversary gift for executives” at the suggested retail price?", "evidence": "Carousel DieCast Legends refers to products.productVendor = 'Carousel DieCast Legends'; the product line described as such refers to productlines.textDescription LIKE '%perfect holiday or anniversary gift for executives%'; profit = SUM(MULTIPLY(SUBTRACT(MSRP, buyPrice), quantityInStock))", "SQL": "SELECT SUM((T2.MSRP - T2.buyPrice) * T2.quantityInStock) FROM productlines AS T1 INNER JOIN products AS T2 ON T1.productLine = T2.productLine WHERE T2.productVendor = 'Carousel DieCast Legends' AND T1.textDescription LIKE '%perfect holiday or anniversary gift for executives%'"} {"question_id": 1607, "db_id": "car_retails", "grading_method": "set", "question": "Which Boston clients have the highest average payment amount? Give their customer numbers.", "evidence": "Boston clients refers to customers.city = 'Boston' joined to payments on customerNumber; average payment amount refers to AVG(payments.amount) grouped by customerNumber; return every customerNumber whose average equals the highest such average, including ties", "SQL": "SELECT T1.customerNumber \nFROM customers AS T1 \nINNER JOIN payments AS T2 \n ON T1.customerNumber = T2.customerNumber \nWHERE T1.city = 'Boston' \nGROUP BY T1.customerNumber \nHAVING AVG(T2.amount) = (SELECT AVG(T4.amount) \n FROM customers AS T3 \n INNER JOIN payments AS T4\n ON T3.customerNumber = T4.customerNumber \n WHERE T3.city = 'Boston' \n GROUP BY T3.customerNumber\n ORDER BY AVG(T4.amount) DESC LIMIT 1)"} {"question_id": 1608, "db_id": "car_retails", "grading_method": "set", "question": "Calculate the total quantity ordered for 18th Century Vintage Horse Carriage and the average price weighted by quantity.", "evidence": "18th Century Vintage Horse Carriage is a product name; average price weighted by quantity = SUM(quantity * priceEach) / SUM(quantity);", "SQL": "SELECT SUM(T2.quantityOrdered) , SUM(T2.quantityOrdered * T2.priceEach) / SUM(T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productName = '18th Century Vintage Horse Carriage'"} {"question_id": 1609, "db_id": "car_retails", "grading_method": "set", "question": "How many kinds of products did order No. 10252 contain?", "evidence": "Products refer to productCode;", "SQL": "SELECT COUNT(t.productCode) FROM orderdetails t WHERE t.orderNumber = '10252'"} {"question_id": 1615, "db_id": "car_retails", "grading_method": "set", "question": "What was the contact name for the check \"NR157385\"?", "evidence": "Contact name refers to contactFirstName and contactLastName", "SQL": "SELECT t2.contactFirstName, t2.contactLastName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'NR157385'"} {"question_id": 1618, "db_id": "car_retails", "grading_method": "set", "question": "What is the text description of the product line for product S18_2949?", "evidence": "The product identifier is products.productCode; product-line descriptions are productlines.textDescription, linked through productLine. Product S18_2949 is stored as 'S18_2949'.", "SQL": "SELECT t1.textDescription FROM productlines AS t1 INNER JOIN products AS t2 ON t1.productLine = t2.productLine WHERE t2.productCode = 'S18_2949'"} {"question_id": 1620, "db_id": "car_retails", "grading_method": "set", "question": "How many French customers does Gerard Hernandez take care of?", "evidence": "customers.salesRepEmployeeNumber records the employee assigned to a customer.", "SQL": "SELECT COUNT(t1.customerNumber) FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.country = 'France' AND t2.firstName = 'Gerard' AND t2.lastName = 'Hernandez'"} {"question_id": 1622, "db_id": "car_retails", "grading_method": "set", "question": "For the product No. S18_3482 in the Order No.10108, how much discount did the customer have?", "evidence": "discount refers to DIVIDE(SUBTRACT(MSRP, priceEach), MSRP); product No. S18_3482 refers to productCode = 'S18_3482'", "SQL": "SELECT (t1.MSRP - t2.priceEach) / t1.MSRP FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productCode = 'S18_3482' AND t2.orderNumber = '10108'"} {"question_id": 1624, "db_id": "car_retails", "grading_method": "set", "question": "What's the email of the President of the company?", "evidence": "President refers to the jobTitle;", "SQL": "SELECT t.email FROM employees t WHERE t.jobTitle = 'President'"} {"question_id": 1625, "db_id": "car_retails", "grading_method": "set", "question": "Who is the sales representative for 'Muscle Machine Inc'? Give the employee’s first and last names.", "evidence": "customers.salesRepEmployeeNumber records the assigned sales representative.", "SQL": "SELECT t2.firstName, t2.lastName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc'"} {"question_id": 1626, "db_id": "car_retails", "grading_method": "set", "question": "What is the email address of the manager of Muscle Machine Inc’s sales representative?", "evidence": "'Muscle Machine Inc' is name of customer; customers.salesRepEmployeeNumber records the sales representative; employees.reportsTo identifies that employee’s direct manager. ", "SQL": "SELECT e_super.email\nFROM customers AS c\nJOIN employees AS e_rep ON c.salesRepEmployeeNumber = e_rep.employeeNumber\nJOIN employees AS e_super ON e_rep.reportsTo = e_super.employeeNumber\nWHERE c.customerName = 'Muscle Machine Inc';"} {"question_id": 1632, "db_id": "car_retails", "grading_method": "set", "question": "What is the postal code of the office where the VP of Sales works?", "evidence": "Employee job titles are employees.jobTitle; the Vice President of Sales title is stored as 'VP Sales'. An employee’s office is employees.officeCode, and office postal code is offices.postalCode.", "SQL": "SELECT t2.postalCode FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'VP Sales'"} {"question_id": 1639, "db_id": "car_retails", "grading_method": "set", "question": "List the names of customers who have an order that is still being processed.", "evidence": "An order still being processed has orders.status = 'In Process'.", "SQL": "SELECT t2.customerName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.status = 'In Process'"} {"question_id": 1640, "db_id": "car_retails", "grading_method": "set", "question": "Among all orders shipped, calculate the percentage of orders shipped at least 3 days before the required date. Round your answer to 4 decimal places.", "evidence": "orders shipped refers to status = 'Shipped'; shipped at least 3 days before the required date refers to JULIANDAY(requiredDate) - JULIANDAY(shippedDate) >= 3; percentage = DIVIDE(COUNT(shipped orders meeting that condition), COUNT(all shipped orders)) * 100, rounded to 4 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN JULIANDAY(`requiredDate`) - JULIANDAY(`shippedDate`) >= 3 THEN 1 ELSE 0 END)\n / COUNT(*) AS early_ship_pct\nFROM orders\nWHERE `status` = 'Shipped'\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 1641, "db_id": "car_retails", "grading_method": "set", "question": "Find the customer who made the highest total payment in 2005.", "evidence": "The highest payment refers to max(sum(amount)); 2005 refers to year(paymentDate);", "SQL": "SELECT t2.customerName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t1.paymentDate) = '2005' GROUP BY t2.customerNumber, t2.customerName ORDER BY SUM(t1.amount) DESC LIMIT 1"} {"question_id": 1642, "db_id": "car_retails", "grading_method": "set", "question": "Which products had the highest total quantity ordered? List their names and profit per piece.", "evidence": "Ordered quantities are orderdetails.quantityOrdered. Product names are products.productName. Profit per piece is products.MSRP minus products.buyPrice.", "SQL": "WITH top_product AS ( SELECT `productCode` FROM `orderdetails` GROUP BY `productCode` HAVING SUM(`quantityOrdered`) = (SELECT MAX(total_quantity) FROM (SELECT SUM(`quantityOrdered`) AS total_quantity FROM `orderdetails` GROUP BY `productCode`) AS subquery) ) SELECT p.`productName`, p.`MSRP` - p.`buyPrice` AS profit_margin_per_piece FROM `products` p JOIN top_product t ON p.`productCode` = t.`productCode`;"} {"question_id": 1643, "db_id": "car_retails", "grading_method": "set", "question": "What is the name of the customer that ordered the most units in a single order?", "evidence": "the size of an order refers to SUM(quantityOrdered) for that order; the most units in a single order refers to the greatest order size; return customers.customerName for the customer who placed that order", "SQL": "WITH order_totals AS (\n SELECT `orderNumber`,\n SUM(`quantityOrdered`) AS total_qty\n FROM `orderdetails`\n GROUP BY `orderNumber`\n),\nmax_order AS (\n SELECT `orderNumber`\n FROM order_totals\n ORDER BY total_qty DESC\n LIMIT 1\n)\nSELECT c.`customerName`\nFROM `orders` o\nJOIN max_order m ON o.`orderNumber` = m.`orderNumber`\nJOIN `customers` c ON c.`customerNumber` = o.`customerNumber`;"} {"question_id": 1644, "db_id": "car_retails", "grading_method": "set", "question": "List all customer names with orders that are disputed.", "evidence": "Orders that are disputed refer to status = 'Disputed'; names refers to customerName", "SQL": "SELECT DISTINCT c.`customerName`\nFROM `orders` AS o\nJOIN `customers` AS c ON o.`customerNumber` = c.`customerNumber`\nWHERE o.`status` = 'Disputed';"} {"question_id": 1645, "db_id": "car_retails", "grading_method": "set", "question": "What percentage of employees work in the Paris office?", "evidence": "the Paris office refers to offices.city = 'Paris'; employees are matched to their office on officeCode; percentage = DIVIDE(COUNT(employeeNumber where city = 'Paris'), COUNT(employeeNumber)) * 100 over all employees matched to an office", "SQL": "SELECT CAST(COUNT(CASE WHEN t1.city = 'Paris' THEN t2.employeeNumber ELSE NULL END) AS REAL) * 100 / COUNT(t2.employeeNumber) FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode"} {"question_id": 1651, "db_id": "car_retails", "grading_method": "set", "question": "How much did customer 103 pay in total?", "evidence": "Pay in total refers to SUM(amount);", "SQL": "SELECT SUM(t.amount) FROM payments t WHERE t.customerNumber = '103'"} {"question_id": 1652, "db_id": "car_retails", "grading_method": "set", "question": "What is the total price of the order 10100?", "evidence": "SUM(MULTIPLY(quantityOrdered, priceEach))", "SQL": "SELECT SUM(t.priceEach * t.quantityOrdered) FROM orderdetails t WHERE t.orderNumber = '10100'"} {"question_id": 1660, "db_id": "car_retails", "grading_method": "set", "question": "For each year, how many customer payments were below 10,000?", "evidence": "for each year refers to grouping on STRFTIME('%Y', payments.paymentDate); return that year together with the COUNT of the customer payments below 10000 in it", "SQL": "SELECT STRFTIME('%Y', t1.paymentDate), COUNT(t1.customerNumber) FROM payments AS t1 WHERE t1.amount < 10000 GROUP BY STRFTIME('%Y', t1.paymentDate)"} {"question_id": 1664, "db_id": "car_retails", "grading_method": "set", "question": "Identify the customer and country associated with check number GG31455.", "evidence": "Payment check numbers are payments.checkNumber; GG31455 is stored as 'GG31455'. Customer name and country are customers.customerName and customers.country.", "SQL": "SELECT t2.customerName, t2.country FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'GG31455'"} {"question_id": 1665, "db_id": "car_retails", "grading_method": "set", "question": "How many 2001 Ferrari Enzo cars were ordered?", "evidence": "Product names are products.productName; 2001 Ferrari Enzo is stored as '2001 Ferrari Enzo'. Ordered units are orderdetails.quantityOrdered.", "SQL": "SELECT SUM(`od`.`quantityOrdered`) AS totalOrdered FROM `orderdetails` AS `od` JOIN `products` AS `p` ON `p`.`productCode` = `od`.`productCode` WHERE `p`.`productName` = '2001 Ferrari Enzo';"} {"question_id": 1669, "db_id": "car_retails", "grading_method": "set", "question": "Calculate the total price of shipped orders belonging to Land of Toys Inc. under the classic car line of products.", "evidence": "SUM(MULTIPLY(quantityOrdered, priceEach)) where productLine = 'Classic Cars'; status = 'Shipped'; customername = 'Land of Toys Inc';", "SQL": "SELECT SUM(t3.priceEach * t3.quantityOrdered) FROM customers AS t1 INNER JOIN orders AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN orderdetails AS t3 ON t2.orderNumber = t3.orderNumber INNER JOIN products AS t4 ON t3.productCode = t4.productCode WHERE t4.productLine = 'Classic Cars' AND t1.customerName = 'Land of Toys Inc.' AND t2.status = 'Shipped'"} {"question_id": 1670, "db_id": "restaurant", "grading_method": "set", "question": "How many restaurants have review scores below 3?", "evidence": "generalinfo.review records the restaurant’s review score.", "SQL": "SELECT COUNT(id_restaurant) FROM generalinfo WHERE review < 3"} {"question_id": 1681, "db_id": "restaurant", "grading_method": "set", "question": "In which counties are there A&W Root Beer Restaurants?", "evidence": "A&W Root Beer Restaurant refers to label = 'a & w root beer'", "SQL": "SELECT DISTINCT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'a & w root beer'"} {"question_id": 1684, "db_id": "restaurant", "grading_method": "set", "question": "In which streets of the city of San Francisco are there restaurants that serve seafood?", "evidence": "street refers to street_name; seafood refers to food_type = 'seafood'", "SQL": "SELECT DISTINCT T1.`street_name` FROM `location` AS T1 JOIN `generalinfo` AS T2 ON T1.`id_restaurant` = T2.`id_restaurant` WHERE T1.`city` = 'san francisco' AND T2.`food_type` = 'seafood' AND T1.`street_name` IS NOT NULL;"} {"question_id": 1692, "db_id": "restaurant", "grading_method": "set", "question": "Which restaurant on the street Alameda de las Pulgas in the city of Menlo Park is the worst rated?", "evidence": "restaurant refers to label; street Alameda de las Pulgas refers to street_name = 'alameda de las pulgas'; the worst rated refers to min(review)", "SQL": "SELECT T2.label \nFROM location AS T1 \nINNER JOIN generalinfo AS T2 \nON T1.id_restaurant = T2.id_restaurant \nWHERE T1.street_name = 'alameda de las pulgas' AND T2.city = 'menlo park' \nAND review = (SELECT MIN(review) \n FROM location AS T3 \n INNER JOIN generalinfo AS T4 \n ON T4.id_restaurant = T3.id_restaurant \n WHERE T3.street_name = 'alameda de las pulgas' AND T4.city = 'menlo park')"} {"question_id": 1697, "db_id": "restaurant", "grading_method": "set", "question": "Calculate the average rating of reviews for restaurants in Santa Cruz County.", "evidence": "average rating = divide(sum(review where county = 'santa cruz county'), count(id_restaurant where county = 'santa cruz county'))", "SQL": "SELECT AVG(T2.review) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.county = 'santa cruz county'"} {"question_id": 1710, "db_id": "restaurant", "grading_method": "set", "question": "What are the restaurants that are located at \"19th St. Oakland\"?", "evidence": "restaurant refers to label; \"19th St. Oakland\" refers to street_name = '19th st' AND city = 'oakland'", "SQL": "SELECT T1.label FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'oakland' AND T2.street_name = '19th st'"} {"question_id": 1712, "db_id": "restaurant", "grading_method": "subset,=,3", "question": "Please name any three restaurants that have an unidentified region.", "evidence": "restaurant name refers to label; unidentified region refers to region = 'unknown'", "SQL": "SELECT T2.label FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant INNER JOIN geographic AS T3 ON T2.city = T3.city WHERE T3.region = 'unknown'"} {"question_id": 1713, "db_id": "restaurant", "grading_method": "set", "question": "What is the name of the Chinese restaurant that can be found at 104 San Tomas Aquino Road, Campbell?", "evidence": "restaurant name refers to label; Chinese restaurant refers to food_type = 'chinese'; 104 San Tomas Aquino Road Campbell refers to street_num = 104 AND street_name LIKE '%san tomas aquino rd%' AND city = 'campbell'", "SQL": "SELECT T1.label FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.street_num = 104 AND T1.city = 'campbell' AND T2.street_name LIKE '%san tomas aquino rd%' AND T1.food_type = 'chinese';"} {"question_id": 1714, "db_id": "restaurant", "grading_method": "set", "question": "How many Thai restaurants can be found in San Pablo Ave, Albany?", "evidence": "Thai restaurant refers to food_type = 'thai'; San Pablo Ave Albany refers to street_name = 'san pablo ave' AND T1.city = 'albany'", "SQL": "SELECT COUNT(T1.id_restaurant) FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.food_type = 'thai' AND T1.city = 'albany' AND T2.street_name = 'san pablo ave'"} {"question_id": 1719, "db_id": "restaurant", "grading_method": "set", "question": "What is the percentage of restaurants in the Bay Area region that scored over 4 for the review rating?", "evidence": "scored over 4 refers to review > 4; percentage = divide(count(id_restaurant where region = 'bay area' and review > 4), count(id_restaurant where region = 'Bay Area')) * 100%", "SQL": "SELECT CAST(SUM(IIF(T2.review > 4, 1, 0)) AS REAL) * 100 / COUNT(T2.id_restaurant) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.region = 'bay area'"} {"question_id": 1721, "db_id": "restaurant", "grading_method": "set", "question": "How many restaurants have more than 4 star reviews?", "evidence": "more than 4 star review refers to review > 4", "SQL": "SELECT COUNT(id_restaurant) AS cnt FROM generalinfo WHERE review > 4"} {"question_id": 1733, "db_id": "restaurant", "grading_method": "set", "question": "Which street in San Francisco has the most burger restaurants?", "evidence": "street refers to street_name; San Francisco refers to city = 'san francisco'; burger restaurant refers to food_type = 'burgers'; the most burger restaurants refers to max(count(street_name where food_type = 'burgers' and city = 'san francisco'))", "SQL": "WITH street_num AS (\n SELECT T2.street_name, COUNT(*) num\n FROM generalinfo AS T1 \n INNER JOIN location AS T2 \n ON T1.id_restaurant = T2.id_restaurant \n WHERE T1.city = 'san francisco' AND T1.food_type = 'burgers' \n GROUP BY T2.street_name \n) SELECT street_name FROM street_num WHERE num = (SELECT MAX(num) FROM street_num)"} {"question_id": 1735, "db_id": "restaurant", "grading_method": "set", "question": "What is the county of the Sankee restaurant?", "evidence": "Sankee restaurant refers to label = 'sankee'", "SQL": "SELECT DISTINCT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'sankee'"} {"question_id": 1738, "db_id": "restaurant", "grading_method": "set", "question": "Among restaurants with a recorded location, what percentage have a location in the Bay Area?", "evidence": "restaurants with a recorded location refers to COUNT(DISTINCT location.id_restaurant), including cities with no geographic row; a location in the Bay Area refers to geographic.region = 'bay area' matched on location.city; percentage = DIVIDE(COUNT(DISTINCT id_restaurant in the Bay Area), COUNT(DISTINCT id_restaurant)) * 100", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN g.region='bay area' THEN l.id_restaurant END) / COUNT(DISTINCT l.id_restaurant)\nFROM location AS l LEFT JOIN geographic AS g ON g.city=l.city;"} {"question_id": 1740, "db_id": "restaurant", "grading_method": "set", "question": "List street names in San Francisco city.", "evidence": "", "SQL": "SELECT street_name FROM location WHERE city = 'san francisco'"} {"question_id": 1741, "db_id": "restaurant", "grading_method": "set", "question": "List restaurant ids located in Danville city.", "evidence": "", "SQL": "SELECT id_restaurant FROM location WHERE city LIKE 'Danville'"} {"question_id": 1748, "db_id": "restaurant", "grading_method": "set", "question": "Which county has the most restaurants with Italian food?", "evidence": "Italian food refers to food_type = 'italian'", "SQL": "WITH county_num AS (\n SELECT T2.county, COUNT(DISTINCT id_restaurant) num \n FROM generalinfo AS T1 \n INNER JOIN geographic AS T2 \n ON T1.city = T2.city \n WHERE T1.food_type = 'italian' \n GROUP BY T2.county\n) SELECT county FROM county_num WHERE num = (SELECT MAX(num) FROM county_num)"} {"question_id": 1751, "db_id": "restaurant", "grading_method": "set", "question": "List down the cities with unknown county.", "evidence": "unknown county refers to county = 'unknown'", "SQL": "SELECT city FROM geographic WHERE county = 'unknown'"} {"question_id": 1763, "db_id": "restaurant", "grading_method": "set", "question": "Among all asian restaurants in N. Milpitas Blvd., Milpitas, how many of them have restaurant ID greater than 385?", "evidence": "asian restaurant refers to food_type = 'asian'; N. Milpitas Blvd. refers to street_name = 'n milpitas blvd'; Milpitas refers to city = 'milpitas'; restaurant ID greater than 385 refers to id_restaurant > 385", "SQL": "SELECT COUNT(T1.id_restaurant) AS num FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.city = 'milpitas' AND T2.food_type = 'asian' AND T1.street_name = 'n milpitas blvd' AND T1.id_restaurant > 385"} {"question_id": 1766, "db_id": "restaurant", "grading_method": "set", "question": "List the food type of the restaurant located in 22779 6th St., Hayward City.", "evidence": "22779 refers to street_num = 22779; 6th St. refers to street_name = '6th st'", "SQL": "SELECT T2.food_type FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.street_num = 22779 AND T1.street_name = '6th st' AND T2.city = 'hayward'"} {"question_id": 1767, "db_id": "restaurant", "grading_method": "set", "question": "How many American restaurants are located in Front, San Francisco?", "evidence": "American restaurant refers to food_type = 'american'; Front refers to street_name = 'front'; San Francisco refers to city = 'san francisco'", "SQL": "SELECT COUNT(*)\nFROM `location` AS l\nJOIN `generalinfo` AS g ON l.`id_restaurant` = g.`id_restaurant`\nWHERE l.`city` = 'san francisco'\n AND l.`street_name` = 'front'\n AND g.`food_type` = 'american';"} {"question_id": 1768, "db_id": "restaurant", "grading_method": "set", "question": "Among American restaurants with street numbers greater than 2000, list the restaurant IDs whose review is greater than 70% of the average review for that same group.", "evidence": "American refers to generalinfo.food_type = 'american'; street numbers greater than 2000 refers to location.street_num > 2000; the average review for that same group refers to AVG(generalinfo.review) over those same restaurants; list the restaurant IDs whose generalinfo.review > MULTIPLY(0.7, that average)", "SQL": "WITH avg_rev AS (SELECT AVG(g.`review`) AS avg_review FROM `generalinfo` g JOIN `location` l ON g.`id_restaurant` = l.`id_restaurant` WHERE g.`food_type` = 'american' AND l.`street_num` > 2000 ) SELECT g.`id_restaurant` FROM `generalinfo` g JOIN `location` l ON g.`id_restaurant` = l.`id_restaurant` CROSS JOIN avg_rev WHERE g.`food_type` = 'american' AND l.`street_num` > 2000 AND g.`review` > 0.7 * avg_rev.avg_review"} {"question_id": 1770, "db_id": "restaurant", "grading_method": "set", "question": "What is the name of the most popular restaurant serving Asian foods in San Francisco?", "evidence": "the most popular refers to max(review); Asian food refers to food_type = 'asian'; San Francisco refers to city = 'san francisco'", "SQL": "SELECT label FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' AND review = ( SELECT MAX(review) FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' )"} {"question_id": 1775, "db_id": "restaurant", "grading_method": "set", "question": "In which region can you find the top 4 most popular restaurants?", "evidence": "the top 4 most popular restaurant refers to top 4 max(review)", "SQL": "SELECT DISTINCT region FROM (SELECT T2.region FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city ORDER BY T1.review DESC LIMIT 4)"} {"question_id": 1780, "db_id": "restaurant", "grading_method": "set", "question": "In which regions can you find the highest number of Baskin Robbins restaurants?", "evidence": "the highest number refers to max(count(city)); Baskin Robbins restaurant refers to label = 'baskin robbins'", "SQL": "SELECT T2.region AS num FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'baskin robbins' GROUP BY T2.region HAVING COUNT(T1.city) = (SELECT MAX(region_count) FROM (SELECT COUNT(T1.city) AS region_count FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'baskin robbins' GROUP BY T2.region) AS subquery);"} {"question_id": 1799, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the name of the player who won the \"man of the match\" award in the match on 2008/4/18?", "evidence": "name of player refers to Player_Name; on 2008/4/18 refers to Match_Date = '2008-04-18'", "SQL": "SELECT T2.Player_Name FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match WHERE T1.Match_Date = '2008-04-18'"} {"question_id": 1803, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the average winning margin of all the matches SC Ganguly has played in?", "evidence": "SC Ganguly refers to Player.Player_Name = 'SC Ganguly'; the matches he played in refers to the Match rows with his Player_Match participation; average winning margin refers to AVG(Match.Win_Margin) over those matches", "SQL": "SELECT AVG(`Win_Margin`) AS avg_win_margin\nFROM `Match`\nWHERE `Match_Id` IN (SELECT DISTINCT pm.`Match_Id`\n FROM `Player` p\n JOIN `Player_Match` pm ON p.`Player_Id` = pm.`Player_Id`\n WHERE p.`Player_Name` = 'SC Ganguly')\n AND `Win_Margin` IS NOT NULL;"} {"question_id": 1808, "db_id": "soccer_2016", "grading_method": "set", "question": "Give the name of venue for the game with a win margin of 138 points.", "evidence": "name of venue refers to Venue_Name; a win margin of 138 points refers to Win_Margin = 138", "SQL": "SELECT T2.Venue_Name FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T1.Win_Margin = 138"} {"question_id": 1813, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the nationality of the 7th season Purple Cap winner?", "evidence": "nationality refers to Country_Name; the 7th season refers to Season_Id = 7; Purple Cap winner refers to Purple_Cap IS NOT NULL", "SQL": "SELECT c.Country_Name\nFROM Season s\nJOIN Player p ON s.Purple_Cap = p.Player_Id\nJOIN Country c ON p.Country_Name = c.Country_Id\nWHERE s.Season_Id = 7;"} {"question_id": 1817, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the batting hand of MK Pandey?", "evidence": "MK Pandey refers to Player_Name = 'MK Pandey'", "SQL": "SELECT T2.Batting_hand FROM Player AS T1 INNER JOIN Batting_Style AS T2 ON T1.Batting_hand = T2.Batting_Id WHERE T1.Player_Name = 'MK Pandey'"} {"question_id": 1837, "db_id": "soccer_2016", "grading_method": "set", "question": "Who is the player that has the highest number of roles as a captain for Deccan Chargers?", "evidence": "name of the player refers to Player_Name; the highest number of roles refers to max(count(Role_Id)); as a captain refers to Role_Desc = 'Captain'; Deccan Chargers refers to Team_Name = 'Deccan Chargers'", "SQL": "WITH player_num AS (\n SELECT T4.Player_Name name, COUNT(*) num\n FROM Team AS T1 \n INNER JOIN Player_Match AS T2 ON T1.Team_id = T2.Team_id \n INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id \n INNER JOIN Player AS T4 ON T2.Player_Id = T4.Player_Id \n WHERE T1.Team_Name = 'Deccan Chargers' AND T1.Team_Id = 8 AND T3.Role_Desc = 'Captain' AND T3.Role_Id = 1 \n GROUP BY T4.Player_Id\n) SELECT name FROM player_num WHERE num = (SELECT MAX(num) FROM player_num)"} {"question_id": 1839, "db_id": "soccer_2016", "grading_method": "set", "question": "Name the player who is born on July 7, 1981.", "evidence": "name of the player refers to Player_Name; born on July 7 1981 refers to DOB = '1981-07-07'", "SQL": "SELECT Player_name FROM Player WHERE DOB = '1981-07-07'"} {"question_id": 1840, "db_id": "soccer_2016", "grading_method": "set", "question": "How many matches were played by the player with player ID 2?", "evidence": "player ID 2 refers to Player_Id = 2", "SQL": "SELECT COUNT(DISTINCT `Match_Id`) FROM `Player_Match` WHERE `Player_Id` = 2;"} {"question_id": 1841, "db_id": "soccer_2016", "grading_method": "set", "question": "List the first team's name in the match with the highest winning margin.", "evidence": "team's name refers to Team_Name; first team refers to Team_Id = Team_1; the highest winning margin refers to max(Win_Margin)", "SQL": "SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 \nWHERE T1.Win_Margin = (\n SELECT MAX(T3.Win_Margin) FROM Match AS T3 INNER JOIN Team AS T4 ON T4.Team_Id = T3.Team_1)"} {"question_id": 1842, "db_id": "soccer_2016", "grading_method": "set", "question": "Give the country where St. George's Park is located.", "evidence": "country refers to Country_Name; St. George's Park refers to Venue_Name = 'St George''s Park'", "SQL": "SELECT T3.Country_Name FROM Venue AS T1 INNER JOIN City AS T2 ON T2.City_Id = T1.City_Id INNER JOIN Country AS T3 ON T3.Country_Id = T2.Country_id WHERE T1.Venue_Name = 'St George''s Park'"} {"question_id": 1843, "db_id": "soccer_2016", "grading_method": "set", "question": "List the player's name of Mumbai Indians in the match ID 335990.", "evidence": "Mumbai Indians refers to Team_Name = 'Mumbai Indians'; match ID 335990 refers to Match_Id = 335990", "SQL": "SELECT DISTINCT p.`Player_Name`\nFROM `Player` p\nJOIN `Player_Match` pm ON p.`Player_Id` = pm.`Player_Id`\nJOIN `Team` t ON t.`Team_Id` = pm.`Team_Id`\nWHERE pm.`Match_Id` = 335990\n AND t.`Team_Name` = 'Mumbai Indians';"} {"question_id": 1848, "db_id": "soccer_2016", "grading_method": "set", "question": "Among the matches held in 2015, who is the winning team in the match ID 829770? List the name of the winning team.", "evidence": "in 2015 refers to Match_Date LIKE '2015%'; the winning team refers to Team_Id = Match_Winner; match ID 829770 refers to Match_Id = 829770", "SQL": "SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner WHERE T1.Match_Date LIKE '2015%' AND T1.Match_Id = 829770"} {"question_id": 1850, "db_id": "soccer_2016", "grading_method": "set", "question": "How many cities are located in South Africa?", "evidence": "South Africa refers to Country_Name = 'South Africa'", "SQL": "SELECT SUM(CASE WHEN T2.Country_Name = 'South Africa' THEN 1 ELSE 0 END) FROM City AS T1 INNER JOIN Country AS T2 ON T2.Country_Id = T1.Country_id"} {"question_id": 1853, "db_id": "soccer_2016", "grading_method": "set", "question": "List the names of the first and the second teams that played matches in 2011 with the point of the winning margin lower than the 30% of the average winning margin of the matches held in 2011.", "evidence": "name of the team refers to Team_Name; in 2011 refers to Match_Date LIKE '2011%'; the point of winning margin lower than 30% of the average winning margin refers to Win_Margin < multiply(avg(Win_Margin), 0.3) where Match_Date LIKE '2011%'", "SQL": "SELECT DISTINCT\n t2.`Team_Name` AS First_Team,\n t3.`Team_Name` AS Second_Team\nFROM `Match` m\nJOIN `Team` t2 ON t2.`Team_Id` = m.`Team_1`\nJOIN `Team` t3 ON t3.`Team_Id` = m.`Team_2`\nWHERE m.`Match_Date` LIKE '2011%'\n AND m.`Win_Margin` <\n (SELECT AVG(`Win_Margin`)*0.30\n FROM `Match`\n WHERE `Match_Date` LIKE '2011%');"} {"question_id": 1859, "db_id": "soccer_2016", "grading_method": "set", "question": "List the players' names who were born in 1971.", "evidence": "players' name refers to Player_name; born in 1971 refers to DOB LIKE '1971%'", "SQL": "SELECT Player_name FROM Player WHERE DOB LIKE '1971%'"} {"question_id": 1864, "db_id": "soccer_2016", "grading_method": "set", "question": "Among the players who were born in 1977, provide names and birthdates of the players from England.", "evidence": "born in 1977 refers to DOB LIKE '1977%'; name refers to Player_Name; birthdate refers to DOB; England refers to Country_Name = 'England'", "SQL": "SELECT T2.Player_Name, T2.DOB FROM Country AS T1 INNER JOIN Player AS T2 ON T2.Country_Name = T1.Country_Id WHERE T2.DOB LIKE '1977%' AND T1.Country_Name = 'England'"} {"question_id": 1866, "db_id": "soccer_2016", "grading_method": "set", "question": "Calculate the win rate of the team \"Chennai Super Kings\".", "evidence": "team \"Chennai Super Kings\" refers to Team_Name = 'Chennai Super Kings'; win rate = divide(count(Match_Id where Match_Winner = 3), count(Match_Id)) * 100%", "SQL": "SELECT CAST(SUM(CASE WHEN T1.Match_Winner = 3 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.Match_Id) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_1 INNER JOIN Team AS T3 ON T3.Team_Id = T1.Team_2 WHERE T2.Team_Name = 'Chennai Super Kings' OR T3.Team_Name = 'Chennai Super Kings'"} {"question_id": 1867, "db_id": "soccer_2016", "grading_method": "set", "question": "List the names and countries of the players from Gujarat Lions who played in the match held on 11th April 2016.", "evidence": "player's name refers to Player_Name; country refers to Country_Name; Gujarat Lions refers to Team_Name = 'Gujarat Lions'; on 11th April 2016 refers to Match_Date = '2016-04-11'", "SQL": "SELECT T4.Player_Name, T5.Country_Name FROM Player_Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Team_Id INNER JOIN Match AS T3 ON T3.Match_Id = T1.Match_Id INNER JOIN Player AS T4 ON T4.Player_Id = T1.Player_Id INNER JOIN Country AS T5 ON T5.Country_Id = T4.Country_Name WHERE T2.Team_Name = 'Gujarat Lions' AND T3.Match_Date = '2016-04-11'"} {"question_id": 1870, "db_id": "soccer_2016", "grading_method": "set", "question": "Who was the captain of the winning team in the match held on 1st June 2008? List the name of the player.", "evidence": "player's name refers to Player_Name; captain refers to Role_Desc = 'Captain'; the winning team refers to Match_Winner = Team_Id; on 1st June 2008 refers to Match_Date = '2008-06-01'", "SQL": "SELECT T3.Player_Name FROM Player_Match AS T1 INNER JOIN Match AS T2 ON T2.Match_Id = T1.Match_Id INNER JOIN Player AS T3 ON T3.Player_Id = T1.Player_Id INNER JOIN Rolee AS T4 ON T4.Role_Id = T1.Role_Id WHERE T2.Match_Date = '2008-06-01' AND T4.Role_Desc = 'Captain' AND T2.Match_Winner = T1.Team_Id"} {"question_id": 1879, "db_id": "soccer_2016", "grading_method": "set", "question": "How many matches have Mumbai Indians won?", "evidence": "Mumbai Indians refers to Team_Name = 'Mumbai Indians'; won refers to Match_Winner", "SQL": "SELECT SUM(CASE WHEN T2.Team_Name = 'Mumbai Indians' THEN 1 ELSE 0 END) FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner"} {"question_id": 1881, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the name of the team that won match ID 336000?", "evidence": "name of the team refers to Team_Name; won refers to Match_Winner", "SQL": "SELECT T2.Team_Name FROM Match AS T1 INNER JOIN Team AS T2 ON T2.Team_Id = T1.Match_Winner WHERE T1.Match_Id = 336000"} {"question_id": 1888, "db_id": "soccer_2016", "grading_method": "set", "question": "How many matches did the Deccan Chargers win?", "evidence": "Match.Match_Winner identifies the winning team; Team.Team_Name uses 'Deccan Chargers'.", "SQL": "SELECT COUNT(*) AS total_wins FROM `Match` AS m JOIN `Team` AS t ON t.`Team_Id` = m.`Match_Winner` WHERE t.`Team_Name` = 'Deccan Chargers';"} {"question_id": 1898, "db_id": "soccer_2016", "grading_method": "set", "question": "In the players, how many were out by hit wicket?", "evidence": "out by hit wicket refers to Out_Name = 'hit wicket'", "SQL": "SELECT COUNT(DISTINCT Player_Out) FROM (SELECT Player_Out FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T1.Kind_Out = T2.Out_Id WHERE Out_Name = 'hit wicket')"} {"question_id": 1904, "db_id": "soccer_2016", "grading_method": "set", "question": "Give the name of the venue where the most number of matches are held.", "evidence": "name of the venue refers to Venue_Name; most number of matches refers to max(count(Venue_Id))", "SQL": "SELECT T2.Venue_Name FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id \nGROUP BY T2.Venue_Name HAVING COUNT(T2.Venue_Id) = (SELECT COUNT(*) FROM `Match` AS T3 INNER JOIN Venue AS T4 ON T3.Venue_Id = T4.Venue_Id GROUP BY T4.Venue_Name ORDER BY COUNT(T4.Venue_Id) DESC LIMIT 1)"} {"question_id": 1912, "db_id": "soccer_2016", "grading_method": "set", "question": "How many games were played in March 2010?", "evidence": "were played in March 2010 refers to Match_Date = '2010-03%'", "SQL": "SELECT SUM(CASE WHEN Match_Date LIKE '2010-03%' THEN 1 ELSE 0 END) FROM `Match`"} {"question_id": 1941, "db_id": "soccer_2016", "grading_method": "set", "question": "Count the match IDs in which V Kohli is the \"Man of the Match\".", "evidence": "", "SQL": "SELECT COUNT(*) AS match_count FROM `Match` AS M JOIN `Player` AS P ON M.`Man_of_the_Match` = P.`Player_Id` WHERE P.`Player_Name` = 'V Kohli';"} {"question_id": 1943, "db_id": "soccer_2016", "grading_method": "set", "question": "Who among the players won both \"Man of the Series\" and \"Orange Cap\" in the same season?", "evidence": "Who refers to Player_Name;", "SQL": "SELECT DISTINCT P.Player_Name\nFROM `Season` S\nJOIN `Player` P ON P.`Player_Id` = S.`Man_of_the_Series`\nWHERE S.`Man_of_the_Series` = S.`Orange_Cap`;"} {"question_id": 1964, "db_id": "soccer_2016", "grading_method": "set", "question": "Provide the complete name of the venue, city and country where the last match was held.", "evidence": "name of the venue, city and country refers to Venue_Name and City_Name and Country_Name; last match refers to max(Match_Date)", "SQL": "WITH venue_date AS (\n SELECT T1.Venue_Name, T2.City_Name, T3.Country_Name, T4.Match_Date FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id INNER JOIN Country AS T3 ON T2.Country_Id = T3.Country_Id INNER JOIN Match AS T4 ON T1.Venue_Id = T4.Venue_Id\n) SELECT Venue_Name, City_Name, Country_Name\nFROM venue_date\nWHERE Match_Date = (SELECT MAX(Match_Date) FROM venue_date)"} {"question_id": 1972, "db_id": "soccer_2016", "grading_method": "set", "question": "How many matches did Mohammad Hafeez play?", "evidence": "Mohammad Hafeez refers to Player_Name = 'Mohammad Hafeez';", "SQL": "SELECT SUM(CASE WHEN T2.Player_Name = 'Mohammad Hafeez' THEN 1 ELSE 0 END) FROM Player_Match AS T1 INNER JOIN Player AS T2 ON T1.Player_Id = T2.Player_Id"} {"question_id": 1981, "db_id": "soccer_2016", "grading_method": "set", "question": "List the match IDs for matches with penalty extras.", "evidence": "Extra_Type.Extra_Name = 'penalty' denotes penalty extras; Extra_Runs records extras by match.", "SQL": "SELECT DISTINCT `T1`.`Match_Id` FROM `Extra_Runs` AS `T1` JOIN `Extra_Type` AS `T2` ON `T1`.`Extra_Type_Id` = `T2`.`Extra_Id` WHERE `T2`.`Extra_Name` = 'penalty'"} {"question_id": 1982, "db_id": "soccer_2016", "grading_method": "set", "question": "Name the teams that played in a tied match in 2015.", "evidence": "Win_By.Win_Type = 'Tie' denotes a tied result. Match.Win_Type identifies the result in Win_By.Win_Id. Match.Match_Date uses YYYY-MM-DD.", "SQL": "SELECT DISTINCT T1.`Team_Name` FROM `Team` AS T1 JOIN `Match` AS M ON (T1.`Team_Id` = M.`Team_1` OR T1.`Team_Id` = M.`Team_2`) JOIN `Win_By` AS W ON M.`Win_Type` = W.`Win_Id` WHERE SUBSTR(M.`Match_Date`,1,4) = '2015' AND W.`Win_Type` = 'Tie';"} {"question_id": 1990, "db_id": "soccer_2016", "grading_method": "set", "question": "How many venues are located at Centurion, South Africa?", "evidence": "venues are located at Centurion refers to city_name = 'Centurion'; South Africa refers to country_name = 'South Africa'", "SQL": "SELECT COUNT(T1.Venue_name) FROM Venue AS T1 INNER JOIN City AS T2 ON T1.City_Id = T2.City_Id INNER JOIN Country AS T3 ON T2.Country_Id = T3.Country_Id WHERE T3.country_name = 'South Africa' AND T2.city_name = 'Centurion'"} {"question_id": 1995, "db_id": "soccer_2016", "grading_method": "set", "question": "Provide the losing team's name in the match ID 336039.", "evidence": "losing team's name refers to Team_Id NOT in \"match_winner\" column", "SQL": "SELECT Team_Name FROM Team WHERE Team_Id = ( SELECT CASE WHEN Team_1 = Match_Winner THEN Team_2 ELSE Team_1 END FROM Match WHERE match_id = 336039 )"} {"question_id": 2014, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the role of SC Ganguly?", "evidence": "SC Ganguly refers to Player_Name = 'SC Ganguly'; role refers to Role_Desc", "SQL": "SELECT T3.Role_Desc FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id WHERE T1.Player_Name = 'SC Ganguly' GROUP BY T3.Role_Desc"} {"question_id": 2015, "db_id": "soccer_2016", "grading_method": "set", "question": "List the names of players who played as a keeper.", "evidence": "played as a keeper refers to Role_Desc = 'Keeper'; name of player refers to Player_Name;", "SQL": "SELECT T1.Player_Name FROM Player AS T1 INNER JOIN Player_Match AS T2 ON T1.Player_Id = T2.Player_Id INNER JOIN Rolee AS T3 ON T2.Role_Id = T3.Role_Id WHERE T3.Role_Desc = 'Keeper' GROUP BY T1.Player_Name"} {"question_id": 2019, "db_id": "soccer_2016", "grading_method": "set", "question": "What was the win type for match 336000?", "evidence": "Match.Win_Type identifies the description in Win_By.Win_Id; Win_By.Win_Type contains the result text.", "SQL": "SELECT T2.Win_Type FROM Match AS T1 INNER JOIN Win_By AS T2 ON T1.Win_Type = T2.Win_Id WHERE T1.Match_Id = 336000"} {"question_id": 2022, "db_id": "soccer_2016", "grading_method": "set", "question": "What is the outcome type of match ID 392195?", "evidence": "", "SQL": "SELECT T2.Outcome_Type FROM Match AS T1 INNER JOIN Outcome AS T2 ON T1.Outcome_type = T2.Outcome_Id WHERE T1.Match_Id = '392195'"} {"question_id": 2023, "db_id": "soccer_2016", "grading_method": "set", "question": "Who are the youngest players by birth date? Give their names and countries, including ties.", "evidence": "youngest refers to the greatest Player.DOB; a player's country refers to the Country whose identifier equals that player's Player.Country_Name; return the player name and that Country.Country_Name for every player whose Player.DOB = MAX(DOB), including all ties", "SQL": "WITH player_city_dob AS (\n SELECT T1.Player_Name, T2.Country_Name, T1.DOB \n FROM Player AS T1 \n INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_Id \n) SELECT Player_Name, Country_Name FROM player_city_dob\nWHERE DOB = (SELECT MAX(DOB) FROM player_city_dob)"} {"question_id": 2029, "db_id": "soccer_2016", "grading_method": "set", "question": "Which team won by wickets in match ID 335993?", "evidence": "team refers to Team_Name", "SQL": "SELECT `Team`.`Team_Name`\nFROM `Match`\nJOIN `Win_By` ON `Match`.`Win_Type` = `Win_By`.`Win_Id`\nJOIN `Team` ON `Team`.`Team_Id` = `Match`.`Match_Winner`\nWHERE `Match`.`Match_Id` = 335993\n AND `Win_By`.`Win_Type` = 'wickets';"} {"question_id": 2032, "db_id": "soccer_2016", "grading_method": "set", "question": "What are the names of players who were named Man of the Match more than three times during the 2008 season?", "evidence": "the 2008 season refers to Season.Season_Year = 2008; named Man of the Match refers to the player that Match.Man_of_the_Match identifies; named Man of the Match more than three times during that season refers to COUNT(*) > 3 of such Match rows per player; return Player.Player_Name of each such player", "SQL": "SELECT p.`Player_Name`\nFROM `Match` m\nJOIN `Season` s ON m.`Season_Id` = s.`Season_Id`\nJOIN `Player` p ON m.`Man_of_the_Match` = p.`Player_Id`\nWHERE s.`Season_Year` = 2008\nGROUP BY p.`Player_Id`\nHAVING COUNT(*) > 3;"} {"question_id": 2040, "db_id": "soccer_2016", "grading_method": "set", "question": "List the IDs of all matches at St. George’s Park tied for the highest winning margin.", "evidence": "matches at St. George's Park refers to Venue.Venue_Name = 'St George''s Park'; the highest winning margin refers to MAX(Match.Win_Margin) among those matches; list the ID of every match at that venue whose Win_Margin is that MAX, so all tied matches are listed", "SQL": "SELECT M.`Match_Id`\nFROM `Match` M\nJOIN `Venue` V ON V.`Venue_Id` = M.`Venue_Id`\nWHERE V.`Venue_Name` = 'St George''s Park'\n AND M.`Win_Margin` = (\n SELECT MAX(M2.`Win_Margin`)\n FROM `Match` M2\n JOIN `Venue` V2 ON V2.`Venue_Id` = M2.`Venue_Id`\n WHERE V2.`Venue_Name` = 'St George''s Park'\n );"} {"question_id": 2041, "db_id": "soccer_2016", "grading_method": "set", "question": "How many of the players are from Sri Lanka?", "evidence": "from Sri Lanka refers to Country_Name = 'Sri Lanka';", "SQL": "SELECT COUNT(*) FROM Player AS T1 INNER JOIN Country AS T2 ON T1.Country_Name = T2.Country_ID WHERE T2.Country_Name = 'Sri Lanka'"} {"question_id": 2045, "db_id": "music_tracker", "grading_method": "set", "question": "What is the release title of the single that was released by Ron Hunt in 1979 that was downloaded 156 times?", "evidence": "release title refers to groupName; Ron Hunt is an artist; groupYear = 1979; releaseType = 'single'; downloaded 156 times refer to totalSnatched = 156;", "SQL": "SELECT groupName FROM torrents WHERE artist LIKE '%Ron Hunt%' AND groupYear = 1979 AND releaseType LIKE 'single' AND totalSnatched = 156"} {"question_id": 2052, "db_id": "music_tracker", "grading_method": "set", "question": "What is the tag and the artist of the most downloaded single?", "evidence": "the most downloaded single refers to MAX(totalSnatched where releaseType = 'single');", "SQL": "SELECT t2.`tag`, t1.`artist`\nFROM `torrents` AS t1\nJOIN `tags` AS t2 ON t1.`id` = t2.`id`\nWHERE t1.`releaseType` = 'single'\n AND t1.`totalSnatched` = (\n SELECT MAX(`totalSnatched`)\n FROM `torrents`\n WHERE `releaseType` = 'single'\n );"} {"question_id": 2060, "db_id": "music_tracker", "grading_method": "set", "question": "How many releases by the artist michael jackson are tagged \"pop\"?", "evidence": "tag = 'pop';", "SQL": "SELECT COUNT(DISTINCT T1.id) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'pop' AND T1.artist = 'michael jackson'"} {"question_id": 2063, "db_id": "music_tracker", "grading_method": "set", "question": "Name the title of the top three releases with the highest number of downloads.", "evidence": "title refers to groupName; the highest number of downloads refers to MAX(totalSnatched);", "SQL": "SELECT groupName FROM torrents ORDER BY totalSnatched DESC LIMIT 3"} {"question_id": 2071, "db_id": "music_tracker", "grading_method": "set", "question": "List the titles of single releases with IDs from 10 to 20 and at least 20 downloads.", "evidence": "torrents.groupName records the release title; torrents.totalSnatched records downloads. Single releases have torrents.releaseType = 'single'.", "SQL": "SELECT groupName FROM torrents WHERE totalSnatched >= 20 AND releaseType LIKE 'single' AND id BETWEEN 10 AND 20"} {"question_id": 2073, "db_id": "music_tracker", "grading_method": "set", "question": "Provide the name of artists who had no more than 100 downloads and are tagged \"funk\" in 1980.", "evidence": "no more than 100 downloads refer to totalSnatched ≤ 100; groupYear = 1980; tag = 'funk';", "SQL": "SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'funk' AND T1.groupYear = 1980 GROUP BY T1.artist HAVING SUM(T1.totalSnatched) <= 100"} {"question_id": 2074, "db_id": "music_tracker", "grading_method": "set", "question": "Which artist has released the most singles with the tag \"soul\"?", "evidence": "the most singles refer to MAX(COUNT(releaseType = 'single'));", "SQL": "SELECT artist\nFROM (\n SELECT t1.artist, COUNT(DISTINCT t1.id) AS cnt\n FROM torrents t1\n JOIN tags t2 ON t1.id = t2.id\n WHERE t2.tag = 'soul'\n AND t1.releaseType = 'single'\n GROUP BY t1.artist\n) x\nWHERE cnt = (\n SELECT MAX(cnt)\n FROM (\n SELECT COUNT(DISTINCT T1.id) AS cnt\n FROM torrents t1\n JOIN tags t2 ON t1.id = t2.id\n WHERE t2.tag = 'soul'\n AND t1.releaseType = 'single'\n GROUP BY t1.artist\n )\n);"} {"question_id": 2075, "db_id": "music_tracker", "grading_method": "set", "question": "Which artists released funk music in 1980 on releases with IDs from 10 through 30?", "evidence": "torrents.id identifies a release; torrents.groupYear is its release year. tags.id identifies the tagged release, and tags.tag = 'funk' denotes the funk tag.", "SQL": "SELECT DISTINCT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'funk' AND T1.groupYear = 1980 AND T1.id BETWEEN 10 AND 30"} {"question_id": 2077, "db_id": "music_tracker", "grading_method": "set", "question": "What are the genre tags for the release with id 16?", "evidence": "", "SQL": "SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.id = 16"} {"question_id": 2086, "db_id": "music_tracker", "grading_method": "set", "question": "Please list all release titles whose tag is jazz in 2005.", "evidence": "release titles refer to groupName; groupYear = 2005;", "SQL": "SELECT T1.groupName FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.groupYear = 2005 AND T2.tag LIKE 'jazz'"} {"question_id": 2094, "db_id": "world_development_indicators", "grading_method": "set", "question": "Among the countries with country notes on the series code SM.POP.TOTL, how many of them are in the low-income group?", "evidence": "countries refer to Countrycode; low-income group refers to incomegroup = 'Low income'; with notes refers to description IS NOT NULL; series code SM.POP.TOTL refers to Seriescode = 'SM.POP.TOTL'", "SQL": "SELECT COUNT(T1.Countrycode) FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Seriescode = 'SM.POP.TOTL' AND T1.IncomeGroup = 'Low income' AND T2.Description IS NOT NULL;"} {"question_id": 2096, "db_id": "world_development_indicators", "grading_method": "set", "question": "How many low-income countries under the lending category of the International Development Associations have a country note on the series code SM.POP.TOTL?", "evidence": "low-income countries are where the incomegroup = Low income", "SQL": "SELECT COUNT(T1.Countrycode) FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.LendingCategory = 'IDA' AND T2.Seriescode = 'SM.POP.TOTL' AND IncomeGroup = 'Low income'"} {"question_id": 2099, "db_id": "world_development_indicators", "grading_method": "set", "question": "What is the description of the footnote on the series code AG.LND.FRST.K2 in 1990 for Aruba?", "evidence": "For this footnote, 1990 is stored as 'YR1990' in Footnotes.Year. Aruba is recorded in Country.ShortName.", "SQL": "SELECT T2.Description FROM Country AS T1 INNER JOIN FootNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.ShortName = 'Aruba' AND T2.Seriescode = 'AG.LND.FRST.K2' AND T2.Year = 'YR1990'"} {"question_id": 2100, "db_id": "world_development_indicators", "grading_method": "set", "question": "In which years did Aruba have a footnote for series AG.LND.FRST.K2?", "evidence": "Aruba is recorded in Country.ShortName. Footnotes.Year uses 'YR' followed by a four-digit year, such as 'YR2010'.", "SQL": "SELECT T2.Year FROM Country AS T1 INNER JOIN FootNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.ShortName = 'Aruba' AND T2.Seriescode = 'AG.LND.FRST.K2'"} {"question_id": 2105, "db_id": "world_development_indicators", "grading_method": "set", "question": "What are the special notes for the country whose average adolescent fertility rate is the highest?", "evidence": "the average adolescent fertility rate is DIVIDE(SUM(value), SUM(IndicatorName like 'adolescent fertility rate%')); MAX(average adolescent fertility rate)", "SQL": "WITH country_avg AS (\n SELECT `CountryCode`, AVG(`Value`) AS avg_rate\n FROM `Indicators`\n WHERE `IndicatorName` LIKE 'Adolescent fertility rate%'\n GROUP BY `CountryCode`\n), top_country AS (\n SELECT `CountryCode`\n FROM country_avg\n ORDER BY avg_rate DESC\n LIMIT 1\n)\nSELECT SpecialNotes\nFROM country_avg\nJOIN country USING (`CountryCode`)\nWHERE avg_rate = (SELECT MAX(avg_rate) FROM country_avg)"} {"question_id": 2111, "db_id": "world_development_indicators", "grading_method": "set", "question": "In 1970, how many countries in the Middle East & North Africa region had CO2 emissions from gaseous fuel consumption above 600 kt?", "evidence": "Indicators.IndicatorName uses 'CO2 emissions from gaseous fuel consumption (kt)'; Indicators.Value is in kilotonnes for this indicator. Country.Region uses 'Middle East & North Africa'.", "SQL": "SELECT COUNT(T2.CountryCode) FROM Indicators AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.Region = 'Middle East & North Africa' AND T1.IndicatorName = 'CO2 emissions from gaseous fuel consumption (kt)' AND T1.Year = 1970 AND T1.Value > 600"} {"question_id": 2120, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which countries had a fertility rate between 4 and 5 in 1979?", "evidence": "Fertility rate refers to the IndicatorName ‘Fertility rate, total (births per woman)’. Entries with a Region are individual economies, including territories; those without one are aggregates.", "SQL": "SELECT DISTINCT c.`ShortName`\nFROM `Indicators` i\nJOIN `Country` c ON c.`CountryCode` = i.`CountryCode`\nWHERE i.`Year` = 1979\n AND i.`IndicatorName` = 'Fertility rate, total (births per woman)'\n AND i.`Value` BETWEEN 4 AND 5\n AND COALESCE(c.`Region`, '') <> '';"} {"question_id": 2150, "db_id": "world_development_indicators", "grading_method": "set", "question": "List the full country names for countries with data for indicator DT.DOD.DSTC.CD.", "evidence": "Full country names are recorded in Country.LongName.", "SQL": "SELECT DISTINCT c.`LongName` FROM `Country` AS c JOIN `Indicators` AS i ON i.`CountryCode` = c.`CountryCode` WHERE i.`IndicatorCode` = 'DT.DOD.DSTC.CD'"} {"question_id": 2153, "db_id": "world_development_indicators", "grading_method": "set", "question": "List the country codes of low-income countries.", "evidence": "Country.IncomeGroup = 'Low income' denotes low income.", "SQL": "SELECT DISTINCT CountryCode FROM Country AS T1 WHERE T1.IncomeGroup = 'Low income'"} {"question_id": 2155, "db_id": "world_development_indicators", "grading_method": "set", "question": "List the country codes and series codes for lower-middle-income countries that use the Australian dollar.", "evidence": "Lower middle income group refers to IncomeGroup = 'Lower middle income';", "SQL": "SELECT T1.CountryCode, T2.SeriesCode FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.CurrencyUnit = 'Australian dollar' AND T1.IncomeGroup = 'Lower middle income'"} {"question_id": 2157, "db_id": "world_development_indicators", "grading_method": "set", "question": "List out the country code and country name of the rich countries using Euro as their currency unit", "evidence": "Non-OECD and OECD countries can be regarded as rich countries for those that are part of the High Income Group;", "SQL": "SELECT DISTINCT T1.CountryCode, T2.CountryName FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.CurrencyUnit = 'Euro' AND (T1.IncomeGroup = 'High income: OECD' OR T1.IncomeGroup = 'High income: nonOECD')"} {"question_id": 2164, "db_id": "world_development_indicators", "grading_method": "set", "question": "How many country records have no special notes?", "evidence": "Country.SpecialNotes records special notes; an empty string denotes no special notes in this database.", "SQL": "SELECT COUNT(LongName) FROM Country WHERE SpecialNotes = ''"} {"question_id": 2167, "db_id": "world_development_indicators", "grading_method": "set", "question": "Give the country codes of low-income countries with data for indicator DT.DOD.DECT.CD.", "evidence": "Country.IncomeGroup uses 'Low income'.", "SQL": "SELECT DISTINCT I.CountryCode FROM Country C JOIN Indicators I ON C.CountryCode = I.CountryCode WHERE C.IncomeGroup = 'Low income' AND I.IndicatorCode = 'DT.DOD.DECT.CD';"} {"question_id": 2175, "db_id": "world_development_indicators", "grading_method": "set", "question": "How many countries have country note description as \"Sources: UN Energy Statistics (2014)\"?", "evidence": "countries refer to CountryCode; currency refers to CurrencyUnit;", "SQL": "SELECT COUNT(DISTINCT T1.Countrycode) FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Description = 'Sources: UN Energy Statistics (2014)';"} {"question_id": 2177, "db_id": "world_development_indicators", "grading_method": "set", "question": "For country notes with the exact description “Data sources : Eurostat”, list the series codes and the countries’ Wb2Codes.", "evidence": "CountryNotes.Countrycode corresponds to Country.CountryCode; Country.Wb2Code is a separate country code.", "SQL": "SELECT T2.seriescode, T1.Wb2Code FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Description = 'Data sources : Eurostat'"} {"question_id": 2178, "db_id": "world_development_indicators", "grading_method": "set", "question": "Among the low income countries, which country has the lowest fertility rate? List the names of these countries.", "evidence": "fertility rate refers to IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)'; lowest refers to MIN(Value); IncomeGroup = 'Low income';", "SQL": "WITH country_value AS (\n SELECT T2.CountryName, T2.Value \n FROM Country AS T1 \n INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode \n WHERE T1.IncomeGroup = 'Low income' AND T2.IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)' \n) SELECT DISTINCT CountryName FROm country_value WHERE Value = (SELECT MIN(Value) FROM country_value)"} {"question_id": 2191, "db_id": "world_development_indicators", "grading_method": "set", "question": "How many countries use the 1968 System of National Accounts methodology?", "evidence": "Country.SystemOfNationalAccounts uses 'Country uses the 1968 System of National Accounts methodology.'.", "SQL": "SELECT COUNT(CountryCode) FROM Country WHERE SystemOfNationalAccounts = 'Country uses the 1968 System of National Accounts methodology.'"} {"question_id": 2193, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which countries have footnotes for series under the topic “Poverty: Shared Prosperity”? List their full names.", "evidence": "", "SQL": "SELECT DISTINCT T1.LongName FROM Country AS T1 INNER JOIN footnotes AS T2 ON T1.CountryCode = T2.Countrycode INNER JOIN Series AS T3 ON T2.Seriescode = T3.SeriesCode WHERE T3.Topic = 'Poverty: Shared prosperity'"} {"question_id": 2200, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which country has the lowest percentage of arable land ever recorded?", "evidence": "which country refers to countryname; the lowest percentage of arable land refers to min(value where indicatorname = 'Arable land (% of land area)')", "SQL": "SELECT `CountryName`\nFROM `Indicators`\nWHERE `IndicatorName` = 'Arable land (% of land area)'\n AND `Value` = (SELECT MIN(`Value`) FROM `Indicators` WHERE `IndicatorName` = 'Arable land (% of land area)')\nGROUP BY `CountryName`;"} {"question_id": 2206, "db_id": "world_development_indicators", "grading_method": "set", "question": "What proportion of Sub-Saharan Africa's countries have lower middle incomes?", "evidence": "proportion = divide(count(countrycode where incomegroup = 'Lower middle income'), count(countrycode))*100%; Sub-Saharan Africa's countries refers to region = 'Sub-Saharan Africa'; have lower middle incomes refers to incomegroup = 'Lower middle income'", "SQL": "SELECT SUM(CASE WHEN IncomeGroup = 'Lower middle income' THEN 1 ELSE 0 END) * 100.0 / COUNT(CountryCode) persentage FROM Country WHERE Region = 'Sub-Saharan Africa'"} {"question_id": 2221, "db_id": "world_development_indicators", "grading_method": "set", "question": "What was Italy’s agricultural land area, in square kilometers, in 1968?", "evidence": "Indicators.IndicatorName uses 'Agricultural land (sq. km)'; Indicators.Value records the area and Indicators.CountryName uses 'Italy'.", "SQL": "SELECT Value FROM Indicators WHERE IndicatorName = 'Agricultural land (sq. km)' AND Year = 1968 AND CountryName = 'Italy'"} {"question_id": 2226, "db_id": "world_development_indicators", "grading_method": "set", "question": "What is the lending category of the country with a cereal production of 6140000 metric tons for the year 1966?", "evidence": "cereal production of 6140000 metric tons refers value where IndicatorName = 'Cereal production (metric tons)' and Value=6140000; the year 1966 refers to Year = '1966'", "SQL": "SELECT T1.LendingCategory FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.IndicatorName = 'Cereal production (metric tons)' AND T2.Value = 6140000 AND T2.Year = 1966"} {"question_id": 2230, "db_id": "world_development_indicators", "grading_method": "set", "question": "What was the average number of passengers carried by air transport per year by Bulgaria from 1970 to 1980? Indicate the country’s system of trade.", "evidence": "passengers carried by air transport refers to Indicators.Value where IndicatorName = 'Air transport, passengers carried'; Bulgaria refers to Indicators.CountryName = 'Bulgaria'; 1970 to 1980 refers to Indicators.Year BETWEEN 1970 AND 1980; return both AVG(Value) and the country's Country.SystemOfTrade", "SQL": "SELECT AVG(T1.Value), T2.SystemOfTrade FROM Indicators AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.IndicatorName = 'Air transport, passengers carried' AND T1.Year >= 1970 AND T1.Year < 1981 AND T1.CountryName = 'Bulgaria'"} {"question_id": 2231, "db_id": "world_development_indicators", "grading_method": "set", "question": "What is the latest household survey recorded for Angola?", "evidence": "Country.LatestHouseholdSurvey is descriptive text that can include the survey name, acronym, and year. Angola is recorded in Country.ShortName.", "SQL": "SELECT LatestHouseholdSurvey FROM Country WHERE ShortName = 'Angola'"} {"question_id": 2238, "db_id": "world_development_indicators", "grading_method": "set", "question": "What is the note for Australia on the indicator SP.ADO.TFRT?", "evidence": "note refers to Description; for Australia refers to ShortName = 'Australia'; indicator SP.ADO.TFRT refers to Seriescode = 'SP.ADO.TFRT'", "SQL": "SELECT T2.Description FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Seriescode = 'SP.ADO.TFRT' AND T1.ShortName = 'Australia'"} {"question_id": 2239, "db_id": "world_development_indicators", "grading_method": "set", "question": "Please list the country notes for Aruba on the indicators under the topic of Environment: Energy production & use.", "evidence": "note refers to Description; for Aruba refers to ShortName = 'Aruba'", "SQL": "SELECT T2.Description FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode INNER JOIN Series AS T3 ON T2.Seriescode = T3.SeriesCode WHERE T1.ShortName = 'Aruba' AND T3.Topic = 'Environment: Energy production & use'"} {"question_id": 2240, "db_id": "world_development_indicators", "grading_method": "set", "question": "Which countries have country notes on the indicator BX.KLT.DINV.CD.WD? List their short names", "evidence": "indicator BX.KLT.DINV.CD.WD refers to Seriescode = 'BX.KLT.DINV.CD.WD'", "SQL": "SELECT T1.ShortName FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode INNER JOIN Series AS T3 ON T2.Seriescode = T3.SeriesCode WHERE T3.Seriescode = 'BX.KLT.DINV.CD.WD'"} {"question_id": 2248, "db_id": "movielens", "grading_method": "set", "question": "Among the users who gave a rating of 5, how many of them are male?", "evidence": "Male users mean that u_gender = 'M'", "SQL": "SELECT COUNT(DISTINCT T1.userid) FROM u2base AS T1 INNER JOIN users AS T2 ON T1.userid = T2.userid WHERE T1.rating = 5 AND T2.u_gender = 'M'"} {"question_id": 2249, "db_id": "movielens", "grading_method": "set", "question": "List the distinct genres of movies in which actor ID 851 appears.", "evidence": "Movie genres are recorded in movies2directors.genre.", "SQL": "SELECT DISTINCT T2.genre FROM movies2actors AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid INNER JOIN actors AS T3 ON T1.actorid = T3.actorid WHERE T3.actorid = 851"} {"question_id": 2252, "db_id": "movielens", "grading_method": "set", "question": "What is the most common occupation among users who have given at least one rating of 2 or lower?", "evidence": "users.occupation stores occupation as text. User ratings are recorded in u2base.rating.", "SQL": "WITH occupation_counts AS (\n SELECT T1.occupation, COUNT(*) AS user_count\n FROM users AS T1\n WHERE EXISTS (\n SELECT 1 FROM u2base AS T2\n WHERE T2.userid = T1.userid AND T2.rating <= 2\n )\n GROUP BY T1.occupation\n)\nSELECT occupation FROM occupation_counts\nWHERE user_count = (SELECT MAX(user_count) FROM occupation_counts);"} {"question_id": 2255, "db_id": "movielens", "grading_method": "subset,=,5", "question": "List any five movies from the ‘other’ country category that are not in English.", "evidence": "The country category is movies.country = 'other'; movies.isEnglish = 'F' denotes a film not in English.", "SQL": "SELECT movieid FROM movies WHERE country = 'other' AND isEnglish = 'F';"} {"question_id": 2259, "db_id": "movielens", "grading_method": "set", "question": "List the id of male users who gave ratings of less than 3 to French movies with running time of 2.", "evidence": "Male users mean that u_gender = 'M'; France is a country", "SQL": "SELECT DISTINCT T1.userid FROM u2base AS T1 INNER JOIN movies AS T2 ON T1.movieid = T2.movieid INNER JOIN users AS T3 ON T1.userid = T3.userid WHERE T2.country = 'France' AND T2.runningtime = 2 AND T1.rating < 3 AND T3.u_gender = 'M'"} {"question_id": 2264, "db_id": "movielens", "grading_method": "set", "question": "How many female actors acted in the movies of year 4?", "evidence": "Female actors mean that a_gender = 'F'", "SQL": "SELECT COUNT(DISTINCT T2.actorid) FROM movies AS T1 INNER JOIN movies2actors AS T2 ON T1.movieid = T2.movieid INNER JOIN actors AS T3 ON T2.actorid = T3.actorid WHERE T3.a_gender = 'F' AND T1.year = 4"} {"question_id": 2270, "db_id": "movielens", "grading_method": "set", "question": "Movies with rating 3 are viewed by audiences in which distinct age group?", "evidence": "The audience and users are the same meaning", "SQL": "SELECT DISTINCT T2.age FROM u2base AS T1 INNER JOIN users AS T2 ON T1.userid = T2.userid WHERE T1.rating = 3"} {"question_id": 2272, "db_id": "movielens", "grading_method": "set", "question": "List the IDs of movies acted in by actors who received a rating of 5.", "evidence": "actors.a_quality records the actor’s rating.", "SQL": "WITH top_actors AS ( SELECT `actorid` FROM `actors` WHERE `a_quality` = 5 ) SELECT DISTINCT `movieid` FROM `movies2actors` WHERE `actorid` IN (SELECT `actorid` FROM top_actors)"} {"question_id": 2275, "db_id": "movielens", "grading_method": "set", "question": "What is the difference of female and male audiences in number who viewed horror movies?", "evidence": "The audience and users are the same meaning; Difference of female and male audiences = count(female users) - count(male users); Female users refers to u_gender = 'F'; Male users refers to u_gender = 'M'", "SQL": "SELECT SUM(CASE WHEN gender = 'F' THEN 1 WHEN gender = 'M' THEN -1 END) AS diff FROM ( SELECT DISTINCT u.userid id, u.u_gender gender FROM users u JOIN u2base ub ON ub.userid = u.userid JOIN movies2directors md ON md.movieid = ub.movieid WHERE md.genre = 'Horror' ) t"} {"question_id": 2277, "db_id": "movielens", "grading_method": "set", "question": "Among the action movies from the USA, how many of them are not in English?", "evidence": "USA is a country; not in English can be represented by isEnglish = 'F'", "SQL": "SELECT COUNT(DISTINCT T1.movieid) FROM movies AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid WHERE T1.country = 'USA' AND T1.isEnglish = 'F' AND T2.genre = 'Action'"} {"question_id": 2288, "db_id": "movielens", "grading_method": "set", "question": "What is the highest average rating for action movies made in the USA?", "evidence": "USA is a country", "SQL": "SELECT AVG(T2.rating) FROM movies AS T1 INNER JOIN u2base AS T2 ON T1.movieid = T2.movieid INNER JOIN movies2directors AS T3 ON T1.movieid = T3.movieid WHERE T1.country = 'USA' AND T3.genre = 'Action' GROUP BY T1.movieid ORDER BY AVG(T2.rating) DESC LIMIT 1"} {"question_id": 2301, "db_id": "movielens", "grading_method": "set", "question": "Give the respective numbers of actors and directors for the movie with id 1949144.", "evidence": "", "SQL": "SELECT COUNT(DISTINCT T1.actorid), COUNT(DISTINCT T2.directorid) FROM movies2actors AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid WHERE T1.movieid = 1949144"} {"question_id": 2303, "db_id": "movielens", "grading_method": "set", "question": "What is the proportion of action movies directors who are called 'box office success paradox'?", "evidence": "'box office success paradox' means average revenue exceeds their quality; The proportion can be computed by [(avg_revenue > d_quality) / ()] * 100%", "SQL": "SELECT 100.0 * SUM(CASE WHEN d.avg_revenue > d.d_quality THEN 1 ELSE 0 END) / COUNT(*) AS proportion_paradox_directors FROM ( SELECT DISTINCT m2d.directorid FROM movies2directors AS m2d WHERE m2d.genre = 'Action' ) AS ad JOIN directors AS d ON ad.directorid = d.directorid;"} {"question_id": 2324, "db_id": "movielens", "grading_method": "set", "question": "How many female actors played a role in any French or U.S. movies?", "evidence": "actors.a_gender = 'F' denotes female. Movie countries are recorded in movies.country as 'France' and 'USA'.", "SQL": "SELECT COUNT(DISTINCT a.actorid)\nFROM `actors` AS a\nJOIN `movies2actors` AS m2a ON a.actorid = m2a.actorid\nJOIN `movies` AS m ON m2a.movieid = m.movieid\nWHERE a.a_gender = 'F'\n AND m.country IN ('France', 'USA');"} {"question_id": 2325, "db_id": "movielens", "grading_method": "set", "question": "How many different actors have played a role in movies that have the highest average rating?", "evidence": "highest average rating refers to MAX(AVG(rating))", "SQL": "SELECT SUM(cnt) FROM (SELECT COUNT(DISTINCT T2.actorid) cnt FROM u2base AS T1 INNER JOIN movies2actors AS T2 ON T1.movieid = T2.movieid GROUP BY T1.movieid HAVING AVG(T1.rating) = (SELECT AVG(T3.rating) FROM u2base AS T3 INNER JOIN movies2actors AS T4 ON T3.movieid = T4.movieid GROUP BY T3.movieid ORDER BY AVG(T3.rating) DESC LIMIT 1))"} {"question_id": 2339, "db_id": "movielens", "grading_method": "set", "question": "How many female actors appeared in movie 2312852, and what are the movie's recorded country and running time?", "evidence": "Female actors are identified by actors.a_gender = 'F'. Country and running time are recorded in movies.country and movies.runningtime.", "SQL": "SELECT SUM(IIF(T1.a_gender = 'F', 1, 0)) , T3.country, T3.runningtime FROM actors AS T1 INNER JOIN movies2actors AS T2 ON T1.actorid = T2.actorid INNER JOIN movies AS T3 ON T2.movieid = T3.movieid WHERE T2.movieid = 2312852 GROUP BY T3.country, T3.runningtime"} {"question_id": 2345, "db_id": "superstore", "grading_method": "set", "question": "List the names of all products in order CA-2011-112326 in the Central region.", "evidence": "central_superstore records Central-region orders; product.\"Product Name\" records product names. Product identifiers are region-specific.", "SQL": "SELECT DISTINCT P.`Product Name`\nFROM `central_superstore` AS CS\nJOIN `product` AS P\n ON P.`Product ID` = CS.`Product ID`\n AND P.`Region` = 'Central' \nWHERE CS.`Order ID` = 'CA-2011-112326';"} {"question_id": 2348, "db_id": "superstore", "grading_method": "set", "question": "How many orders has Aimee Bixby made?", "evidence": "Aimee Bixby made refers to \"Customer Name\" = 'Aimee Bixby';", "SQL": "WITH all_orders AS (\n SELECT `Order ID`, `Customer ID`, `Region` FROM `central_superstore`\n UNION ALL\n SELECT `Order ID`, `Customer ID`, `Region` FROM `east_superstore`\n UNION ALL\n SELECT `Order ID`, `Customer ID`, `Region` FROM `west_superstore`\n UNION ALL\n SELECT `Order ID`, `Customer ID`, `Region` FROM `south_superstore`\n)\nSELECT COUNT(DISTINCT o.`Order ID`) AS total_orders\nFROM all_orders o\nJOIN people p\n ON o.`Customer ID` = p.`Customer ID`\n AND o.`Region` = p.`Region`\nWHERE p.`Customer Name` = 'Aimee Bixby';"} {"question_id": 2354, "db_id": "superstore", "grading_method": "set", "question": "Among the customers who have ordered the product \"Telescoping Adjustable Floor Lamp\", how many of them are consumers?", "evidence": "\"Telescoping Adjustable Floor Lamp\" is a \"Product Name\"; consumers refers to Segment = 'Consumer';", "SQL": "SELECT COUNT(DISTINCT p.`Customer ID`) AS consumer_cnt\nFROM people p\nJOIN (\n SELECT `Customer ID`, `Region` FROM west_superstore WHERE `Product ID` IN (SELECT `Product ID` FROM product WHERE `Product Name` = 'Telescoping Adjustable Floor Lamp')\n UNION ALL\n SELECT `Customer ID`, `Region` FROM east_superstore WHERE `Product ID` IN (SELECT `Product ID` FROM product WHERE `Product Name` = 'Telescoping Adjustable Floor Lamp')\n UNION ALL\n SELECT `Customer ID`, `Region` FROM south_superstore WHERE `Product ID` IN (SELECT `Product ID` FROM product WHERE `Product Name` = 'Telescoping Adjustable Floor Lamp')\n UNION ALL\n SELECT `Customer ID`, `Region` FROM central_superstore WHERE `Product ID` IN (SELECT `Product ID` FROM product WHERE `Product Name` = 'Telescoping Adjustable Floor Lamp')\n) o ON p.`Customer ID` = o.`Customer ID` AND p.`Region` = o.`Region`\nWHERE p.`Segment` = 'Consumer';"} {"question_id": 2361, "db_id": "superstore", "grading_method": "set", "question": "What is the name of the product that has the highest original price?", "evidence": "has the highest original price refers to MAX(DIVIDE(Sales, SUTRACT(1, discount))); name of the product refers to \"Product Name\"", "SQL": "WITH original_price AS (\n SELECT `Product ID` id, `Region` region, original_price price\n FROM (\n SELECT `Product ID`, `Region`, `Sales` / (1 - `Discount`) AS original_price FROM east_superstore\n UNION ALL\n SELECT `Product ID`, `Region`, `Sales` / (1 - `Discount`) FROM central_superstore\n UNION ALL\n SELECT `Product ID`, `Region`, `Sales` / (1 - `Discount`) FROM west_superstore\n UNION ALL\n SELECT `Product ID`, `Region`, `Sales` / (1 - `Discount`) FROM south_superstore\n)) SELECT DISTINCT p.`Product Name`\nFROM original_price t\nJOIN product p\n ON p.`Product ID` = t.id\n AND p.`Region` = t.`Region`\nWHERE t.price = (SELECT MAX(price) FROM original_price);"} {"question_id": 2362, "db_id": "superstore", "grading_method": "set", "question": "What are the names of the products that were ordered recently by Darren Powers?", "evidence": "Darren Powers is the \"Customer Name\"; name of the product refers to \"Product Name\"; recently refers to MAX(\"Order Date\")", "SQL": "WITH all_orders AS (SELECT `Order Date`, `Product ID`, `Region` FROM central_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM people WHERE `Customer Name` = 'Darren Powers') UNION ALL SELECT `Order Date`, `Product ID`, `Region` FROM east_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM people WHERE `Customer Name` = 'Darren Powers') UNION ALL SELECT `Order Date`, `Product ID`, `Region` FROM west_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM people WHERE `Customer Name` = 'Darren Powers') UNION ALL SELECT `Order Date`, `Product ID`, `Region` FROM south_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM people WHERE `Customer Name` = 'Darren Powers') ) SELECT p.`Product Name` FROM all_orders ao JOIN product p ON p.`Product ID` = ao.`Product ID` AND p.`Region` = ao.`Region` WHERE ao.`Order Date` = ( SELECT MAX(`Order Date`) FROM all_orders );"} {"question_id": 2368, "db_id": "superstore", "grading_method": "subset,=,10", "question": "Name 10 products that were shipped first class from the East region.", "evidence": "shipped first class refers to \"Ship Mode\" = 'First Class'; Region = 'East'", "SQL": "SELECT DISTINCT T2.`Product Name` FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Mode` = 'First Class' AND T2.Region = 'East'"} {"question_id": 2375, "db_id": "superstore", "grading_method": "set", "question": "How many items in total were shipped from the East region on March 25, 2015? After the total, list each product name once, in alphabetical order, separated by commas with no added spaces.", "evidence": "shipped on 3/25/2015 refers to \"Ship Date\" = Date('2015-03-25');", "SQL": "WITH selected AS (SELECT T1.Quantity, T2.`Product Name` AS product_name FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` AND T2.Region = 'East' WHERE T1.`Ship Date` = '2015-03-25') SELECT (SELECT SUM(Quantity) FROM selected) AS total_quantity, (SELECT GROUP_CONCAT(product_name, ',') FROM (SELECT DISTINCT product_name FROM selected WHERE product_name IS NOT NULL ORDER BY product_name)) AS products"} {"question_id": 2377, "db_id": "superstore", "grading_method": "set", "question": "What category does the item ordered by Katherine Murray on 11/4/2018 in the South region belong to?", "evidence": "ordered by Katherine Murray refers to \"Customer Name\" = 'Katherine Murray'; on 11/4/2018 refers to \"Order Date\" = Date('2018-11-04');", "SQL": "SELECT DISTINCT T3.Category FROM south_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` WHERE T2.`Customer Name` = 'Katherine Murray' AND T1.`Order Date` = '2018-11-04' AND T2.Region = 'South'"} {"question_id": 2392, "db_id": "superstore", "grading_method": "set", "question": "List the names of customers in the Eastern region who placed an order that cost the superstore more than 8,000.", "evidence": "An order’s cost is the total cost of its line items; each line item’s cost is Sales - Profit. Eastern region refers to order records with Region = 'East'; customer names refer to Customer Name.", "SQL": "WITH high_cost_orders AS (\n SELECT `Order ID`, `Customer ID`\n FROM `east_superstore`\n GROUP BY `Order ID`, `Customer ID`\n HAVING SUM(`Sales` - `Profit`) > 8000\n)\nSELECT DISTINCT p.`Customer Name`\nFROM high_cost_orders h\nJOIN `people` p\n ON h.`Customer ID` = p.`Customer ID` AND p.`Region` = 'East';"} {"question_id": 2393, "db_id": "superstore", "grading_method": "set", "question": "How many orders were made by Maxwell Schwartz in 2015?", "evidence": "Maxwell Schwartz is a customer name recorded in people.Customer Name. Order Date records when an order was placed.", "SQL": "SELECT COUNT(DISTINCT `Order ID`) AS num_orders\nFROM (\n SELECT `Order ID`, `Customer ID`, `Region` FROM `east_superstore` WHERE strftime('%Y',`Order Date`)='2015'\n UNION\n SELECT `Order ID`, `Customer ID`, `Region` FROM `west_superstore` WHERE strftime('%Y',`Order Date`)='2015'\n UNION\n SELECT `Order ID`, `Customer ID`, `Region` FROM `central_superstore` WHERE strftime('%Y',`Order Date`)='2015'\n UNION\n SELECT `Order ID`, `Customer ID`, `Region` FROM `south_superstore` WHERE strftime('%Y',`Order Date`)='2015'\n) t JOIN people ON people.`Customer ID` = t.`Customer ID` AND people.`Region` = t.`Region`\nWHERE people.`Customer Name` = 'Maxwell Schwartz'"} {"question_id": 2398, "db_id": "superstore", "grading_method": "set", "question": "List the numbers of orders from the Eastern and Western stores in 2015 in two columns, respectively.", "evidence": "in 2015 refers to strftime('%Y', \"Order Date\") = '2015'; Eastern store refers to east_superstore; Western store refers west_superstore;", "SQL": "SELECT\n (SELECT COUNT(DISTINCT `Order ID`) FROM east_superstore WHERE strftime('%Y', `Order Date`) = '2015') AS east_orders,\n (SELECT COUNT(DISTINCT `Order ID`) FROM west_superstore WHERE strftime('%Y', `Order Date`) = '2015') AS west_orders;"} {"question_id": 2399, "db_id": "superstore", "grading_method": "set", "question": "List the products ordered by Matt Abelman from the Western store in 2013.", "evidence": "ordered by Matt Abelman refers to \"Customer Name\" = 'Matt Abelman'; in 2013 refers to \"Order Date\" like '2013%'", "SQL": "SELECT DISTINCT T3.`Product Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` AND T3.Region = T1.Region WHERE T2.`Customer Name` = 'Matt Abelman' AND STRFTIME('%Y', T1.`Order Date`) = '2013'"} {"question_id": 2400, "db_id": "superstore", "grading_method": "set", "question": "Calculate the total superstore's cost of the orders by Brad Thomas in 2016.", "evidence": "Brad Thomas is the \"Customer Name\"; in 2016 refers to strftime('%Y', \"Order Date\") = '2016'; total cost refers to SUM(SUTRACT(MULTIPLY(DIVIDE(Sales, SUTRACT(1, discount)), Quantity), Profit))", "SQL": "WITH all_superstores AS (\n SELECT *\n FROM (\n SELECT * FROM `east_superstore` WHERE strftime('%Y', `Order Date`) = '2016'\n UNION\n SELECT * FROM `west_superstore` WHERE strftime('%Y', `Order Date`) = '2016'\n UNION\n SELECT * FROM `central_superstore` WHERE strftime('%Y', `Order Date`) = '2016'\n UNION\n SELECT * FROM `south_superstore` WHERE strftime('%Y', `Order Date`) = '2016'\n ) t\n) SELECT SUM((T1.Sales / (1 - T1.Discount)) * T1.Quantity - T1.Profit) AS cost FROM all_superstores AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` AND T1.Region = T2.Region INNER JOIN product AS T3 ON T1.`Product ID` = T3.`Product ID` AND T1.Region = T3.Region WHERE T2.`Customer Name` = 'Brad Thomas'"} {"question_id": 2407, "db_id": "superstore", "grading_method": "set", "question": "List the name of all products in the west superstore that customers chose for same-day shipment in the year 2013.", "evidence": "product.Product Name records product names; product IDs are region-specific. west_superstore.Ship Mode uses 'Same Day', and Ship Date records the shipping date.", "SQL": "SELECT DISTINCT P.`Product Name` FROM west_superstore AS W JOIN product AS P ON W.`Product ID` = P.`Product ID` AND P.`Region` = 'West' WHERE W.`Ship Mode` = 'Same Day' AND W.`Ship Date` >= '2013-01-01' AND W.`Ship Date` < '2014-01-01';"} {"question_id": 2409, "db_id": "superstore", "grading_method": "set", "question": "How many \"Lexmark X 9575 Professional All-in-One Color Printer\" units did Cindy Stewart order in the South region?", "evidence": "Customer and product names are recorded in people.\"Customer Name\" and product.\"Product Name\". Their IDs are region-specific. south_superstore contains South-region order lines; south_superstore.Quantity records units ordered.", "SQL": "SELECT SUM(s.`Quantity`) AS total_quantity\nFROM `south_superstore` AS s\nJOIN `people` p ON p.`Customer ID` = s.`Customer ID`\n AND p.`Region` = s.`Region`\nJOIN `product` pr ON pr.`Product ID` = s.`Product ID`\n AND pr.`Region` = s.`Region`\nWHERE p.`Customer Name` = 'Cindy Stewart'\n AND pr.`Product Name` = 'Lexmark X 9575 Professional All-in-One Color Printer';"} {"question_id": 2412, "db_id": "superstore", "grading_method": "set", "question": "What is the total profit from \"Memorex Froggy Flash Drive 8 GB\" sales in the South region?", "evidence": "Product names are recorded in product.\"Product Name\"; product IDs are region-specific. south_superstore.Profit is profit per order line; negative values are losses.", "SQL": "SELECT SUM(s.`Profit`) AS total_profit FROM `south_superstore` AS s JOIN `product` AS p ON s.`Product ID` = p.`Product ID` AND p.`Region` = 'South' WHERE p.`Product Name` = 'Memorex Froggy Flash Drive 8 GB';"} {"question_id": 2415, "db_id": "superstore", "grading_method": "set", "question": "Of all units ordered from the Central and South superstores, what percentage were Office Supplies products?", "evidence": "units refers to Quantity on an order line; Office Supplies refers to Category = 'Office Supplies'; percentage = DIVIDE(SUM(Quantity on the Office Supplies lines), SUM(Quantity on all those lines)) * 100, over the combined Central and South order lines matched to products by Product ID and Region", "SQL": "SELECT\n 100.0 * SUM(CASE WHEN p.`Category` = 'Office Supplies' THEN s.Quantity ELSE 0 END) / SUM(s.Quantity) AS pct_office_supplies\nFROM (\n SELECT `Product ID`, `Region`, Quantity FROM `central_superstore`\n UNION ALL\n SELECT `Product ID`, `Region`, Quantity FROM `south_superstore`\n) s\nJOIN `product` p\n ON p.`Product ID` = s.`Product ID`\n AND p.`Region` = s.`Region`;"} {"question_id": 2417, "db_id": "superstore", "grading_method": "set", "question": "Which Art products appear on the most order lines in the Central superstore? List their names.", "evidence": "Art products refers to product.`Sub-Category` = 'Art' with product.Region = 'Central', matched to central_superstore rows on `Product ID`; order lines for a product refers to COUNT(*) of those rows grouped by product.`Product ID`; return the `Product Name` of every product whose count equals the maximum, ties included", "SQL": "SELECT p.`Product Name` FROM `central_superstore` cs JOIN `product` p ON cs.`Product ID` = p.`Product ID` AND p.`Region` = 'Central' WHERE p.`Sub-Category` = 'Art' GROUP BY p.`Product ID` HAVING COUNT(*) = (SELECT COUNT(*) FROM `central_superstore` cs JOIN `product` p ON cs.`Product ID` = p.`Product ID` AND p.`Region` = 'Central' WHERE p.`Sub-Category` = 'Art' GROUP BY p.`Product ID` ORDER BY COUNT(*) DESC LIMIT 1)"} {"question_id": 2435, "db_id": "superstore", "grading_method": "set", "question": "How many orders purchased by Aaron Bergman have been delivered with the slowest shipping speed?", "evidence": "slowest shipping speed refers to \"Ship Mode\" = 'Standard Class'", "SQL": "WITH bergman AS (\n SELECT `Customer ID`\n FROM people\n WHERE `Customer Name` = 'Aaron Bergman'\n), all_orders AS (\n SELECT DISTINCT `Order ID`\n FROM central_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM bergman) AND `Ship Mode` = 'Standard Class'\n UNION\n SELECT DISTINCT `Order ID`\n FROM west_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM bergman) AND `Ship Mode` = 'Standard Class'\n UNION\n SELECT DISTINCT `Order ID`\n FROM east_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM bergman) AND `Ship Mode` = 'Standard Class'\n UNION\n SELECT DISTINCT `Order ID`\n FROM south_superstore WHERE `Customer ID` IN (SELECT `Customer ID` FROM bergman) AND `Ship Mode` = 'Standard Class'\n)\nSELECT COUNT(*) AS orders_with_slowest_shipping\nFROM all_orders;"} {"question_id": 2441, "db_id": "superstore", "grading_method": "set", "question": "How many furniture product units were ordered at central superstore?", "evidence": "product.Category uses 'Furniture'; central_superstore.Quantity records units on an order line. Product IDs are region-specific.", "SQL": "SELECT SUM(T1.Quantity) FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Category = 'Furniture' AND T2.Region = 'Central'"} {"question_id": 2444, "db_id": "superstore", "grading_method": "set", "question": "How many orders were made by Alan Barnes in 2015 at the Central superstore?", "evidence": "in 2015 refers to \"Order Date\" = '2015%'", "SQL": "SELECT COUNT(DISTINCT T2.`Order ID`) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Customer Name` = 'Alan Barnes' AND STRFTIME('%Y', T2.`Order Date`) = '2015'"} {"question_id": 2446, "db_id": "superstore", "grading_method": "set", "question": "Of the Central superstore orders containing at least one item discounted by 20%, what percentage were placed by customers living in Texas?", "evidence": "central_superstore.Discount = 0.2 denotes a 20% line discount. people.State records 'Texas'; customer IDs are region-specific.", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN p.`State` = 'Texas' THEN cs.`Order ID` END) / COUNT(DISTINCT cs.`Order ID`) AS percentage_texas FROM central_superstore cs JOIN people p ON p.`Customer ID` = cs.`Customer ID` AND p.`Region` = cs.`Region` WHERE cs.`Discount` = 0.2"} {"question_id": 2453, "db_id": "superstore", "grading_method": "set", "question": "Who is the customer with an order shipped on March 5, 2013, in the eastern region?", "evidence": "Who is the customer refers to Customer Name; shipped on March 5, 2013 refers to \"Ship Date\" = '2013-03-05'; eastern region refers to Region = 'East'", "SQL": "SELECT DISTINCT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Ship Date` = '2013-03-05'"} {"question_id": 2455, "db_id": "superstore", "grading_method": "set", "question": "Who ordered the order ID CA-2011-118976 from the East region?", "evidence": "Who refers to \"Customer Name\"", "SQL": "SELECT DISTINCT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Order ID` = 'CA-2011-118976' AND T2.Region = 'East'"} {"question_id": 2463, "db_id": "shooting", "grading_method": "set", "question": "In which year were the most cases involving a handgun recorded?", "evidence": "incidents.subject_weapon records the weapon, including 'Handgun'; incidents.date records the incident date.", "SQL": "SELECT year\nFROM (\n SELECT SUBSTR(`date`,1,4) AS year,\n COUNT(*) AS cnt\n FROM incidents\n WHERE `subject_weapon` = 'Handgun'\n GROUP BY year\n)\nWHERE cnt = (\n SELECT MAX(cnt)\n FROM (\n SELECT COUNT(*) AS cnt\n FROM incidents\n WHERE `subject_weapon` = 'Handgun'\n GROUP BY SUBSTR(`date`,1,4)\n )\n);"} {"question_id": 2465, "db_id": "shooting", "grading_method": "set", "question": "Did the number of cases with Vehicle as subject weapon increase or decrease from year 2007 to 2008. State the difference.", "evidence": "number of cases refers to count(case_number); with Vehicle as subject weapon refers to subject_weapon = 'Vehicle'; year 2007 refers to date between '2007-01-01' and '2007-12-31'; year 2008 refers to date between '2008-01-01' and '2008-12-31'", "SQL": "SELECT (SELECT COUNT(*) FROM `incidents` WHERE `subject_weapon` = 'Vehicle' AND SUBSTR(`date`,1,4) = '2008') - (SELECT COUNT(*) FROM `incidents` WHERE `subject_weapon` = 'Vehicle' AND SUBSTR(`date`,1,4) = '2007') AS difference;"} {"question_id": 2473, "db_id": "shooting", "grading_method": "set", "question": "What is the percentage of female subjects who used the Vehicle as weapon?", "evidence": "female refers to gender = 'F'; use Vehicle as weapon refers to subject_weapon = 'Vehicle'; percentage = divide(count(case_number where subject_weapon = 'Vehicle'), count(case_number)) where gender = 'F' * 100%", "SQL": "SELECT CAST(SUM(T1.subject_weapon = 'Vehicle') AS REAL) * 100 / COUNT(T1.case_number) FROM incidents T1 INNER JOIN subjects T2 ON T1.case_number = T2.case_number WHERE T2.gender = 'F'"} {"question_id": 2476, "db_id": "shooting", "grading_method": "set", "question": "Of all male officers, what percentage are black officers? Round your answer to 1 decimal place.", "evidence": "male officers refers to officers.gender = 'M'; officers may appear more than once, so take each full_name with its race once; black officers refers to race = 'B'; percentage = DIVIDE(COUNT(those officers with race = 'B'), COUNT(those male officers)) * 100, ROUND to 1 decimal place", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(race = 'B') / COUNT(*) AS pct_black_male_officers\nFROM (\n SELECT DISTINCT `full_name`, `race`\n FROM `officers`\n WHERE `gender` = 'M'\n)\n) SELECT ROUND(value, 1) FROM unrounded;"} {"question_id": 2479, "db_id": "shooting", "grading_method": "set", "question": "How many different Black officer names appear on cases recorded from 2010 through 2015?", "evidence": "officers.race = 'B' denotes Black officers. officers.full_name records officer names; case_number links officers to incidents. incidents.date uses year/month/day text.", "SQL": "SELECT COUNT(DISTINCT o.full_name) FROM officers o JOIN incidents i ON o.case_number=i.case_number WHERE o.race='B' AND SUBSTR(i.date,1,4) BETWEEN '2010' AND '2015'"} {"question_id": 2483, "db_id": "shooting", "grading_method": "set", "question": "What is the proportion of white males and females in the police force?", "evidence": "white refers to race = 'W'; male refers to gender = 'M'; female refers to gender = 'F'; proportion of white males = divide(count(officers where race = 'W' and gender = 'M'), count(officers)) * 100%; proportion of white females = divide(count(officers where race = 'W' and gender = 'F'), count(officers)) * 100%", "SQL": "SELECT 100.0 * SUM(CASE WHEN race = 'W' AND gender = 'M' THEN 1 ELSE 0 END) / COUNT(*) AS proportion_white_males, 100.0 * SUM(CASE WHEN race = 'W' AND gender = 'F' THEN 1 ELSE 0 END) / COUNT(*) AS proportion_white_females FROM officers"} {"question_id": 2484, "db_id": "shooting", "grading_method": "set", "question": "How many more black female victims than white female victims were discovered?", "evidence": "black refers to race = 'B'; female refers to gender = 'F'; white refers to race = 'W'; result = subtract(count(victims where race = 'B'), count(victims where race = 'W')) where gender = 'F'", "SQL": "SELECT SUM(race = 'B') - SUM(race = 'W') FROM subjects WHERE gender = 'F'"} {"question_id": 2496, "db_id": "genes", "grading_method": "set", "question": "What is the highest expression correlation score among gene pairs with one gene on chromosome 9 and the other on chromosome 6?", "evidence": "Interactions.GeneID1 and Interactions.GeneID2 identify the two members of a gene pair. Interactions.Expression_Corr is their expression correlation score.", "SQL": "SELECT MAX(I.`Expression_Corr`)\nFROM `Interactions` AS I\nJOIN `Genes` AS G1 ON G1.`GeneID` = I.`GeneID1`\nJOIN `Genes` AS G2 ON G2.`GeneID` = I.`GeneID2`\nWHERE (G1.`Chromosome` = '9' AND G2.`Chromosome` = '6')\n OR (G1.`Chromosome` = '6' AND G2.`Chromosome` = '9');"} {"question_id": 2497, "db_id": "genes", "grading_method": "set", "question": "Please list the motif of the genes that are located in the cytoplasm and have 7 chromosomes.", "evidence": "", "SQL": "SELECT DISTINCT `Motif`\nFROM `Genes`\nWHERE `Localization` = 'cytoplasm'\n AND `Chromosome` = 7;"} {"question_id": 2505, "db_id": "genes", "grading_method": "set", "question": "Among genes recorded in the cytoskeleton, what percentage have an unknown class? Round to two decimal places. Of the genes with an unknown class, how many have no recorded conditional phenotype?", "evidence": "in the cytoskeleton refers to Genes.Localization = 'cytoskeleton'; a gene is one DISTINCT GeneID and has unknown class if any of its cytoskeleton records has Class IN ('Unknown','?'); percentage = ROUND(DIVIDE(COUNT(unknown-class genes), COUNT(genes)) * 100, 2); also return how many of those unknown-class genes have no cytoskeleton record with Phenotype = 'Conditional phenotypes'", "SQL": "WITH cytoskel AS (\n SELECT `GeneID`,\n MAX(CASE WHEN `Class` IN ('Unknown','?') THEN 1 ELSE 0 END) AS is_unknown,\n MAX(CASE WHEN `Phenotype`='Conditional phenotypes' THEN 1 ELSE 0 END) AS is_conditional\n FROM `Genes`\n WHERE `Localization`='cytoskeleton'\n GROUP BY `GeneID`\n)\nSELECT\n ROUND(100.0 * SUM(is_unknown) / COUNT(*), 2) AS pct_unknown_class,\n SUM(CASE WHEN is_unknown=1 AND is_conditional=0 THEN 1 END) AS not_conditional_unknown\nFROM cytoskel;"} {"question_id": 2508, "db_id": "genes", "grading_method": "set", "question": "Taking all the essential genes of the transcription factors class located in the nucleus as a reference, list the ids of all the reference genes that carry out a genetic-type interaction with another gene.", "evidence": "", "SQL": "WITH nuc_ess_tf AS (\n SELECT DISTINCT `GeneID`\n FROM `Genes`\n WHERE `Localization` = 'nucleus'\n AND `Class` = 'Transcription factors'\n AND `Essential` = 'Essential'\n)\nSELECT DISTINCT e.`GeneID`\nFROM nuc_ess_tf e\nJOIN `Interactions` i\n ON (i.`GeneID1` = e.`GeneID` OR i.`GeneID2` = e.`GeneID`)\nWHERE i.`Type` LIKE 'Genetic%';"} {"question_id": 2510, "db_id": "genes", "grading_method": "set", "question": "Among genes with the phenotype “Nucleic acid metabolism defects” and motif PS00107, what percentage have a positive interaction with another gene?", "evidence": "the population refers to the DISTINCT genes with Genes.Phenotype = 'Nucleic acid metabolism defects' AND Genes.Motif = 'PS00107'; a positive interaction with another gene refers to an Interactions record for that gene with Expression_Corr > 0; percentage = DIVIDE(COUNT(DISTINCT genes in the population that have at least one such positive interaction), COUNT(DISTINCT genes in the population)) * 100", "SQL": "WITH target_genes AS ( SELECT DISTINCT `GeneID` FROM `Genes` WHERE `Phenotype` = 'Nucleic acid metabolism defects' AND `Motif` = 'PS00107' ), genes_with_positive AS ( SELECT DISTINCT tg.`GeneID` FROM target_genes tg JOIN `Interactions` i ON i.`GeneID1` = tg.`GeneID` OR i.`GeneID2` = tg.`GeneID` WHERE i.`Expression_Corr` > 0 ) SELECT (SELECT COUNT(*) FROM genes_with_positive) * 100.0 / (SELECT COUNT(*) FROM target_genes) AS percentage_positive_genes;"} {"question_id": 2515, "db_id": "app_store", "grading_method": "set", "question": "Which app name and category have the most user reviews with a sentiment polarity score of -1?", "evidence": "a sentiment polarity score of -1 refers to user_reviews.Sentiment_Polarity = '-1.0' stored as text; the most user reviews refers to the apps whose COUNT of such reviews equals the maximum over all apps, keeping every tied app; return both the app name playstore.App and its playstore.Category", "SQL": "WITH counts AS (\n SELECT `App`, COUNT(*) AS cnt\n FROM user_reviews\n WHERE `Sentiment_Polarity` = '-1.0'\n GROUP BY `App`\n),\nmaxcnt AS (\n SELECT MAX(cnt) AS max_cnt FROM counts\n)\nSELECT DISTINCT p.`App`, p.`Category`\nFROM counts c\nJOIN maxcnt m ON c.cnt = m.max_cnt\nJOIN playstore p ON p.`App` = c.`App`;"} {"question_id": 2517, "db_id": "app_store", "grading_method": "set", "question": "What is the lowest sentiment polarity score of the Basketball Stars app for people who dislikes the app pretty much and how many downloads does it have?", "evidence": "lowest sentiment polarity score refers to MIN(Sentiment_Polarity); user dislike the app pretty much refers to Sentiment_Polarity<-0.5; number of downloads it has refers to installs;", "SQL": "SELECT MIN(CAST(`Sentiment_Polarity` AS REAL)) AS lowest_sentiment_polarity, (SELECT `Installs` FROM `playstore` WHERE `App` = 'Basketball Stars') AS installs FROM `user_reviews` WHERE `App` = 'Basketball Stars' AND CAST(`Sentiment_Polarity` AS REAL) < -0.5"} {"question_id": 2518, "db_id": "app_store", "grading_method": "set", "question": "How many Akinator app reviews have a recorded sentiment subjectivity score of 0.5 or lower?", "evidence": "Sentiment subjectivity is recorded in Sentiment_Subjectivity; 'nan' indicates that no score is available.", "SQL": "SELECT COUNT(*) AS review_cnt\nFROM `user_reviews`\nWHERE `App` = 'Akinator'\n AND Sentiment_Subjectivity <> 'nan' AND CAST(`Sentiment_Subjectivity` AS REAL) <= 0.5;"} {"question_id": 2519, "db_id": "app_store", "grading_method": "set", "question": "How many apps have rating of 5?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT App) FROM playstore WHERE Rating = 5"} {"question_id": 2526, "db_id": "app_store", "grading_method": "set", "question": "For each app with multiple genres and at least one recorded numeric subjectivity score, what is the total sentiment subjectivity of its reviews?", "evidence": "multiple genres refers to an app with at least one playstore row whose Genres contains a semicolon, including repeated labels; total sentiment subjectivity refers to SUM(CAST(Sentiment_Subjectivity AS REAL)) over that app's stored review rows, excluding the literal 'nan', with separate review rows of identical contents counted separately; return each such app with at least one numeric subjectivity score and its total", "SQL": "SELECT T1.App, SUM(CAST(T1.Sentiment_Subjectivity AS REAL)) FROM user_reviews AS T1 WHERE T1.Sentiment_Subjectivity <> 'nan' AND EXISTS (SELECT 1 FROM playstore AS T2 WHERE T2.App = T1.App AND T2.Genres LIKE '%;%') GROUP BY T1.App"} {"question_id": 2532, "db_id": "app_store", "grading_method": "set", "question": "How many of the reviews for the app \"Brit + Co\" have a comment?", "evidence": "Brit + Co refers to App = 'Brit + Co'; comment refers to Translated Review NOT null AND <> 'nan'", "SQL": "SELECT COUNT(*)\nFROM `user_reviews`\nWHERE `App` = 'Brit + Co'\n AND `Translated_Review` IS NOT NULL\n AND `Translated_Review` <> 'nan';"} {"question_id": 2533, "db_id": "app_store", "grading_method": "set", "question": "List the top 5 shopping apps with the most reviews.", "evidence": "shopping apps refers to Genre = 'Shopping'; most reviews refers to MAX(Reviews);", "SQL": "SELECT `App`\nFROM `playstore`\nWHERE `Genres` = 'Shopping' \nGROUP BY `App`\nORDER BY `Reviews` DESC\nLIMIT 5;"} {"question_id": 2534, "db_id": "app_store", "grading_method": "set", "question": "How many neutral reviews does the app \"Dino War: Rise of Beasts\" have?", "evidence": "neutral reviews refers to Sentiment = 'Neutral';", "SQL": "SELECT COUNT(App) FROM user_reviews WHERE App = 'Dino War: Rise of Beasts' AND Sentiment = 'Neutral'"} {"question_id": 2535, "db_id": "app_store", "grading_method": "set", "question": "What are the apps tagged with 5,000+ installs?", "evidence": "Installs = '5,000+';", "SQL": "SELECT DISTINCT App FROM playstore WHERE Installs = '5,000+'"} {"question_id": 2537, "db_id": "app_store", "grading_method": "set", "question": "Which free app has the most Negative comments?", "evidence": "free app refers to Type = 'Free'; negative comment refers to Sentiment = 'Negative'; free app with most negative comments refers to MAX(COUNT(Sentiment = 'Negative')) where Type = 'Free';", "SQL": "SELECT u.`App`\nFROM `user_reviews` AS u\nJOIN (\n SELECT DISTINCT `App`\n FROM `playstore`\n WHERE `Type` = 'Free'\n ) AS p\n ON u.`App` = p.`App`\nWHERE u.`Sentiment` = 'Negative'\nGROUP BY u.`App`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 2541, "db_id": "app_store", "grading_method": "set", "question": "What is the rating for \"Garden Coloring Book\"? List all of its reviews.", "evidence": "Garden Coloring Book refers to App = 'Garden Coloring Book'; review refers to Translated_Review;", "SQL": "SELECT T1.Rating, T2.Translated_Review FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Garden Coloring Book'"} {"question_id": 2542, "db_id": "app_store", "grading_method": "set", "question": "Which Photography app has the highest total Sentiment subjectivity score?", "evidence": "playstore.Genres = 'Photography' identifies photography apps. user_reviews.Sentiment_Subjectivity records review subjectivity; playstore can have multiple catalog rows for an app.", "SQL": "WITH photography_apps AS (\n SELECT DISTINCT `App`\n FROM playstore\n WHERE `Genres` = 'Photography'\n)\nSELECT ur.`App`\nFROM user_reviews ur\nJOIN photography_apps pa ON pa.`App` = ur.`App`\nGROUP BY ur.`App`\nORDER BY SUM(CAST(ur.`Sentiment_Subjectivity` AS REAL)) DESC\nLIMIT 1;"} {"question_id": 2548, "db_id": "app_store", "grading_method": "set", "question": "What percentage of no comment reviews are from \"Teen\" content rating apps?", "evidence": "no comment refers to Translated_Review = 'nan'; percentage = DIVIDE((SUM(Content Rating = 'Teen')), COUNT(*)) * 100;", "SQL": "SELECT 100.0 * SUM(CASE WHEN p.`Content Rating` = 'Teen' THEN 1 ELSE 0 END) / COUNT(*) AS pct_no_comment_from_teen\nFROM `user_reviews` u\nJOIN (SELECT DISTINCT `App`, `Content Rating` FROM `playstore`) p\n ON p.`App` = u.`App`\nWHERE u.`Translated_Review` = 'nan';"} {"question_id": 2551, "db_id": "app_store", "grading_method": "set", "question": "List the genres of apps with at least one billion installs.", "evidence": "playstore.Installs stores text bands such as '1,000,000,000+', rather than exact install counts. '1,000,000,000+' is the highest band tracked.", "SQL": "SELECT Genres FROM playstore WHERE Installs = '1,000,000,000+' GROUP BY Genres"} {"question_id": 2556, "db_id": "app_store", "grading_method": "set", "question": "Among apps rated 4.7, what percentage have more positive than negative user reviews?", "evidence": "apps rated 4.7 refers to the DISTINCT app with playstore.Rating = 4.7; more positive than negative user reviews refers to an app whose count of user_reviews.Sentiment = 'Positive' is greater than its count of Sentiment = 'Negative'; percentage = DIVIDE(the apps rated 4.7 with more positive than negative, all apps rated 4.7) * 100", "SQL": "WITH posneg AS (\n SELECT `App`,\n SUM(CASE WHEN `Sentiment` = 'Positive' THEN 1 ELSE 0 END) AS pos_cnt,\n SUM(CASE WHEN `Sentiment` = 'Negative' THEN 1 ELSE 0 END) AS neg_cnt\n FROM `user_reviews`\n GROUP BY `App`\n),\napps AS (\n SELECT DISTINCT `App`\n FROM `playstore`\n WHERE `Rating` = 4.7\n)\nSELECT 100.0 * SUM(CASE WHEN COALESCE(pos_cnt,0) > COALESCE(neg_cnt,0) THEN 1 ELSE 0 END)\n / COUNT(*) AS percentage\nFROM apps\nLEFT JOIN posneg USING (`App`);"} {"question_id": 2557, "db_id": "app_store", "grading_method": "set", "question": "Which apps listed in the app catalog have at least one positive or neutral review and no negative reviews? Give each app’s name and average recorded app rating.", "evidence": "at least one positive or neutral review and no negative reviews refers to an App in user_reviews whose Sentiment values include 'Positive' or 'Neutral' and never 'Negative', ignoring 'nan'; return both the App name and AVG(playstore.Rating) over that app's catalog records, grouped by App", "SQL": "WITH eligible_apps AS (\n SELECT App FROM user_reviews\n WHERE Sentiment IN ('Positive', 'Neutral', 'Negative')\n GROUP BY App\n HAVING SUM(CASE WHEN Sentiment = 'Negative' THEN 1 ELSE 0 END) = 0\n)\nSELECT p.App, AVG(p.Rating) AS average_rating\nFROM playstore AS p\nJOIN eligible_apps AS e ON e.App = p.App\nGROUP BY p.App;"} {"question_id": 2562, "db_id": "app_store", "grading_method": "set", "question": "What is the average price of games in the arcade genre with a content rating of Everyone 10+?", "evidence": "Game prices are recorded in playstore.Price. The arcade genre is labeled 'Arcade' in playstore.Genres; the content rating is 'Everyone 10+' in playstore.\"Content Rating\". playstore.Genres can contain multiple genres separated by semicolons. An app can have multiple catalog rows.", "SQL": "SELECT AVG(price) AS avg_price\nFROM (\n SELECT CAST(REPLACE(`Price`, '$', '') AS REAL) price\n FROM playstore\n WHERE `Content Rating` = 'Everyone 10+'\n AND `Genres` LIKE '%Arcade%'\n GROUP BY App\n)"} {"question_id": 2563, "db_id": "app_store", "grading_method": "set", "question": "What is the size of Browser 4G, and how many of its reviews have a sentiment polarity score of at least 0.5?", "evidence": "Browser 4G is recorded in playstore.App as 'Browser 4G'; playstore.Size records its size. Review sentiment polarity is recorded in user_reviews.Sentiment_Polarity.", "SQL": "SELECT DISTINCT p.`Size`, r.positive_cnt\nFROM `playstore` AS p\nCROSS JOIN (\n SELECT COUNT(*) AS positive_cnt\n FROM `user_reviews`\n WHERE `App` = 'Browser 4G'\n AND CAST(`Sentiment_Polarity` AS REAL) >= 0.5\n) AS r\nWHERE p.`App` = 'Browser 4G';"} {"question_id": 2565, "db_id": "app_store", "grading_method": "set", "question": "What is the average review sentiment polarity for Golf GPS Rangefinder: Golf Pad, and what is its Google Play Store rating?", "evidence": "App names are recorded in playstore.App and user_reviews.App. user_reviews.Sentiment_Polarity is a review’s sentiment score; the text 'nan' represents missing data. playstore.Rating is the recorded app rating.", "SQL": "SELECT AVG(CAST(`Sentiment_Polarity` AS REAL)) AS avg_sentiment,\n `Rating`\nFROM `playstore` p\nJOIN `user_reviews` u ON p.`App` = u.`App`\nWHERE p.`App` = 'Golf GPS Rangefinder: Golf Pad'\n AND u.`Sentiment_Polarity` <> 'nan'\nGROUP BY `Rating`;"} {"question_id": 2569, "db_id": "app_store", "grading_method": "set", "question": "For the Honkai Impact 3rd App, what is the highest sentiment polarity score and what genre does it belong to?", "evidence": "highest sentiment polarity score refers to MAX(Sentiment_Polarity);", "SQL": "SELECT MAX(CAST(ur.`Sentiment_Polarity` AS REAL)) AS max_polarity,\n p.`Genres`\nFROM playstore AS p\nJOIN user_reviews AS ur ON p.`App` = ur.`App`\nWHERE p.`App` = 'Honkai Impact 3rd'\n AND ur.`Sentiment_Polarity` != 'nan'\nGROUP BY p.`Genres`;"} {"question_id": 2571, "db_id": "app_store", "grading_method": "set", "question": "Which education app has the lowest rating?", "evidence": "Education apps have playstore.Category = 'EDUCATION'; playstore.Rating records the app rating.", "SQL": "SELECT `App`\nFROM `playstore`\nWHERE `Category` = 'EDUCATION'\nAND Rating = (SELECT MIN(Rating) FROM playstore WHERE Category = 'EDUCATION' AND Rating IS NOT NULL)"} {"question_id": 2572, "db_id": "app_store", "grading_method": "set", "question": "List all free sports Apps", "evidence": "free sports Apps refers to type = 'Free' and Category = 'SPORTS';", "SQL": "SELECT DISTINCT p.`App`\nFROM `playstore` AS p\nWHERE p.`Type` = 'Free'\n AND p.`Category` = 'SPORTS';"} {"question_id": 2576, "db_id": "regional_sales", "grading_method": "set", "question": "List all the customers with name containing the word 'Group'.", "evidence": "name containing the word 'Group' refers to Customer Names LIKE '%Group%';", "SQL": "SELECT T FROM ( SELECT IIF(`Customer Names` LIKE '%Group%', `Customer Names`, NULL) AS T FROM Customers ) WHERE T IS NOT NULL"} {"question_id": 2579, "db_id": "regional_sales", "grading_method": "set", "question": "List all the order numbers along with its product name for each order under the sales team of 'Douglas Tucker'.", "evidence": "", "SQL": "SELECT DISTINCT T2.OrderNumber, T1.`Product Name` FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID WHERE T3.`Sales Team` = 'Douglas Tucker'"} {"question_id": 2580, "db_id": "regional_sales", "grading_method": "set", "question": "Among orders in 2020, name the customers who had the greatest discount applied for 'Cocktail Glasses'", "evidence": "MAX(Discount Applied) where Product Name = 'Cocktail Glasses'; orders in 2020 refer to the OrderDate between 01-01-2020 and 31-12-2020;", "SQL": "SELECT DISTINCT T1.`Customer Names` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN Products AS T3 ON T3.ProductID = T2._ProductID WHERE T3.`Product Name` = 'Cocktail Glasses' AND SUBSTR(T2.OrderDate, -2) = '20' AND T2.`Discount Applied` = ( SELECT T2.`Discount Applied` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN Products AS T3 ON T3.ProductID = T2._ProductID WHERE T3.`Product Name` = 'Cocktail Glasses' AND T2.OrderDate LIKE '%/%/20' ORDER BY T2.`Discount Applied` DESC LIMIT 1 )"} {"question_id": 2582, "db_id": "regional_sales", "grading_method": "set", "question": "List the order numbers, customer names, and order dates for orders with the highest unit cost.", "evidence": "Sales Orders.\"Unit Cost\" records unit cost, with commas used as thousands separators. Customer names are recorded in Customers.\"Customer Names\".", "SQL": "SELECT so.`OrderNumber`,\n c.`Customer Names`,\n so.`OrderDate`\nFROM `Sales Orders` AS so\nJOIN `Customers` AS c\n ON c.`CustomerID` = so.`_CustomerID`\nWHERE CAST(REPLACE(so.`Unit Cost`, ',', '') AS REAL) = (\n SELECT MAX(CAST(REPLACE(`Unit Cost`, ',', '') AS REAL))\n FROM `Sales Orders`);"} {"question_id": 2587, "db_id": "regional_sales", "grading_method": "set", "question": "What is the name of the sales team whose orders had the greatest net profit in 2020?", "evidence": "net profit of an order refers to MULTIPLY(SUBTRACT(\"Unit Price\", \"Unit Cost\"), \"Order Quantity\") with thousands commas removed from the two amounts; in 2020 refers to OrderDate LIKE '%/%/20'; return \"Sales Team\".\"Sales Team\" whose SUM of that net profit is the greatest, including ties", "SQL": "WITH team_profit AS (\n SELECT st.`Sales Team` team, SUM( (REPLACE(so.`Unit Price`, ',', '') -\n REPLACE(so.`Unit Cost`, ',', '') ) * so.`Order Quantity` ) profit\n FROM `Sales Orders` so\n JOIN `Sales Team` st ON st.`SalesTeamID` = so.`_SalesTeamID`\n WHERE so.`OrderDate` LIKE '%/%/20'\n GROUP BY st.`Sales Team`\n) SELECT team FROM team_profit WHERE profit = (SELECT MAX(profit) FROm team_profit)"} {"question_id": 2594, "db_id": "regional_sales", "grading_method": "set", "question": "Describe the ID, city and region of the stores which are in Allen country.", "evidence": "ID refers to StoreID;", "SQL": "SELECT DISTINCT T2.StoreID, T2.`City Name`, T1.Region FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.County = 'Allen County'"} {"question_id": 2597, "db_id": "regional_sales", "grading_method": "set", "question": "Calculate the percentage of Medline’s orders placed through the in-store channel.", "evidence": "Medline refers to Customers.`Customer Names` = 'Medline ' with a trailing space; the in-store channel refers to `Sales Orders`.`Sales Channel` = 'In-Store'; percentage = DIVIDE(COUNT(Medline orders with Sales Channel = 'In-Store'), COUNT(Medline orders)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T1.`Sales Channel` = 'In-Store' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1._CustomerID) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Medline '"} {"question_id": 2598, "db_id": "regional_sales", "grading_method": "set", "question": "For wholesale orders of Bedroom Furniture placed in 2019, list the customer names and delivery times in days.", "evidence": "wholesale refers to `Sales Orders`.`Sales Channel` = 'Wholesale'; Bedroom Furniture refers to Products.`Product Name`; placed in 2019 refers to SUBSTR(OrderDate, -2) = '19', dates being M/D/YY; delivery time = SUBTRACT(DeliveryDate, OrderDate) in whole days once both are read as dates, skipping orders without one; return both Customers.`Customer Names` and that day count, ordered by customer name", "SQL": "WITH filtered AS (\n SELECT C.`Customer Names` AS customer_name,\n date('20' || substr(S.`OrderDate`,-2) || '-' || \n substr('00'||substr(S.`OrderDate`,1,instr(S.`OrderDate`, '/')-1),-2) || '-' || \n substr('00'||REPLACE(substr(S.`OrderDate`, instr(S.`OrderDate`, '/')+1, 2), '/', ''), -2) ) AS order_iso,\n date('20' || substr(S.`DeliveryDate`,-2) || '-' || \n substr('00'||substr(S.`DeliveryDate`,1,instr(S.`DeliveryDate`, '/')-1),-2) || '-' || \n substr('00'||REPLACE(substr(S.`DeliveryDate`, instr(S.`DeliveryDate`, '/')+1, 2), '/', ''), -2) ) AS delivery_iso\n FROM `Sales Orders` S\n JOIN Products P ON P.`ProductID` = S.`_ProductID`\n JOIN Customers C ON C.`CustomerID` = S.`_CustomerID`\n WHERE S.`Sales Channel` = 'Wholesale'\n AND P.`Product Name` = 'Bedroom Furniture'\n AND substr(S.`OrderDate`,-2) = '19'\n)\nSELECT customer_name,\n ROUND(julianday(delivery_iso) - julianday(order_iso)) AS delivery_period_days\nFROM filtered\nWHERE delivery_iso IS NOT NULL\nORDER BY customer_name;"} {"question_id": 2609, "db_id": "regional_sales", "grading_method": "set", "question": "How many states are located in the Midwest region?", "evidence": "Regions.Region records a state’s region, including 'Midwest'; Regions.StateCode identifies the state.", "SQL": "SELECT COUNT(DISTINCT T) FROM ( SELECT CASE WHEN Region = 'Midwest' THEN StateCode ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL"} {"question_id": 2614, "db_id": "regional_sales", "grading_method": "set", "question": "Calculate the average net profit of phones which have sales channel of distributor.", "evidence": "net profit can be computed as SUBTRACT(Unit Price, Unit Cost); AVG(net profit) where Product Name = 'Phones' and Sales Channel = 'Distributor';", "SQL": "SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Phones' AND T1.`Sales Channel` = 'Distributor'"} {"question_id": 2615, "db_id": "regional_sales", "grading_method": "set", "question": "What is the average per-unit profit for Bar Tools orders with an order quantity exceeding 5?", "evidence": "Bar Tools refers to Products.`Product Name` = 'Bar Tools'; order quantity exceeding 5 refers to `Order Quantity` > 5; per-unit profit refers to SUBTRACT(`Unit Price`, `Unit Cost`); average per-unit profit = DIVIDE(SUM of that per-unit profit, COUNT of those Sales Orders rows)", "SQL": "SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Bar Tools' AND T1.`Order Quantity` > 5"} {"question_id": 2619, "db_id": "regional_sales", "grading_method": "set", "question": "List out the discount levels applied for all orders from Ole Group.", "evidence": "Ole Group is the name of the customer; discount levels applied refer to Discount Applied NOT NULL;", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN T1.`Customer Names` = 'Ole Group' THEN T2.`Discount Applied` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL"} {"question_id": 2621, "db_id": "regional_sales", "grading_method": "set", "question": "Among the orders placed by Ei, how many orders have quantity greater than 4?", "evidence": "Customers.Customer Names stores Ei as 'Ei ' with a trailing space. Sales Orders.Order Quantity records quantity.", "SQL": "SELECT SUM(CASE WHEN T1.`Order Quantity` > 4 AND T2.`Customer Names` = 'Ei ' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID"} {"question_id": 2623, "db_id": "regional_sales", "grading_method": "set", "question": "What are the customer names for orders with a unit cost greater than 4000 USD?", "evidence": "Sales Orders.\"Unit Cost\" records unit cost and may contain thousands-separator commas; customer names are in Customers.\"Customer Names\".", "SQL": "SELECT DISTINCT T FROM ( SELECT DISTINCT CASE WHEN CAST(REPLACE(T2.`Unit Cost`, ',', '') AS REAL) > 4000 THEN T1.`Customer Names` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL"} {"question_id": 2627, "db_id": "regional_sales", "grading_method": "set", "question": "Please give the order number and product name of the order which has the lowest unit price.", "evidence": "the lowest unit price refers to MIN(Unit Price);", "SQL": "SELECT so.OrderNumber, p.`Product Name`\nFROM `Sales Orders` so\nJOIN Products p ON p.ProductID = so._ProductID\nWHERE CAST(REPLACE(so.`Unit Price`, ',', '') AS REAL) = (\n SELECT MIN(CAST(REPLACE(`Unit Price`, ',', '') AS REAL)) FROM `Sales Orders`\n);"} {"question_id": 2630, "db_id": "regional_sales", "grading_method": "set", "question": "Please list all sale team names which had orders on 5/31/2018.", "evidence": "had orders on 5/31/2018 refer to OrderDate = '5/31/18'; sale team names refer to Sales Team;", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN T1.OrderDate = '5/31/18' THEN T2.`Sales Team` ELSE NULL END AS T FROM `Sales Orders` T1 INNER JOIN `Sales Team` T2 ON T2.SalesTeamID = T1._SalesTeamID ) WHERE T IS NOT NULL"} {"question_id": 2636, "db_id": "regional_sales", "grading_method": "set", "question": "What is the unit cost of order SO - 000103?", "evidence": "OrderNumber = 'SO - 000103';", "SQL": "SELECT DISTINCT T FROM ( SELECT IIF(OrderNumber = 'SO - 000103', `Unit Cost`, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL"} {"question_id": 2637, "db_id": "regional_sales", "grading_method": "set", "question": "In 2020, what were the total orders of all stores in Maricopa County?", "evidence": "total orders refer to COUNT(OrderNumber); 2020 refers to SUBSTR(OrderDate, -2) = '20';", "SQL": "SELECT SUM(CASE WHEN T2.County = 'Maricopa County' AND OrderDate LIKE '%/%/20' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID"} {"question_id": 2643, "db_id": "regional_sales", "grading_method": "set", "question": "What is the percentage of total orders of Stephen Payne that had a net profit of over 1000?", "evidence": "Sales Team = 'Stephen Payne'; net profit can be computed as SUM(SUBTRACT(Unit Price, Unit Cost) * Quantity); DIVIDE(COUNT(OrderNumber where Sales Team = 'Stephen Payne' and Net Profit > 1000)), (COUNT(OrderNumber where Sales Team = 'Stephen Payne')) as percentage;", "SQL": "SELECT SUM(CASE WHEN total_profit > 1000 THEN 1 ELSE 0 END) * 100.0 / COUNT(*) FROM (\n SELECT SUM(CAST((REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) AS REAL) * T1.`Order Quantity`) total_profit, \n T1.OrderNumber \n FROM `Sales Orders` AS T1 \n INNER JOIN `Sales Team` AS T2 \n ON T2.SalesTeamID = T1._SalesTeamID \n WHERE T2.`Sales Team` = 'Stephen Payne'\n GROUP BY OrderNumber)"} {"question_id": 2657, "db_id": "regional_sales", "grading_method": "set", "question": "State all the order numbers for sales team of Samuel Fowler.", "evidence": "", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.`Sales Team` = 'Samuel Fowler' THEN T1.OrderNumber ELSE NULL END AS T FROM `Sales Orders` T1 INNER JOIN `Sales Team` T2 ON T2.SalesTeamID = T1._SalesTeamID ) WHERE T IS NOT NULL"} {"question_id": 2663, "db_id": "regional_sales", "grading_method": "set", "question": "Write down the store IDs and region of the state \"Michigan\".", "evidence": "\"Michigan\" is the State", "SQL": "SELECT DISTINCT T2.StoreID, T1.Region FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'Michigan'"} {"question_id": 2670, "db_id": "regional_sales", "grading_method": "set", "question": "Which products were sold through the wholesale channel at stores in the Pacific/Honolulu time zone?", "evidence": "\"Sales Orders\".\"Sales Channel\" uses 'Wholesale'. \"Store Locations\".\"Time Zone\" uses 'Pacific/Honolulu'.", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN T3.`Time Zone` = 'Pacific/Honolulu' AND T2.`Sales Channel` = 'Wholesale' THEN T1.`Product Name` ELSE NULL END AS T FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` T3 ON T3.StoreID = T2._StoreID ) WHERE T IS NOT NULL"} {"question_id": 2683, "db_id": "regional_sales", "grading_method": "set", "question": "List all the cities where Shawn Torres sells Audio products.", "evidence": "\"Shawn Torres\" is the name of Sales Team; Audio product refers to Product Name = 'Audio'", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN T4.`Product Name` = 'Audio' AND T3.`Sales Team` = 'Shawn Torres' THEN T1.`City Name` ELSE NULL END AS T FROM `Store Locations` T1 INNER JOIN `Sales Orders` T2 ON T2._StoreID = T1.StoreID INNER JOIN `Sales Team` T3 ON T3.SalesTeamID = T2._SalesTeamID INNER JOIN Products T4 ON T4.ProductID = T2._ProductID ) WHERE T IS NOT NULL"} {"question_id": 2691, "db_id": "regional_sales", "grading_method": "set", "question": "To which region does the sales team that has used the WARE-MKL1006 warehouse the most times for its shipments belong?", "evidence": "WARE-MKL1006 refers to `Sales Orders`.WarehouseCode = 'WARE-MKL1006'; the sales team that used it the most times refers to the _SalesTeamID with the greatest COUNT(*) of those orders, taking the single top one; return that team's `Sales Team`.Region", "SQL": "SELECT ST.`Region`\nFROM (\n SELECT `_SalesTeamID`\n FROM `Sales Orders`\n WHERE `WarehouseCode` = 'WARE-MKL1006'\n GROUP BY `_SalesTeamID`\n ORDER BY COUNT(*) DESC\n LIMIT 1\n) AS top\nJOIN `Sales Team` ST\n ON ST.`SalesTeamID` = top.`_SalesTeamID`;"} {"question_id": 2692, "db_id": "regional_sales", "grading_method": "set", "question": "In which city is the store with the highest sales order unit price located?", "evidence": "Sales Orders.Unit Price stores numeric amounts as text with comma thousands separators, so read it as CAST(REPLACE(Unit Price, ',', '') AS REAL); the highest sales order unit price refers to MAX of that numeric price over all Sales Orders; return the Store Locations.City Name of the store with that highest unit price", "SQL": "SELECT sl.`City Name` FROM `Sales Orders` so JOIN `Store Locations` sl ON sl.`StoreID` = so.`_StoreID` WHERE CAST(REPLACE(so.`Unit Price`, ',', '') AS REAL) = ( SELECT MAX(CAST(REPLACE(`Unit Price`, ',', '') AS REAL)) FROM `Sales Orders` );"} {"question_id": 2696, "db_id": "regional_sales", "grading_method": "set", "question": "At what Latitude and Longitude is the store that has used the WARE-PUJ1005 warehouse the fewest times?", "evidence": "WARE-PUJ1005 is the WarehouseCode; fewest times refers to Min (Count(WarehouseCode))", "SQL": "WITH loc_cnt AS (\n SELECT T2.Latitude, T2.Longitude, COUNT(*) cnt \n FROM `Sales Orders` AS T1 \n INNER JOIN `Store Locations` AS T2 \n ON T2.StoreID = T1._StoreID \n WHERE T1.WarehouseCode = 'WARE-PUJ1005' \n GROUP BY T2.StoreID\n) SELECT Latitude, Longitude\nFROM loc_cnt\nWHERE cnt = (SELECT MIN(cnt) FROM loc_cnt)"} {"question_id": 2703, "db_id": "regional_sales", "grading_method": "set", "question": "Which sales team has the order with the highest unit price? List the team name.", "evidence": "highest unit price refers to Max(Unit Price)", "SQL": "SELECT st.`Sales Team`\nFROM `Sales Orders` so\nJOIN `Sales Team` st ON st.`SalesTeamID` = so.`_SalesTeamID`\nWHERE CAST(REPLACE(so.`Unit Price`, ',', '') AS REAL) =\n (SELECT MAX(CAST(REPLACE(`Unit Price`, ',', '') AS REAL))\n FROM `Sales Orders`)"} {"question_id": 2721, "db_id": "regional_sales", "grading_method": "set", "question": "In the Northeast region, what is the average household income for each city located in the state with the highest number of stores?", "evidence": "the Northeast region refers to Region = 'Northeast'; the state with the highest number of stores refers to the StateCode with the greatest COUNT of store locations in that region; return each City Name with AVG(Household Income) in that state", "SQL": "SELECT\n sl.`City Name`,\n AVG(sl.`Household Income`) AS avg_household_income\nFROM `Store Locations` sl\nJOIN `Regions` r ON r.`StateCode` = sl.`StateCode`\nWHERE r.`Region` = 'Northeast'\n AND sl.`StateCode` IN (\n SELECT sl2.`StateCode`\n FROM `Store Locations` sl2\n JOIN `Regions` r2 ON r2.`StateCode` = sl2.`StateCode`\n WHERE r2.`Region` = 'Northeast'\n GROUP BY sl2.`StateCode`\n HAVING COUNT(*) = (\n SELECT COUNT(*)\n FROM `Store Locations` sl3\n JOIN `Regions` r3 ON r3.`StateCode` = sl3.`StateCode`\n WHERE r3.`Region` = 'Northeast'\n GROUP BY sl3.`StateCode`\n ORDER BY COUNT(*) DESC LIMIT 1)\n \n )\nGROUP BY sl.`City Name`;"} {"question_id": 2728, "db_id": "regional_sales", "grading_method": "set", "question": "How many orders were shipped by the sales teams with the highest amount of shipped orders in 2020? Give the names of the said sales teams.", "evidence": "shipped refers to ShipDate; in 2020 refers to SUBSTR(ShipDate, -2) = '20'; highest amount of shipped orders refers to Max(Count(OrderNumber))", "SQL": "SELECT COUNT(T1.OrderNumber), T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.ShipDate LIKE '%/%/20' GROUP BY T2.`Sales Team` HAVING COUNT(T1.OrderNumber) = (SELECT COUNT(T3.OrderNumber) FROM `Sales Orders` AS T3 INNER JOIN `Sales Team` AS T4 ON T4.SalesTeamID = T3._SalesTeamID WHERE T3.ShipDate LIKE '%/%/20' GROUP BY T4.`Sales Team` ORDER BY COUNT(T3.OrderNumber) DESC LIMIT 1);"} {"question_id": 2737, "db_id": "regional_sales", "grading_method": "set", "question": "What is the household income of Glendale, Arizona?", "evidence": "\"Glendale\" is the City Name; Arizona is the State", "SQL": "SELECT `Household Income` FROM `Store Locations` WHERE `City Name` = 'Glendale' AND State = 'Arizona'"} {"question_id": 2745, "db_id": "european_football_1", "grading_method": "set", "question": "What percentage of matches in the 2017 season had an away team that scored exactly 2 goals?", "evidence": "the away team scored exactly 2 goals refers to FTAG = 2; percentage = DIVIDE(SUM(CASE WHEN FTAG = 2 THEN 1 ELSE 0 END), COUNT(*)) * 100 over the matchs rows of the 2017 season", "SQL": "SELECT 100.0 * SUM(CASE WHEN `FTAG` = 2 THEN 1 ELSE 0 END) / COUNT(*) AS away_two_goal_percentage\nFROM `matchs`\nWHERE `season` = 2017;"} {"question_id": 2748, "db_id": "european_football_1", "grading_method": "set", "question": "How many matches played in the 2019 season of Scottish Championship league were ended with an equal result of 2-2?", "evidence": "matches refer to Div; Scottish Championship is a name of the league; equal result of 2-2 refers to FTAG = 2 AND FTHG = 2;", "SQL": "SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2019 AND T2.name = 'Scottish Championship' AND T1.FTAG = 2 AND T1.FTHG = 2"} {"question_id": 2750, "db_id": "european_football_1", "grading_method": "set", "question": "From the Spanish LaLiga division in the 2017 season, which team won the most times as a local team, what's percentage of home matches did the team win?", "evidence": "local team refers to HomeTeam; Spanish means belong to the country = 'Spain'; LaLiga is a name of division; won as a local team refers to FTR = 'H', where H stands for home victory; DIVIDE(COUNT(Div where name = 'LaLiga', country = 'Spain', season = 2017, FRT = 'H'), COUNT(Div where name = 'LaLiga', country = 'Spain', season = 2017)) as percentage;", "SQL": "WITH team_stats AS (\n SELECT T1.`HomeTeam`,\n SUM(CASE WHEN T1.`FTR` = 'H' THEN 1 ELSE 0 END) AS home_wins,\n COUNT(*) AS total_home_matches\n FROM `matchs` T1\n JOIN `divisions` T2 ON T1.`Div` = T2.`division`\n WHERE T2.`name` = 'LaLiga'\n AND T2.`country` = 'Spain'\n AND T1.`season` = 2017\n GROUP BY T1.`HomeTeam`\n)\nSELECT `HomeTeam`,\n home_wins * 100.0 / total_home_matches AS win_percentage\nFROM team_stats\nORDER BY home_wins DESC, `HomeTeam`\nLIMIT 1;"} {"question_id": 2755, "db_id": "european_football_1", "grading_method": "set", "question": "Which division had the most draw matches in the 2008 season?", "evidence": "a draw refers to matchs.FTR = 'D'; the 2008 season refers to matchs.season = 2008; the most draw matches refers to the Div with the highest COUNT of such matches, taking the single top division; return that Div", "SQL": "SELECT Div FROM matchs WHERE season = 2008 AND FTR = 'D' GROUP BY Div ORDER BY COUNT(FTR) DESC LIMIT 1"} {"question_id": 2760, "db_id": "european_football_1", "grading_method": "set", "question": "Which away teams in the Bundesliga division scored the highest number of final-time goals in a single match?", "evidence": "the Bundesliga division refers to divisions.name = 'Bundesliga'; final-time goals scored by the away team refers to matchs.FTAG; the highest number in a single match refers to FTAG = MAX(FTAG) among the Bundesliga matchs; return matchs.AwayTeam for those matchs", "SQL": "SELECT T1.AwayTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div=T2.division WHERE T2.name = 'Bundesliga' AND T1.FTAG = (SELECT MAX(T3.FTAG) FROM matchs AS T3 INNER JOIN divisions AS T4 ON T3.Div=T4.division WHERE T4.name = 'Bundesliga')"} {"question_id": 2766, "db_id": "european_football_1", "grading_method": "set", "question": "What's the name of the football division in the Netherlands?", "evidence": "Netherlands is the name of country;", "SQL": "SELECT name FROM divisions WHERE country = 'Netherlands'"} {"question_id": 2770, "db_id": "european_football_1", "grading_method": "set", "question": "For the Ligue 2 game with the most total goals, which team won?", "evidence": "Ligue 2 is recorded in divisions.name as 'Ligue 2'. matchs.FTHG and matchs.FTAG record full-time home and away goals. matchs.FTR uses 'H' for a home win, 'A' for an away win, and 'D' for a draw.", "SQL": "SELECT CASE\n WHEN m.FTR = 'H' THEN m.HomeTeam\n WHEN m.FTR = 'A' THEN m.AwayTeam\n ELSE NULL\n END AS winner\nFROM matchs AS m\nJOIN divisions AS d ON m.Div = d.division\nWHERE d.name = 'Ligue 2'\n AND (m.FTHG + m.FTAG) = (\n SELECT MAX(FTHG + FTAG)\n FROM matchs m2\n JOIN divisions d2 ON m2.Div = d2.division\n WHERE d2.name = 'Ligue 2');"} {"question_id": 2771, "db_id": "european_football_1", "grading_method": "set", "question": "How many Away Victories happened on 2016/3/27 in the LaLiga 2 division?", "evidence": "Away victories refer to FTR = 'A'; LaLiga 2 is the name of division; Date = '2016-03-27';", "SQL": "SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga 2' AND T1.Date = '2016-03-27' AND T1.FTR = 'A'"} {"question_id": 2772, "db_id": "european_football_1", "grading_method": "set", "question": "How many draw games happened on 2018/8/7 for National League?", "evidence": "National League is the name of division; Date = '2018-08-07'; draw refers to FTR = 'D'; games refer to Div;", "SQL": "SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'National League' AND T1.Date = '2018-08-07' AND T1.FTR = 'D'"} {"question_id": 2777, "db_id": "european_football_1", "grading_method": "set", "question": "How many Scottish League One games took place on the day when Pro Vercelli beat Pescara 5–2?", "evidence": "matchs.HomeTeam and matchs.AwayTeam record team names; matchs.FTHG and matchs.FTAG record their full-time goals. Scottish League One is recorded in divisions.name as 'Scottish League One'.", "SQL": "SELECT COUNT(T1.Date) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Scottish League One' AND T1.Date = ( SELECT Date FROM matchs WHERE FTHG = 5 AND FTAG = 2 AND HomeTeam = 'Pro Vercelli' AND AwayTeam = 'Pescara' )"} {"question_id": 2782, "db_id": "european_football_1", "grading_method": "set", "question": "For all the games ended up with 1-1, what percentage of them are from Liga NOS division?", "evidence": "games ended up with 1-1 refers to matchs.FTHG = 1 AND matchs.FTAG = 1; Liga NOS refers to divisions.name = 'Liga NOS'; percentage = DIVIDE(COUNT of 1-1 games in Liga NOS, COUNT of all 1-1 games) * 100", "SQL": "SELECT 100.0 * SUM(CASE WHEN d.name = 'Liga NOS' THEN 1 ELSE 0 END) / COUNT(*) AS percentage\nFROM `matchs` AS m\nLEFT JOIN `divisions` AS d\n ON m.`Div` = d.`division`\nWHERE m.`FTHG` = 1 AND m.`FTAG` = 1;"} {"question_id": 2784, "db_id": "european_football_1", "grading_method": "set", "question": "Which team was the home team in the match of the Bundesliga division on 2020/10/2?", "evidence": "Bundesliga is the name of division; Date = '2020-10-02';", "SQL": "SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.Date = '2020-10-02' AND T2.name = 'Bundesliga'"} {"question_id": 2789, "db_id": "european_football_1", "grading_method": "set", "question": "Of the matches in all seasons of the Bundesliga division, how many of them ended with a tie?", "evidence": "Bundesliga is the name of division; tie refers to FTR = 'D', where D stands for draft;", "SQL": "SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.FTR = 'D'"} {"question_id": 2795, "db_id": "european_football_1", "grading_method": "set", "question": "What's the winning rate of Club Brugge in the 2021 Division 1A?", "evidence": "Division 1A refers to divisions.name = 'Division 1A' and 2021 to matchs.season = 2021; Club Brugge's matches have HomeTeam or AwayTeam = 'Club Brugge'; a win refers to (HomeTeam = 'Club Brugge' AND FTR = 'H') OR (AwayTeam = 'Club Brugge' AND FTR = 'A'); winning rate = DIVIDE(wins, those matches) * 100", "SQL": "SELECT CASE WHEN COUNT(*) = 0 THEN 0\n ELSE CAST(SUM(CASE WHEN (m.`HomeTeam` = 'Club Brugge' AND m.`FTR` = 'H')\n OR (m.`AwayTeam` = 'Club Brugge' AND m.`FTR` = 'A')\n THEN 1 END) AS REAL) * 100.0 / COUNT(*) END AS win_rate\nFROM `matchs` m\nJOIN `divisions` d ON m.`Div` = d.`division`\nWHERE d.`name` = 'Division 1A'\n AND m.`season` = 2021\n AND (m.`HomeTeam` = 'Club Brugge' OR m.`AwayTeam` = 'Club Brugge');"} {"question_id": 2804, "db_id": "professional_basketball", "grading_method": "set", "question": "List the coach ID, team name, and year for coaching stints from 2000 through 2010 in which the coach lost more games than they won.", "evidence": "coaches.won and lost are recorded per team stint, identified by tmID and stint within a year.", "SQL": "SELECT c.coachID,\n t.`name` AS team_name,\n c.`year`\nFROM `coaches` c\nJOIN `teams` t\n ON c.`tmID` = t.`tmID`\n AND c.`year` = t.`year`\nWHERE c.`year` BETWEEN 2000 AND 2010\n AND c.`lost` > c.`won`;"} {"question_id": 2807, "db_id": "professional_basketball", "grading_method": "set", "question": "What percentage of players who won an All-Defensive First Team award from 1980 through 2000 were born in New York?", "evidence": "players.birthState = 'NY' denotes New York. The award label is 'All-Defensive First Team'.", "SQL": "WITH winners AS (\n SELECT DISTINCT `playerID`\n FROM `awards_players`\n WHERE `award` = 'All-Defensive First Team' AND `year` BETWEEN 1980 AND 2000\n),\nny_winners AS (\n SELECT w.`playerID`\n FROM winners w\n JOIN `players` p ON p.`playerID` = w.`playerID`\n WHERE p.`birthState` = 'NY'\n)\nSELECT CAST(COUNT(*) AS REAL) * 100.0 / (SELECT COUNT(*) FROM winners) AS pct_ny_winners FROM ny_winners;"} {"question_id": 2817, "db_id": "professional_basketball", "grading_method": "set", "question": "How many total minutes has the Brooklyn-born player, known by the name of Superman, played during all of his NBA All-Star seasons?", "evidence": "\"Brooklyn\" is the birthCity of player; known by the name of Superman refers to nameNick like '%Superman%'; total minutes refers to Sum(minutes)", "SQL": "SELECT SUM(T2.minutes) FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.birthCity = 'Brooklyn' AND T1.nameNick LIKE '%Superman%'"} {"question_id": 2833, "db_id": "professional_basketball", "grading_method": "set", "question": "Among the players that went to high school in New York and have won the MVP, what is their average height?", "evidence": "players.hsState = 'NY' identifies high schools in New York. awards_players.award = 'Most Valuable Player' identifies the MVP award; players.height records height.", "SQL": "SELECT AVG(p.`height`) AS avg_height FROM `players` AS p WHERE p.`hsState` = 'NY' AND p.`playerID` IN ( SELECT DISTINCT ap.`playerID` FROM `awards_players` AS ap WHERE ap.`award` = 'Most Valuable Player' )"} {"question_id": 2834, "db_id": "professional_basketball", "grading_method": "set", "question": "Please list the IDs of top ten teams with the highest scores in 2000.", "evidence": "in 2000 refers to year = 2000; team with highest score refers to Max(o_pts)", "SQL": "SELECT `tmID` FROM `teams` WHERE `year` = 2000 ORDER BY `o_pts` DESC LIMIT 10;"} {"question_id": 2835, "db_id": "professional_basketball", "grading_method": "set", "question": "Which teams have winning rate less than 50%? List their names.", "evidence": "team with winning rate less than 50% refers to Divide (won, Sum(won, lost)) < 0.5", "SQL": "SELECT DISTINCT name FROM teams WHERE CAST(won AS REAL) * 100 / (won + lost) < 50"} {"question_id": 2840, "db_id": "professional_basketball", "grading_method": "set", "question": "Please list down the last name of players from \"BLB\" team.", "evidence": "\"BLB\" is the tmID", "SQL": "SELECT T1.lastName FROM players AS T1 INNER JOIN players_teams AS T2 ON T1.playerID = T2.playerID WHERE T2.tmID = 'BLB' GROUP BY T1.playerID"} {"question_id": 2847, "db_id": "professional_basketball", "grading_method": "set", "question": "What is the maximum weight of USA all-star players?", "evidence": "\"USA\" is the birthCountry of player;  maximum weight refers to Max(weight)", "SQL": "SELECT MAX(T1.weight) FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.birthCountry = 'USA'"} {"question_id": 2851, "db_id": "professional_basketball", "grading_method": "set", "question": "Which team IDs had at least three different players selected as All-Stars in seasons when those players belonged to the team, over all recorded years?", "evidence": "selected as All-Stars in seasons when those players belonged to the team refers to players_teams joined to player_allstar on the same playerID with players_teams.year = season_id; at least three different players refers to COUNT(DISTINCT playerID) >= 3 per team; return those team IDs", "SQL": "SELECT T1.tmID FROM players_teams AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID AND T1.year = T2.season_id GROUP BY T1.tmID HAVING COUNT(DISTINCT T1.playerID) >= 3"} {"question_id": 2855, "db_id": "professional_basketball", "grading_method": "set", "question": "How many teams scored at least 500 points in total across all their players in 1937?", "evidence": "players_teams.points records a player’s points for a team and year; tmID identifies the team.", "SQL": "SELECT COUNT(*) FROM ( SELECT T2.name, SUM(T1.points) FROM players_teams AS T1 INNER JOIN teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.year = 1937 GROUP BY T2.name HAVING SUM(points) >= 500 ) AS T3"} {"question_id": 2857, "db_id": "professional_basketball", "grading_method": "set", "question": "Give the first and last names of the three shortest Black players with positive recorded heights.", "evidence": "Black players refers to players.race = 'B'; positive recorded heights refers to players.height > 0; the three shortest refers to ORDER BY players.height ASC LIMIT 3; return the first and last names of those players", "SQL": "SELECT firstName, lastName FROM players WHERE race = 'B' AND height > 0 ORDER BY height ASC LIMIT 3"} {"question_id": 2858, "db_id": "professional_basketball", "grading_method": "set", "question": "How many players with the first name Joe were drafted in 1970?", "evidence": "drafted in 1970 refers to draftYear = 1970", "SQL": "SELECT COUNT(DISTINCT COALESCE(`playerID`, `firstName` || ' ' || `lastName`)) AS num_joe_players\nFROM `draft`\nWHERE `firstName` = 'Joe' AND `draftYear` = 1970;"} {"question_id": 2859, "db_id": "professional_basketball", "grading_method": "set", "question": "How many regular-season field goals did George Mikan make overall in the 1951 through 1953 seasons?", "evidence": "players_teams.fgMade records field goals made and players_teams.year records the season year. players.firstName and players.lastName identify George Mikan.", "SQL": "SELECT SUM(`fgMade`) AS total_fg_made FROM `players_teams` WHERE `playerID` = 'mikange01' AND `year` BETWEEN 1951 AND 1953"} {"question_id": 2860, "db_id": "professional_basketball", "grading_method": "set", "question": "What are the basketball players' BMI ranges? List the minimum and maximum BMI values.", "evidence": "BMI = Multiply(Divide(weight, Multiply(height, height)), 703)", "SQL": "SELECT\n MIN(weight * 1.0 / (height * height) * 703) AS min_bmi,\n MAX(weight * 1.0 / (height * height) * 703) AS max_bmi\nFROM `players`\nWHERE weight IS NOT NULL AND weight > 0\n AND height IS NOT NULL AND height > 0;"} {"question_id": 2861, "db_id": "professional_basketball", "grading_method": "set", "question": "Which team had the highest per-year home-loss rate over all time?", "evidence": "teams.homeLost and teams.homeWon record home losses and wins for a team-year. Home-loss rate is the share of those home games lost.", "SQL": "SELECT name\nFROM teams\nWHERE (homeWon + homeLost) > 0\nAND CAST(homeLost AS REAL) / (homeWon + homeLost) = (\n SELECT MAX(CAST(homeLost AS REAL) / (homeWon + homeLost)) FROM teams)"} {"question_id": 2868, "db_id": "professional_basketball", "grading_method": "set", "question": "Which players committed the most personal fouls over their NBL careers? List their first names.", "evidence": "NBL refers to lgID = 'NBL'; personal fouls over their NBL careers refers to SUM(PF) over a player's NBL team season rows; the most personal fouls refers to the greatest such per-player total; list players.firstName", "SQL": "WITH pf_sum AS (\n SELECT pt.playerID,\n SUM(pt.PF) AS totalPF\n FROM players_teams pt\n WHERE pt.lgID = 'NBL'\n GROUP BY pt.playerID\n)\nSELECT p.firstName\nFROM pf_sum\nJOIN players p ON p.playerID = pf_sum.playerID\nWHERE pf_sum.totalPF = (SELECT MAX(totalPF) FROM pf_sum);"} {"question_id": 2885, "db_id": "professional_basketball", "grading_method": "set", "question": "Which coach had the largest margin of wins over losses in 1988? Give the coach ID.", "evidence": "margin of wins over losses refers to SUBTRACT(won, lost) as recorded for a coaches team stint; the largest margin refers to the greatest such margin among coaches in 1988; return the coach ID holding it", "SQL": "SELECT coachID FROM coaches WHERE year = 1988 ORDER BY won - lost DESC LIMIT 1"} {"question_id": 2896, "db_id": "professional_basketball", "grading_method": "set", "question": "What is the percentage of offense rebounds from the total rebounds of the players in year 2000.", "evidence": "in year 2000 refers to year = 2000; percentage = divide(sum(o_rebounds), sum(rebounds)) * 100%", "SQL": "SELECT 100.0 * SUM(`oRebounds`) / SUM(`rebounds`) AS percentage_off_reb\nFROM `players_teams`\nWHERE `year` = 2000;"} {"question_id": 2920, "db_id": "professional_basketball", "grading_method": "set", "question": "State the names of teams that ranked first at least five times and lost a championship final at least two times between 1980 and 2000.", "evidence": "between 1980 and 2000 refers to year BETWEEN 1980 AND 2000 in teams and in series_post alike; ranked first at least five times refers to COUNT(teams rows with rank = 1 in those years) >= 5 for a team; lost a championship final at least two times refers to COUNT(series_post rows with round = 'F' in those years having that team as tmIDLoser) >= 2; return the DISTINCT teams.name of every team that satisfies both", "SQL": "WITH first_rank AS (\n SELECT `tmID`, COUNT(*) AS cnt_first\n FROM `teams`\n WHERE `year` BETWEEN 1980 AND 2000 AND `rank` = 1\n GROUP BY `tmID`\n HAVING cnt_first >= 5\n),\nfinal_losses AS (\n SELECT `tmIDLoser` AS `tmID`, COUNT(*) AS cnt_loss\n FROM `series_post`\n WHERE `year` BETWEEN 1980 AND 2000 AND `round` = 'F'\n GROUP BY `tmID`\n HAVING cnt_loss >= 2\n)\nSELECT DISTINCT t.`name`\nFROM first_rank fr\nJOIN final_losses fl ON fr.`tmID` = fl.`tmID`\nJOIN `teams` t ON t.`tmID` = fr.`tmID` AND t.`year` BETWEEN 1980 AND 2000; "} {"question_id": 2922, "db_id": "professional_basketball", "grading_method": "set", "question": "For players drafted in 1970, how much higher was the average draft age in the ABA than in the NBA?", "evidence": "draft age refers to SUBTRACT(the draft year, the birth year of players.birthDate in YYYY-MM-DD); the population is players drafted in 1970 with draft.lgID IN ('ABA','NBA'); how much higher refers to SUBTRACT(AVG(draft age where draft.lgID = 'ABA'), AVG(draft age where draft.lgID = 'NBA')), each average taken over its own draft.lgID value only", "SQL": "SELECT\n AVG(CASE WHEN d.lgID = 'ABA' THEN d.draftYear - CAST(strftime('%Y', p.birthDate) AS INTEGER) END)\n - AVG(CASE WHEN d.lgID = 'NBA' THEN d.draftYear - CAST(strftime('%Y', p.birthDate) AS INTEGER) END) AS age_difference\nFROM draft AS d\nJOIN players AS p ON d.playerID = p.playerID\nWHERE d.draftYear = 1970\n AND d.lgID IN ('ABA','NBA')\n AND p.birthDate IS NOT NULL;"} {"question_id": 2934, "db_id": "professional_basketball", "grading_method": "set", "question": "Among NBA teams that did not make the playoffs in the 2000 season, which had the highest win rate? List their team IDs.", "evidence": "NBA teams in the 2000 season refers to teams.lgID = 'NBA' AND teams.year = 2000; did not make the playoffs refers to a missing or empty teams.playoff; win rate = DIVIDE(won * 1.0, won + lost), unscaled; the highest win rate refers to MAX of that rate; include all teams tied for it; return their team IDs", "SQL": "WITH rates AS (SELECT tmID, won * 1.0 / (won + lost) AS win_rate FROM teams WHERE year = 2000 AND lgID = 'NBA' AND (playoff IS NULL OR playoff = '')) SELECT tmID FROM rates WHERE win_rate = (SELECT MAX(win_rate) FROM rates)"} {"question_id": 2938, "db_id": "professional_basketball", "grading_method": "set", "question": "For the player who was drafted in the 1st round, 6th position in 1976, which team did he play in that year?", "evidence": "drafted in the 1st round refers to draftRound = 1; 6th position refers to draftSelection = 6; in 1976 refers to year = 1976; team refers to tmID", "SQL": "SELECT pt.`tmID`\nFROM `draft` AS d\nJOIN `players_teams` AS pt\n ON d.`playerID` = pt.`playerID` AND pt.`year` = d.`draftYear`\nWHERE d.`draftYear` = 1976\n AND d.`draftRound` = 1\n AND d.`draftSelection` = 6;"} {"question_id": 2944, "db_id": "professional_basketball", "grading_method": "set", "question": "Find the youngest player listed as both a forward and a guard. Which NBA teams did they play for? List the team IDs.", "evidence": "listed as both a forward and a guard refers to players.pos LIKE '%F%' AND players.pos LIKE '%G%'; the youngest such player refers to players.birthDate = MAX(birthDate) over those players; NBA refers to players_teams rows with lgID = 'NBA'; list the DISTINCT players_teams.tmID of that player", "SQL": "WITH youngest AS (\n SELECT playerID, birthDate\n FROM players\n WHERE pos LIKE '%F%' AND pos LIKE '%G%'\n AND birthDate = (SELECT MAX(birthDate) FROM players\n WHERE pos LIKE '%F%' AND pos LIKE '%G%')\n)\nSELECT DISTINCT pt.tmID\nFROM youngest y\nJOIN players_teams pt ON pt.playerID = y.playerID\nWHERE pt.lgID = 'NBA';"} {"question_id": 2945, "db_id": "professional_basketball", "grading_method": "set", "question": "Among the players who played the most PBLA games, who graduated from Central Missouri State College? Give their first, middle, and last names.", "evidence": "PBLA games refers to players_teams.GP where lgID = 'PBLA'; the most PBLA games refers to the players whose SUM(GP) over their PBLA rows equals the greatest such total; Central Missouri State College refers to players.college = 'Central Missouri State'; return the first, middle and last names", "SQL": "WITH gp AS ( SELECT `playerID`, SUM(`GP`) AS total_gp FROM `players_teams` WHERE `lgID` = 'PBLA' GROUP BY `playerID` ), max_gp AS ( SELECT MAX(total_gp) AS maxgp FROM gp ) SELECT p.`firstName`, p.`middleName`, p.`lastName` FROM gp JOIN max_gp ON gp.total_gp = maxgp JOIN players p ON p.`playerID` = gp.`playerID` WHERE p.`college` = 'Central Missouri State'"} {"question_id": 2950, "db_id": "professional_basketball", "grading_method": "set", "question": "For the 2001 rebounds leader in the league, when was his birthday?", "evidence": "2001 refers to year = 2001; rebounds leader refers to max(rebounds); birthday refers to birthDate", "SQL": "SELECT p.`birthDate`\nFROM `players` p\nWHERE p.`playerID` IN (\n SELECT pt.`playerID`\n FROM `players_teams` pt\n WHERE pt.`year` = 2001\n GROUP BY pt.`playerID`\n HAVING SUM(pt.`rebounds`) = (\n SELECT SUM(pt1.`rebounds`)\n FROM `players_teams` pt1\n WHERE pt1.`year` = 2001\n GROUP BY pt1.`playerID`\n ORDER BY SUM(pt1.`rebounds`) DESC LIMIT 1) \n);"} {"question_id": 2958, "db_id": "shakespeare", "grading_method": "set", "question": "Please list the character names of all the characters from the work Twelfth Night.", "evidence": "character names refers to CharName; Twelfth Night refers to Title = 'Twelfth Night'", "SQL": "SELECT DISTINCT T4.CharName FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.Title = 'Twelfth Night'"} {"question_id": 2962, "db_id": "shakespeare", "grading_method": "set", "question": "Please list the IDs of the paragraphs in which the character \"son to Tamora\" appears.", "evidence": "character \"son to Tamora\"  refers to characters.Description = 'son to Tamora'", "SQL": "SELECT T1.id FROM paragraphs AS T1 INNER JOIN characters AS T2 ON T1.character_id = T2.id WHERE T2.Description = 'son to Tamora'"} {"question_id": 2968, "db_id": "shakespeare", "grading_method": "set", "question": "How many comedies did Shakespeare create?", "evidence": "comedies refers to GenreType = 'Comedy'", "SQL": "SELECT COUNT(id) FROM works WHERE GenreType = 'Comedy'"} {"question_id": 2969, "db_id": "shakespeare", "grading_method": "set", "question": "When did Shakespeare write the first poem?", "evidence": "first poem refers to GenreType = 'Poem' and Date = 'min'", "SQL": "SELECT MIN(Date) FROM works WHERE GenreType = 'Poem'"} {"question_id": 2970, "db_id": "shakespeare", "grading_method": "set", "question": "Give the abbreviation name for the character \"Earl of Westmoreland\".", "evidence": "abbreviation name refers to Abbrev; character \"Earl of Westmoreland\" refers to CharName = 'Earl of Westmoreland'", "SQL": "SELECT DISTINCT Abbrev FROM characters WHERE CharName = 'Earl of Westmoreland'"} {"question_id": 2980, "db_id": "shakespeare", "grading_method": "set", "question": "Give the description for the Act No.2, Scene No.2 of Midsummer Night's Dream.", "evidence": "Act No.2 refers to Act = '2'; Scene No.2  refers to Scene = '2'; Midsummer Night's Dream refers to Title = 'Midsummer Night''s Dream'", "SQL": "SELECT T2.Description FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Act = '2' AND T2.Scene = '2' AND T1.Title = 'Midsummer Night''s Dream'"} {"question_id": 2993, "db_id": "shakespeare", "grading_method": "set", "question": "What is the description of the chapter with the longest number of paragraphs?", "evidence": "chapter with the longest number of paragraphs refers to max(count(paragraph))", "SQL": "SELECT c.`Description`\nFROM `chapters` AS c\nJOIN `paragraphs` AS p ON p.`chapter_id` = c.`id`\nGROUP BY c.`id`\nHAVING COUNT(*) = (\n SELECT COUNT(*)\n FROM `chapters` AS c1\n JOIN `paragraphs` AS p1 ON p1.`chapter_id` = c1.`id`\n GROUP BY c1.`id`\n ORDER BY COUNT(*) DESC LIMIT 1)"} {"question_id": 2997, "db_id": "shakespeare", "grading_method": "set", "question": "Which works have the most recorded scenes in Act 1, and how many paragraphs are in that act for each? Give each work’s title and paragraph count.", "evidence": "the most recorded scenes in Act 1 refers to the MAX of COUNT(DISTINCT Scene) among chapters with Act = 1 per work, keeping every tied work; paragraphs in that act refers to COUNT(paragraphs.id) over the paragraphs of that work's Act = 1 chapters, 0 if none; return both works.LongTitle and that paragraph count", "SQL": "WITH scene_counts AS (\n SELECT work_id,COUNT(DISTINCT Scene) AS scenes FROM chapters WHERE Act=1 GROUP BY work_id\n), selected AS (\n SELECT work_id FROM scene_counts WHERE scenes=(SELECT MAX(scenes) FROM scene_counts)\n)\nSELECT w.LongTitle,COUNT(p.id) AS paragraphs\nFROM selected s JOIN works w ON w.id=s.work_id\nJOIN chapters c ON c.work_id=w.id AND c.Act=1\nLEFT JOIN paragraphs p ON p.chapter_id=c.id\nGROUP BY w.id,w.LongTitle;"} {"question_id": 3006, "db_id": "shakespeare", "grading_method": "set", "question": "What are the titles and genres of the one-act works of Shakespeare?", "evidence": "one-act works refers to works for which COUNT(DISTINCT chapters.Act) = 1, since multiple scene records can belong to the same act; return works.Title and works.GenreType for each such work", "SQL": "SELECT w.Title,\n w.GenreType\nFROM works AS w\nJOIN chapters AS c ON w.id = c.work_id\nGROUP BY w.id\nHAVING COUNT(DISTINCT c.Act) = 1;"} {"question_id": 3011, "db_id": "shakespeare", "grading_method": "set", "question": "In The Tragedy of Romeo and Juliet, what percentage of paragraphs is attributed to Romeo, and what percentage to Juliet? Give each name and percentage, rounded to two decimal places.", "evidence": "The Tragedy of Romeo and Juliet refers to works.LongTitle = 'The Tragedy of Romeo and Juliet'; paragraphs.character_id attributes each paragraph to a character, and paragraph records are the attribution units; a character's percentage = ROUND(DIVIDE(COUNT(paragraphs of that play attributed to that character), COUNT(paragraphs of that play)) * 100, 2); give the character and its percentage for Romeo and for Juliet", "SQL": "SELECT\n c.`CharName` AS character,\n ROUND(COUNT(*) * 100.0 /\n (SELECT COUNT(*)\n FROM `paragraphs` p2\n JOIN `chapters` ch2 ON ch2.`id` = p2.`chapter_id`\n JOIN `works` w2 ON w2.`id` = ch2.`work_id`\n WHERE w2.`LongTitle` = 'The Tragedy of Romeo and Juliet'), 2) AS percentage\nFROM `paragraphs` p\nJOIN `chapters` ch ON ch.`id` = p.`chapter_id`\nJOIN `works` w ON w.`id` = ch.`work_id`\nJOIN `characters` c ON c.`id` = p.`character_id`\nWHERE w.`LongTitle` = 'The Tragedy of Romeo and Juliet'\n AND c.`CharName` IN ('Romeo','Juliet')\nGROUP BY c.`CharName`;"} {"question_id": 3012, "db_id": "shakespeare", "grading_method": "set", "question": "What is the paragraph number for the text \"This is Illyria, lady.\"?", "evidence": "The text is recorded in paragraphs.PlainText; its paragraph number is paragraphs.ParagraphNum.", "SQL": "SELECT ParagraphNum FROM paragraphs WHERE PlainText = 'This is Illyria, lady.'"} {"question_id": 3014, "db_id": "shakespeare", "grading_method": "subset,=,5", "question": "List down any 5 titles in the history genre.", "evidence": "in the history genre refers to GenreType = 'History'", "SQL": "SELECT Title FROM works WHERE GenreType = 'History'"} {"question_id": 3015, "db_id": "shakespeare", "grading_method": "set", "question": "How many scenes are there in Act 5 of work ID 9?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT Scene) FROM chapters WHERE work_id = 9 AND Act = 5"} {"question_id": 3016, "db_id": "shakespeare", "grading_method": "set", "question": "List the character names and descriptions of chapter ID 18710.", "evidence": "character names refers to CharName", "SQL": "SELECT DISTINCT T1.CharName, T1.Description FROM characters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.character_id WHERE T2.Chapter_id = 18710"} {"question_id": 3023, "db_id": "shakespeare", "grading_method": "set", "question": "Describe the full title which had the character named Servant to Montague.", "evidence": "full title refers to LongTitle; character named Servant to Montague refers to characters.Description = 'Servant to Montague'", "SQL": "SELECT DISTINCT T1.LongTitle FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T4.Description = 'Servant to Montague'"} {"question_id": 3024, "db_id": "shakespeare", "grading_method": "set", "question": "Describe the scene number, act, and title of work which had the description of \"The house of ANTIPHOLUS of Ephesus\" in chapter.", "evidence": "", "SQL": "SELECT T2.Act, T2.Scene, T1.Title FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Description = 'The house of ANTIPHOLUS of Ephesus.'"} {"question_id": 3026, "db_id": "shakespeare", "grading_method": "set", "question": "Calculate the average number of scenes per act in Antony and Cleopatra.", "evidence": "Antony and Cleopatra refers to works.Title = 'Antony and Cleopatra'; the chapters rows of that title are its scenes, and chapters.Act identifies the act; average number of scenes per act = DIVIDE(COUNT(chapters rows), COUNT(DISTINCT Act)) as a REAL", "SQL": "SELECT CAST(COUNT(*) AS REAL) / COUNT(DISTINCT `Act`) AS avg_scenes_per_act\nFROM `chapters`\nJOIN `works` ON `works`.`id` = `chapters`.`work_id`\nWHERE `works`.`Title` = 'Antony and Cleopatra';"} {"question_id": 3033, "db_id": "shakespeare", "grading_method": "set", "question": "What are the character names for a senator of Venice?", "evidence": "character names refers to CharName; a senator of Venice refers to characters.Description = 'A senator of Venice'", "SQL": "SELECT CharName FROM characters WHERE Description = 'A senator of Venice'"} {"question_id": 3038, "db_id": "shakespeare", "grading_method": "set", "question": "In how many chapters does Gratiano, described as \"friend to Antonio and Bassiano\", appear?", "evidence": "The stored character description is 'friend to Antonio and Bassiano'. paragraphs.character_id attributes a paragraph to a character.", "SQL": "SELECT COUNT(DISTINCT T2.chapter_id) FROM characters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.character_id WHERE T1.CharName = 'Gratiano' AND T1.Description = 'friend to Antonio and Bassiano'"} {"question_id": 3041, "db_id": "shakespeare", "grading_method": "set", "question": "Please list the paragraph numbers that have the character name Aedile.", "evidence": "paragraphs  refers to ParagraphNum; character name Aedile refers to CharName = 'Aedile'", "SQL": "SELECT T2.ParagraphNum FROM characters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.character_id WHERE T1.CharName = 'Aedile'"} {"question_id": 3044, "db_id": "shakespeare", "grading_method": "set", "question": "Among historical works dated from 1500 through 1599, what percentage have at least five scenes?", "evidence": "historical works refers to works.GenreType = 'History'; dated from 1500 through 1599 refers to works.Date BETWEEN 1500 AND 1599; at least five scenes refers to COUNT(chapters of that work) >= 5; percentage = DIVIDE(COUNT(those works with >= 5 scenes), COUNT(all historical works dated 1500-1599)) * 100", "SQL": "WITH hist_1500 AS (\n SELECT `id`\n FROM `works`\n WHERE `GenreType` = 'History'\n AND `Date` BETWEEN 1500 AND 1599\n), qualified AS (\n SELECT w.`id`\n FROM hist_1500 w\n JOIN `chapters` c ON c.`work_id` = w.`id`\n GROUP BY w.`id`\n HAVING COUNT(*) >= 5\n)\nSELECT 100.0 * (SELECT COUNT(*) FROM qualified)\n / (SELECT COUNT(*) FROM hist_1500) AS `percentage`;"} {"question_id": 3056, "db_id": "shakespeare", "grading_method": "set", "question": "How many paragraphs of dialogue does Viola have in Act 1, Scene 2 of Twelfth Night?", "evidence": "Viola refers to characters.CharName = 'Viola'; how many paragraphs of dialogue refers to the COUNT of paragraphs records for that character in Act 1, Scene 2 of Twelfth Night", "SQL": "SELECT COUNT(T4.id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T2.Act = 1 AND T2.Scene = 2 AND T4.CharName = 'Viola' AND T1.Title = 'Twelfth Night'"} {"question_id": 3059, "db_id": "shakespeare", "grading_method": "set", "question": "List the scene numbers involving the character named Sir Toby Belch in the Twelfth Night.", "evidence": "scene numbers refers to Scene; character named Sir Toby Belch refers to CharName = 'Sir Toby Belch'; in the Twelfth Night refers to Title = 'Twelfth Night'", "SQL": "SELECT DISTINCT T2.Scene FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.Title = 'Twelfth Night' AND T4.CharName = 'Sir Toby Belch'"} {"question_id": 3063, "db_id": "cars", "grading_method": "set", "question": "Among the cars with 8 cylinders, what are the names of the ones that are the most expensive?", "evidence": "with 8 cylinders refers to cylinders = 8; name of the car refers to car_name; the most expensive refers to max(price)", "SQL": "SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.cylinders = 8 AND T2.price = (SELECT MAX(T4.price) FROM data AS T3 INNER JOIN price AS T4 ON T3.ID = T4.ID WHERE T3.cylinders = 8);"} {"question_id": 3064, "db_id": "cars", "grading_method": "set", "question": "Among the cars over 3000lbs, how many of them cost less than $30000?", "evidence": "over 3000lbs refers to weight > 3000; cost less than $30000 refers to price < 30000", "SQL": "SELECT COUNT(T1.car_name) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.weight > 3000 AND T2.price < 30000"} {"question_id": 3066, "db_id": "cars", "grading_method": "set", "question": "How much US dollars does a Ford Torino cost?", "evidence": "cost refers to price; Ford Torino refers to car_name = 'ford torino'", "SQL": "SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford torino'"} {"question_id": 3067, "db_id": "cars", "grading_method": "set", "question": "What was the origin country of the car model ford torino produced in 1970?", "evidence": "origin country refers to country; Ford Torino refers to car_name = 'ford torino'; produced in 1970 refers to model_year = 1970", "SQL": "SELECT T3.country 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 T1.car_name = 'ford torino' AND T2.model_year = 1970"} {"question_id": 3081, "db_id": "cars", "grading_method": "set", "question": "Which is the origin country of the $44274.40748 car?", "evidence": "origin country refers to country; the $44274.40748 car refers to price = 44274.40748", "SQL": "SELECT T3.country FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.price = 44274.40748"} {"question_id": 3082, "db_id": "cars", "grading_method": "set", "question": "How much is the Volkswagen Dasher with 14.1 mph acceleration?", "evidence": "cost refers to price; Volkswagen Dasher refers to car_name = 'volkswagen dasher'; 14.1 mph acceleration refers to acceleration = 14.1", "SQL": "SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'volkswagen dasher' AND T1.acceleration = '14.1'"} {"question_id": 3083, "db_id": "cars", "grading_method": "set", "question": "Provide the engine displacement status of the $37443.85589 car.", "evidence": "engine displacement status refers to displacement; the $37443.85589 car refers to price = 37443.85589", "SQL": "SELECT T1.displacement FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = '37443.85589'"} {"question_id": 3084, "db_id": "cars", "grading_method": "set", "question": "When was the $32650.65157 car introduced to the market? State the year.", "evidence": "price.price records the price. data.model stores the model year as an offset from 1900.", "SQL": "SELECT 1900 + T1.model FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = 32650.65157"} {"question_id": 3085, "db_id": "cars", "grading_method": "set", "question": "Provide the price of the only Toyota Corona hardtop in the database.", "evidence": "Toyota Corona hardtop refers to car_name = 'toyota corona hardtop'", "SQL": "SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'toyota corona hardtop'"} {"question_id": 3090, "db_id": "cars", "grading_method": "set", "question": "Calculate the swept volume of the $34538.97449 car.", "evidence": "sweep volume = divide(displacement, cylinders); the $34538.97449 car refers to price = 34538.97449", "SQL": "SELECT T1.displacement / T1.cylinders FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = 34538.97449"} {"question_id": 3091, "db_id": "cars", "grading_method": "set", "question": "What are the names of the most expensive cars?", "evidence": "name of the car refers to car_name; the most expensive refers to max(price)", "SQL": "SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = (SELECT MAX(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID);"} {"question_id": 3094, "db_id": "cars", "grading_method": "set", "question": "What are the fastest cars made by Japan?", "evidence": "the fastest refers to max(horsepower); made by Japan refers to country = 'Japan'; name of the car refers to car_name", "SQL": "SELECT DISTINCT T1.car_name 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.horsepower = (SELECT MAX(T4.horsepower) FROM data AS T4 INNER JOIN production AS T5 ON T4.ID = T5.ID INNER JOIN country AS T6 ON T5.country = T6.origin WHERE T6.country = 'Japan');"} {"question_id": 3095, "db_id": "cars", "grading_method": "set", "question": "How many times was Ford Maverick introduced to the market?", "evidence": "Ford Maverick refers to car_name = 'ford maverick';", "SQL": "SELECT COUNT(DISTINCT T2.model_year) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford maverick'"} {"question_id": 3098, "db_id": "cars", "grading_method": "set", "question": "What are the names of the most expensive cars that were produced by the USA?", "evidence": "name of the car refers to car_name; the most expensive refers to max(price); produced by the USA refers to country = 'USA'", "SQL": "SELECT T4.car_name FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'USA' AND T1.price = (SELECT MAX(T1_sub.price) FROM price AS T1_sub INNER JOIN production AS T2_sub ON T1_sub.ID = T2_sub.ID INNER JOIN country AS T3_sub ON T3_sub.origin = T2_sub.country WHERE T3_sub.country = 'USA')"} {"question_id": 3106, "db_id": "cars", "grading_method": "set", "question": "Calculate the average price of cars from Europe. Round your answer to 2 decimal places.", "evidence": "from Europe refers to country.country = 'Europe', reached from production by country.origin = production.country; average price refers to AVG(price.price) over the price rows whose price.ID is one of those European cars; round your answer to 2 decimal places refers to ROUND(that average, 2)", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(pr.price) AS avg_price FROM price pr WHERE pr.ID IN ( SELECT DISTINCT p.ID FROM production p JOIN country c ON c.origin = p.country WHERE c.country = 'Europe' )\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 3107, "db_id": "cars", "grading_method": "set", "question": "What is the price of the car ID 15?", "evidence": "", "SQL": "SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.ID = 15"} {"question_id": 3108, "db_id": "cars", "grading_method": "set", "question": "How many of the cars from Japan weighed less than 3000?", "evidence": "from Japan refers to country = 'Japan'; weighed less than 3000 refers to weight < 3000", "SQL": "SELECT COUNT(DISTINCT d.`ID`)\nFROM `data` AS d\nJOIN `production` AS p ON p.`ID` = d.`ID`\nJOIN `country` AS c ON c.`origin` = p.`country`\nWHERE c.`country` = 'Japan'\n AND d.`weight` < 3000;"} {"question_id": 3110, "db_id": "cars", "grading_method": "set", "question": "Provide the ID of cars from Japan worth greater than 25000 and have an acceleration of 14.", "evidence": "from Japan refers to country = 'Japan'; worth greater than 25000 refers to price > 25000; have an acceleration of 14 refers to acceleration = 14", "SQL": "SELECT DISTINCT T4.ID FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' AND T1.price > 25000 AND T4.acceleration = 14"} {"question_id": 3120, "db_id": "cars", "grading_method": "set", "question": "Which country produced the car with the lowest mileage per gallon?", "evidence": "the lowest mileage per gallon refers to min(mpg)", "SQL": "SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country ORDER BY T1.mpg ASC LIMIT 1"} {"question_id": 3122, "db_id": "cars", "grading_method": "set", "question": "Among the cars introduced in 1977, provide the names and the horse powers of cars from Europe.", "evidence": "introduced in 1977 refers to model_year = 1977; car's name refers to car_name; from Europe refers to country = 'Europe'", "SQL": "SELECT T1.car_name, T1.horsepower 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 T2.model_year = 1977 AND T3.country = 'Europe'"} {"question_id": 3123, "db_id": "cars", "grading_method": "set", "question": "Provide the names and models of the cars with the highest price.", "evidence": "car's name refers to car_name; the highest price refers to max(price)", "SQL": "SELECT T1.car_name, T1.model FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = (SELECT MAX(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID);"} {"question_id": 3124, "db_id": "cars", "grading_method": "set", "question": "What is the price of a Chevrolet Bel Air?", "evidence": "Chevrolet Bel Air refers to car_name = 'chevrolet bel air'", "SQL": "SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'chevrolet bel air'"} {"question_id": 3125, "db_id": "cars", "grading_method": "set", "question": "What is the average price per car produced in Japan?", "evidence": "produced in Japan refers to country = 'Japan'; average price per car = avg(price)", "SQL": "SELECT AVG(p.`price`)\nFROM `price` AS p\nJOIN (\n SELECT DISTINCT pr.`ID`\n FROM `production` pr\n JOIN `country` c ON c.`origin` = pr.`country`\n WHERE c.`country` = 'Japan'\n) AS j ON p.`ID` = j.`ID`;"} {"question_id": 3127, "db_id": "cars", "grading_method": "set", "question": "Among the cars produced in 1975, provide IDs, names, and producing countries of the cars with the maximum number of cylinders.", "evidence": "produced in 1975 refers to model_year = 1975; names refers to car_name; producing countries refers to country; the maximum number of cylinders refers to max(cylinders)", "SQL": "SELECT d.ID, d.car_name, c.country\nFROM `data` d\nJOIN `production` p ON d.ID = p.ID\nJOIN `country` c ON c.origin = p.country\nWHERE p.model_year = 1975\n AND d.cylinders = (\n SELECT MAX(d2.cylinders)\n FROM `data` d2\n JOIN `production` p2 ON d2.ID = p2.ID\n WHERE p2.model_year = 1975\n );"} {"question_id": 3128, "db_id": "cars", "grading_method": "set", "question": "Which cars are the cheapest? Provide the car name, acceleration, number of cylinders, and producing year.", "evidence": "the cheapest refers to min(price); number of cylinders refers to cylinders; producing year refers to model_year", "SQL": "WITH cheapest AS (SELECT MIN(price) AS min_price FROM price) SELECT T1.car_name, T1.acceleration, T1.cylinders, T2.model_year FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN price AS T3 ON T3.ID = T2.ID INNER JOIN cheapest AS T4 ON T3.price = T4.min_price"} {"question_id": 3129, "db_id": "cars", "grading_method": "set", "question": "List the names and prices of the cars with model 82 and mileage per gallon of greater than 30.", "evidence": "car's name refers to car_name; model 82 refers to model = 82; mileage per gallon of greater than 30 refers to mpg > 30", "SQL": "SELECT T2.car_name, T1.price FROM price AS T1 INNER JOIN data AS T2 ON T1.ID = T2.ID WHERE T2.model = 82 AND T2.mpg > 30"} {"question_id": 3132, "db_id": "cars", "grading_method": "set", "question": "Calculate the average production rate per year from 1971 to 1980.", "evidence": "from 1971 to 1980 refers to model_year between 1971 and 1980; average production rate per year = divide(count(ID where model_year between 1971 and 1980), 10)", "SQL": "SELECT CAST(COUNT(*) AS REAL) / 10 AS avg_production_per_year\nFROM `production`\nWHERE `model_year` BETWEEN 1971 AND 1980;\n"} {"question_id": 3136, "db_id": "cars", "grading_method": "set", "question": "List the price of Ford cars from model 1970 to 1980.", "evidence": "Ford cars refers to car_name LIKE 'ford%'; from model 1970 to 1980 refers to model_year BETWEEN 1970 AND 1980", "SQL": "SELECT DISTINCT T3.price FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN price AS T3 ON T3.ID = T2.ID WHERE T1.car_name LIKE 'ford%' AND T2.model_year BETWEEN 1970 AND 1980"} {"question_id": 3141, "db_id": "cars", "grading_method": "set", "question": "List the names of the most expensive cars.", "evidence": "car's name refers to car_name; the most expensive refers to max(price)", "SQL": "SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = (SELECT MAX(price) FROM price)"} {"question_id": 3142, "db_id": "cars", "grading_method": "set", "question": "In which years was Buick Skylark 320 in production?", "evidence": "Car model name is data.car_name; Buick Skylark 320 is stored as 'buick skylark 320'. Production year is production.model_year.", "SQL": "SELECT T2.model_year FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'buick skylark 320'"} {"question_id": 3143, "db_id": "cars", "grading_method": "set", "question": "Which countries produced the most expensive cars in 1970?", "evidence": "the most expensive refers to max(price); in 1970 refers to model_year = 1970", "SQL": "SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN price AS T4 ON T4.ID = T1.ID WHERE T2.model_year = 1970 AND T4.price = (SELECT MAX(T8.price) FROM data AS T5 INNER JOIN production AS T6 ON T5.ID = T6.ID INNER JOIN country AS T7 ON T7.origin = T6.country INNER JOIN price AS T8 ON T8.ID = T5.ID WHERE T6.model_year = 1970);"} {"question_id": 3145, "db_id": "cars", "grading_method": "set", "question": "Calculate the percentage of American cars among all cars.", "evidence": "American car refers to country = 'USA'; percentage = divide(count(ID where country = 'USA'), count(ID)) * 100%", "SQL": "SELECT CAST( COUNT(DISTINCT CASE WHEN c.country = 'USA' THEN d.ID END) AS REAL) * 100 / COUNT(DISTINCT d.ID) AS percentage_usa FROM data d JOIN production p ON p.ID = d.ID JOIN country c ON c.origin = p.country"} {"question_id": 3148, "db_id": "donor", "grading_method": "set", "question": "When were the highest amounts donated? How much was the amount?", "evidence": "when refers donation_timestamp; the highest amount refers to max(donation_total)", "SQL": "SELECT donation_timestamp, donation_total FROM donations WHERE donation_total = ( SELECT donation_total FROM donations ORDER BY donation_total DESC LIMIT 1 )"} {"question_id": 3150, "db_id": "donor", "grading_method": "set", "question": "For each donation not from a teacher, state the donor account id and calculate the percentage of donation given for optional support.", "evidence": "not from a teacher refers to is_teacher_acct = 'f'; donor account id refers to donor_acctid; percentage of donation = divide(donation_optional_support, donation_total)*100%", "SQL": " SELECT `donor_acctid`, (100.0 * `donation_optional_support`) / `donation_total` AS `pct_optional_support` FROM `donations` WHERE `is_teacher_acct` = 'f';"} {"question_id": 3154, "db_id": "donor", "grading_method": "set", "question": "Name the project titles created by teacher who acquired a doctor degree.", "evidence": "teacher who acquired a doctor degree refers to teacher_prefix = 'Dr.'", "SQL": "SELECT DISTINCT T1.title FROM essays AS T1 JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T2.teacher_prefix = 'Dr.'"} {"question_id": 3157, "db_id": "donor", "grading_method": "set", "question": "Name the vendors who provide resources for project 'Lights, Camera, Action!'. List all the item names and unit price for each.", "evidence": "project 'Lights, Camera, Action!' refers to title = 'Lights, Camera, Action!'", "SQL": "SELECT T1.vendor_name, T1.item_name, T1.item_unit_price FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid INNER JOIN essays AS T3 ON T2.projectid = T3.projectid WHERE T3.title = 'Lights, Camera, Action!'"} {"question_id": 3161, "db_id": "donor", "grading_method": "set", "question": "Of the money contributed to school projects, excluding optional support, what percentage went to rural schools? Round your answer to 3 decimal places.", "evidence": "money contributed excluding optional support refers to donations.donation_to_project; rural schools refers to projects.school_metro = 'rural'; percentage = ROUND(DIVIDE(SUM(donation_to_project for rural schools), SUM(donation_to_project)) * 100, 3) over donations joined to their projects", "SQL": "WITH unrounded(value) AS (\nSELECT CAST(SUM(CASE WHEN T2.school_metro = 'rural' THEN T1.donation_to_project ELSE 0 END) AS REAL) * 100 / SUM(donation_to_project) FROM donations AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 3162, "db_id": "donor", "grading_method": "set", "question": "What are the IDs of the projects with the highest cost, how much has been collected in donations, and what percentage of their cost is still lacking?", "evidence": "the highest cost refers to projects.total_price_excluding_optional_support = MAX(total_price_excluding_optional_support); collected refers to SUM(donations.donation_to_project) toward that project; the percentage of its cost still lacking = DIVIDE(SUBTRACT(cost, collected), cost) * 100; return the project ID, the collected contributions and that percentage", "SQL": "WITH max_cost_project AS (\n SELECT `projectid`, `total_price_excluding_optional_support` AS cost\n FROM `projects`\n WHERE `total_price_excluding_optional_support` = (\n SELECT MAX(`total_price_excluding_optional_support`)\n FROM `projects`\n )\n)\nSELECT m.`projectid`,\n COALESCE(SUM(d.`donation_to_project`),0) AS collected,\n (cost - COALESCE(SUM(d.`donation_to_project`),0))*100.0 / cost AS percent_lacking\nFROM max_cost_project m\nLEFT JOIN `donations` d ON d.`projectid` = m.`projectid`\nLEFT JOIN `essays` e ON e.`projectid` = m.`projectid`\nGROUP BY m.`projectid`;"} {"question_id": 3165, "db_id": "donor", "grading_method": "set", "question": "Which project has the highest total price including optional support? Indicate its project ID.", "evidence": "the highest total price including optional support refers to MAX(projects.total_price_including_optional_support); indicate its project ID refers to returning the project ID of the single project holding that maximum", "SQL": "SELECT projectid FROM projects ORDER BY total_price_including_optional_support DESC LIMIT 1"} {"question_id": 3166, "db_id": "donor", "grading_method": "set", "question": "Which state had the highest number of PayPal donations made in honor of someone and including a corporate-sponsored gift card?", "evidence": "PayPal donations made in honor of someone and including a corporate-sponsored gift card refers to payment_method = 'paypal' AND for_honoree = 't' AND payment_included_campaign_gift_card = 't'; the highest number refers to the donor_state with the largest COUNT of those donations", "SQL": "SELECT donor_state\nFROM donations\nWHERE for_honoree = 't'\n AND payment_included_campaign_gift_card = 't'\n AND payment_method = 'paypal'\n AND donor_state IS NOT NULL\nGROUP BY donor_state\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 3169, "db_id": "donor", "grading_method": "set", "question": "For project \"d6ef27c07c30c81f0c16c32b6acfa2ff\", list the resources requested, their quantities, and whether the teacher has a Ph.D. or doctoral degree (Yes or No).", "evidence": "resources.item_name and resources.item_quantity record requested resources and quantities; projects.teacher_prefix = 'Dr.' denotes that the teacher acquired a Ph.D. or doctoral degree in this dataset.", "SQL": "SELECT DISTINCT T1.item_name, T1.item_quantity, CASE WHEN T2.teacher_prefix = 'Dr.' THEN 'Yes' ELSE 'No' END FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.projectid = 'd6ef27c07c30c81f0c16c32b6acfa2ff'"} {"question_id": 3170, "db_id": "donor", "grading_method": "set", "question": "What is the total price including optional support received by the teachers who posted the essay titled \"Recording Rockin' Readers\"?", "evidence": "", "SQL": "SELECT SUM(p.`total_price_including_optional_support`)\nFROM projects p\nWHERE p.`teacher_acctid` IN (\n SELECT DISTINCT e.`teacher_acctid`\n FROM essays e\n WHERE e.`title` = 'Recording Rockin'' Readers'\n);"} {"question_id": 3175, "db_id": "donor", "grading_method": "set", "question": "What is the name of the vendor that supplies resources to the project \"iMath\"?", "evidence": "project \"iMath\" refers to title = 'iMath'", "SQL": "SELECT DISTINCT T1.vendor_name FROM resources AS T1 INNER JOIN essays AS T3 ON T1.projectid = T3.projectid WHERE T3.title = 'iMath'"} {"question_id": 3179, "db_id": "donor", "grading_method": "set", "question": "Find the top five donors who gave the most optional support in total. For each donor, list their known donor states (leave the state blank only if none is recorded), their donor ID, and their average optional support per donation. Also list the resource types of the projects associated with their largest optional-support donations. Round the average optional support to two decimal places.", "evidence": "Optional support refers to donation_optional_support; donor states to donations.donor_state; resource types to projects.resource_type. Include zero-support donations in the average. Include all known donor states and all resource types associated with donations tied for each donor’s largest optional-support amount. Return each distinct state/resource-type combination separately. Use NULL when no donor state is known or a project’s resource type is unknown.", "SQL": "WITH top_donors AS MATERIALIZED (\n SELECT donor_acctid,\n SUM(donation_optional_support) AS total_support,\n ROUND(AVG(donation_optional_support), 2) AS average_support,\n MAX(donation_optional_support) AS largest_support\n FROM donations\n GROUP BY donor_acctid\n ORDER BY total_support DESC\n LIMIT 5\n), selected_donations AS MATERIALIZED (\n SELECT donor_acctid, donor_state, projectid, donation_optional_support\n FROM donations\n WHERE donor_acctid IN (SELECT donor_acctid FROM top_donors)\n), donor_states AS (\n SELECT DISTINCT donor_acctid, donor_state\n FROM selected_donations\n WHERE donor_state IS NOT NULL\n), donor_resources AS (\n SELECT DISTINCT d.donor_acctid, p.resource_type\n FROM selected_donations AS d\n INNER JOIN top_donors AS t\n ON d.donor_acctid = t.donor_acctid\n AND d.donation_optional_support = t.largest_support\n LEFT JOIN projects AS p ON d.projectid = p.projectid\n)\nSELECT DISTINCT s.donor_state, t.donor_acctid,\n t.average_support, r.resource_type\nFROM top_donors AS t\nLEFT JOIN donor_states AS s ON t.donor_acctid = s.donor_acctid\nLEFT JOIN donor_resources AS r ON t.donor_acctid = r.donor_acctid;"} {"question_id": 3182, "db_id": "donor", "grading_method": "set", "question": "Which school requested the highest amount of resources from Amazon? State the school's ID.", "evidence": "highest amount of resources refers to max(count(schoolid)); Amazon refers to vendor_name = 'Amazon'", "SQL": "SELECT T2.schoolid FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.vendor_name LIKE 'Amazon' GROUP BY T2.schoolid ORDER BY COUNT(T1.vendor_name) DESC LIMIT 1"} {"question_id": 3185, "db_id": "donor", "grading_method": "set", "question": "How many students will be impacted for the Fit Firsties! Project?", "evidence": "how many students refers to students_reached; Fit Firsties! project refers to title = 'Fit Firsties!'", "SQL": "SELECT T2.students_reached FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.title LIKE 'Fit Firsties!'"} {"question_id": 3187, "db_id": "donor", "grading_method": "set", "question": "Which projects created by teachers with Doctor Degree have more than 30 students involved? List down the title of the project.", "evidence": "teachers with Doctor Degree refers to teacher_prefix = 'Dr.'; more than 30 students involved refers to students_reached > 30", "SQL": "SELECT T1.title FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T2.teacher_prefix LIKE 'Dr.' AND T2.students_reached > 30"} {"question_id": 3189, "db_id": "donor", "grading_method": "set", "question": "What is the title of the project with the highest total cost of requested resources?", "evidence": "Project titles are recorded in essays.title. Resource cost is item_unit_price times item_quantity in resources; a project’s cost covers all its requested resources.", "SQL": "SELECT e.`title`\nFROM `essays` e\nWHERE e.`projectid` = (\n SELECT r.`projectid`\n FROM `resources` r\n JOIN `essays` e2 ON e2.`projectid` = r.`projectid`\n GROUP BY r.projectid \n ORDER BY SUM(r.`item_unit_price` * r.`item_quantity`) DESC\n LIMIT 1\n);"} {"question_id": 3194, "db_id": "donor", "grading_method": "set", "question": "Which item has the highest total quantity supplied by Lakeshore Learning Materials? Give its name.", "evidence": "Lakeshore Learning Materials refers to resources.vendor_name = 'Lakeshore Learning Materials'; total quantity of an item refers to SUM(item_quantity) grouped by item_name; the highest total quantity refers to the single item_name with the MAX of that total; return item_name", "SQL": "SELECT `item_name`\nFROM `resources`\nWHERE `vendor_name` = 'Lakeshore Learning Materials'\nGROUP BY `item_name`\nORDER BY SUM(`item_quantity`) DESC\nLIMIT 1;"} {"question_id": 3198, "db_id": "donor", "grading_method": "set", "question": "Among projects supplied by Lakeshore Learning Materials, which had the highest labor-fulfillment cost? List their school IDs, including ties.", "evidence": "supplied by Lakeshore Learning Materials refers to the projects recorded in resources with vendor_name = 'Lakeshore Learning Materials'; the highest labor-fulfillment cost refers to projects.fulfillment_labor_materials = MAX(fulfillment_labor_materials) among only those projects; list the school IDs, including ties", "SQL": "SELECT DISTINCT P.schoolid\nFROM projects P\nWHERE P.projectid IN (SELECT projectid\n FROM resources\n WHERE vendor_name = 'Lakeshore Learning Materials')\n AND P.fulfillment_labor_materials = (\n SELECT MAX(fulfillment_labor_materials)\n FROM projects\n WHERE projectid IN (SELECT projectid\n FROM resources\n WHERE vendor_name = 'Lakeshore Learning Materials')\n);"} {"question_id": 3199, "db_id": "donor", "grading_method": "set", "question": "What is the type of the resources needed by the project that had the highest cost of optional tip?", "evidence": "Highest cost of the optional tip refers to Max(total_price_including_optional_support - total_price_excluding_optional_support);", "SQL": "SELECT DISTINCT r.`project_resource_type`\nFROM `resources` r\nJOIN `projects` p ON p.`projectid` = r.`projectid`\nWHERE (p.`total_price_including_optional_support` - p.`total_price_excluding_optional_support`) = (\n SELECT MAX(`total_price_including_optional_support` - `total_price_excluding_optional_support`)\n FROM `projects` Join resources USING(projectid));"} {"question_id": 3200, "db_id": "donor", "grading_method": "set", "question": "What is the total donated amount for projects created by teachers working at schools 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. donations.donation_total is the donation amount, including optional support.", "SQL": "SELECT SUM(d.donation_total) FROM donations d JOIN projects p ON p.projectid=d.projectid WHERE LOWER(TRIM(p.school_city))='brooklyn' AND p.school_state='NY';"} {"question_id": 3201, "db_id": "donor", "grading_method": "set", "question": "List the donation messages for projects created by teachers at public magnet schools 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. projects.school_magnet = 't' denotes a magnet school; donations.donation_message records the donor's message.", "SQL": "SELECT d.donation_message FROM projects p JOIN donations d ON p.projectid=d.projectid WHERE LOWER(TRIM(p.school_city))='brooklyn' AND p.school_state='NY' AND p.school_magnet='t';"} {"question_id": 3203, "db_id": "donor", "grading_method": "set", "question": "What is the total donation amount made for projects whose main subject area are Literacy & Language?", "evidence": "main subject area refers to primary_focus_area = 'Literacy & Language'; total donation amount refers to Sum(donation_total);", "SQL": "SELECT SUM(d.`donation_total`) AS total_donation\nFROM `projects` p\nJOIN `donations` d ON p.`projectid` = d.`projectid`\nWHERE p.`primary_focus_area` = 'Literacy & Language';"} {"question_id": 3204, "db_id": "donor", "grading_method": "set", "question": "Which donors have donated the most for a project whose main subject area is Literacy & Language? Please give their IDs.", "evidence": "main subject area refers to primary_focus_area = 'Literacy & Language'; donated the most refers to Max(donation_total);", "SQL": "SELECT DISTINCT T2.donor_acctid FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.primary_focus_area = 'Literacy & Language' AND T2.donation_total = (SELECT MAX(T2.donation_total) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.primary_focus_area = 'Literacy & Language')"} {"question_id": 3205, "db_id": "donor", "grading_method": "set", "question": "Which Supplies items were requested in the greatest total quantity by Literacy & Language projects? List their names, including ties.", "evidence": "Literacy & Language projects refers to projects.primary_focus_area = 'Literacy & Language'; Supplies refers to resources.project_resource_type = 'Supplies'; an item's total requested quantity refers to SUM(resources.item_quantity) grouped by item_name; return every item_name whose total equals the MAX of those totals", "SQL": "SELECT r.item_name\nFROM resources r\nJOIN projects p ON p.projectid = r.projectid\nWHERE p.primary_focus_area = 'Literacy & Language'\n AND r.project_resource_type = 'Supplies'\nGROUP BY r.item_name\nHAVING SUM(r.item_quantity) = (\n SELECT MAX(total_qty)\n FROM (\n SELECT SUM(r2.item_quantity) AS total_qty\n FROM resources r2\n JOIN projects p2 ON p2.projectid = r2.projectid\n WHERE p2.primary_focus_area = 'Literacy & Language'\n AND r2.project_resource_type = 'Supplies'\n GROUP BY r2.item_name\n )\n);"} {"question_id": 3207, "db_id": "donor", "grading_method": "set", "question": "What is the average amount of individual donations to projects created by teachers at schools in Brooklyn, NY? Round your answer to 2 decimal places.", "evidence": "schools in Brooklyn, NY refers to projects whose school_city is 'brooklyn' apart from capitalization and surrounding spaces, with school_state = 'NY'; individual donation amount refers to donation_total, which includes optional support; answer = ROUND(AVG(donation_total), 2) over the donations to those schools' projects", "SQL": "WITH unrounded(value) AS (SELECT AVG(donation_total) FROM donations WHERE projectid IN (SELECT projectid FROM projects WHERE LOWER(TRIM(school_city))='brooklyn' AND school_state='NY')) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 3209, "db_id": "donor", "grading_method": "set", "question": "Is donor “22cbc920c9b5fa08dfb331422f5926b5” a teacher? 't' or 'f'", "evidence": "donor “22cbc920c9b5fa08dfb331422f5926b5” refers to donor_acctid = '22cbc920c9b5fa08dfb331422f5926b5'; is a teacher refers to is_teacher_acct;", "SQL": "SELECT DISTINCT is_teacher_acct FROM donations WHERE donor_acctid = '22cbc920c9b5fa08dfb331422f5926b5'"} {"question_id": 3218, "db_id": "donor", "grading_method": "set", "question": "Among the schools receiving donations from donor ‘000eebf28658900e63b538cf8a73afbd’, how many have the highest poverty level?", "evidence": "Highest poverty is recorded as projects.poverty_level = 'highest poverty'; donations.donor_acctid identifies the donor.", "SQL": "SELECT COUNT(DISTINCT T1.schoolid) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.poverty_level = 'highest poverty' AND T2.donor_acctid = '000eebf28658900e63b538cf8a73afbd'"} {"question_id": 3219, "db_id": "donor", "grading_method": "set", "question": "What are the short descriptions of the projects at school “301c9bf0a45d159d162b65a93fddd74e” that received donations?", "evidence": "school \"301c9bf0a45d159d162b65a93fddd74e\" refers to schoolid = '301c9bf0a45d159d162b65a93fddd74e';", "SQL": "SELECT DISTINCT e.`short_description`\nFROM `projects` p\nJOIN `donations` d ON p.`projectid` = d.`projectid`\nJOIN `essays` e ON p.`projectid` = e.`projectid`\nWHERE p.`schoolid` = '301c9bf0a45d159d162b65a93fddd74e';"} {"question_id": 3221, "db_id": "donor", "grading_method": "set", "question": "What payment method was used for the donation to the project created by teacher \"822b79362bbf22b8be4d7bea2fa91a70\"?", "evidence": "projects.teacher_acctid identifies the teacher; donations.payment_method records the payment method.", "SQL": "SELECT T2.payment_method FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.teacher_acctid = '822b79362bbf22b8be4d7bea2fa91a70'"} {"question_id": 3223, "db_id": "donor", "grading_method": "set", "question": "Are any donors who donated to school \"d4af834b1d3fc8061e1ee1b3f1a77b85\" a teacher? Yes or No", "evidence": "school \"d4af834b1d3fc8061e1ee1b3f1a77b85\" refers to schoolid = 'd4af834b1d3fc8061e1ee1b3f1a77b85'; donor is a teacher refers to is_teacher_acct = 't';", "SQL": "SELECT CASE WHEN COUNT(*) > 1 THEN 'Yes' ELSE 'No' END FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.schoolid = 'd4af834b1d3fc8061e1ee1b3f1a77b85' AND T2.is_teacher_acct='t'"} {"question_id": 3231, "db_id": "donor", "grading_method": "set", "question": "What is the total number of projects created by teachers who teach grades 3–5 in the Boston Public School District?", "evidence": "Grades 3–5 are recorded as projects.grade_level = 'Grades 3-5'; the district is projects.school_district = 'Boston Public School District'.", "SQL": "SELECT COUNT(projectid) FROM projects WHERE school_district = 'Boston Public School District' AND grade_level = 'Grades 3-5'"} {"question_id": 3232, "db_id": "donor", "grading_method": "set", "question": "For the teacher who wrote the project 'ABC Read', which city was he/she in?", "evidence": "'ABC Read' is the title; city refers to school_city", "SQL": "SELECT DISTINCT T2.school_city FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.title = 'ABC Read'"} {"question_id": 3235, "db_id": "donor", "grading_method": "set", "question": "What are the titles for the projects that got the donation message as \"Donation on behalf of Matt Carpenter because I'm a strong believer in education.\"?", "evidence": "", "SQL": "SELECT T1.title FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T2.donation_message LIKE 'Donation on behalf of Matt Carpenter because I''m a strong believer in education.'"} {"question_id": 3237, "db_id": "donor", "grading_method": "set", "question": "What is the total donation amount for the project 'Engaging Young Readers with a Leveled Classroom Library'?", "evidence": "essays.title records the project title and may contain leading or trailing spaces; donations.donation_to_project and donation_optional_support are the two components of the donation amount.", "SQL": "SELECT SUM(T2.donation_to_project) + SUM(T2.donation_optional_support) FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE TRIM(T1.title) LIKE 'Engaging Young Readers with a Leveled Classroom Library'"} {"question_id": 3239, "db_id": "donor", "grading_method": "set", "question": "State the short description for the project which got the donation at 14:44:28 on 2012/9/6.", "evidence": "donation at 14:44:28 on 2012/9/6 refers to donation_timestamp LIKE '2012-09-06 14:44:28%';", "SQL": "SELECT T1.short_description FROM essays AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T2.donation_timestamp LIKE '2012-09-06 14:44:28%'"} {"question_id": 3241, "db_id": "donor", "grading_method": "set", "question": "What is the teacher's account ID for the project that got the donation at 11:38:43 on 2008/7/29 ?", "evidence": "donation at 11:38:43 on 2008/7/29 refers to donation_timestamp LIKE '2008-07-29 11:38:43%'; teacher's account ID refers to teacher_acctid;", "SQL": "SELECT T1.teacher_acctid FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T2.donation_timestamp LIKE '2008-07-29 11:38:43%'"} {"question_id": 3247, "db_id": "donor", "grading_method": "set", "question": "Write down the need statement of Family History Project.", "evidence": "title is 'Family History Project '; need statement refer to need_statement", "SQL": "SELECT need_statement FROM essays WHERE title = 'Family History Project '"} {"question_id": 3248, "db_id": "donor", "grading_method": "set", "question": "How many schools with suburban metros are there in Livingston Parish School District?", "evidence": "Livingston Parish School District is recorded as 'Livingston Parish School Dist' in school_district. Suburban areas are labelled 'suburban' in school_metro.", "SQL": "SELECT COUNT(DISTINCT `schoolid`)\nFROM `projects`\nWHERE `school_district` = 'Livingston Parish School Dist'\n AND `school_metro` = 'suburban';"} {"question_id": 3251, "db_id": "donor", "grading_method": "set", "question": "Which school counties in New York had the highest number of projects with low poverty levels?", "evidence": "New York refers to projects.school_state = 'NY'; low poverty refers to poverty_level = 'low poverty'; highest number of projects refers to the school_county with the greatest COUNT(*) of such projects; return every school_county tied at that maximum", "SQL": "SELECT school_county\nFROM projects\nWHERE poverty_level = 'low poverty' AND school_state = 'NY'\nGROUP BY school_county\nHAVING COUNT(*) = (\n SELECT COUNT(*) AS cnt\n FROM projects\n WHERE poverty_level = 'low poverty' AND school_state = 'NY'\n GROUP BY school_county\n ORDER BY cnt DESC\n LIMIT 1\n);"} {"question_id": 3256, "db_id": "donor", "grading_method": "set", "question": "Give the coordinates of the buyer of R & A Plant Genetics from Benchmark Education.", "evidence": "coordinates refer to (school_latitude, school_longitude); R & A Plant Genetics refer to item_name; Benchmark Education refer to vendor_name", "SQL": "SELECT T2.school_latitude, T2.school_longitude FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.item_name = 'R & A Plant Genetics' AND T1.vendor_name = 'Benchmark Education'"} {"question_id": 3257, "db_id": "donor", "grading_method": "set", "question": "Which payment methods are most commonly used by the schools in the state of Georgia for the payment of donations?", "evidence": "Georgia refer to school_state = 'GA'", "SQL": "SELECT T1.payment_method\nFROM donations AS T1\nINNER JOIN projects AS T2 ON T1.projectid = T2.projectid\nWHERE T2.school_state = 'GA'\nGROUP BY T1.payment_method\nHAVING COUNT(*) = (\n SELECT COUNT(*) AS cnt\n FROM donations AS T1\n INNER JOIN projects AS T2 ON T1.projectid = T2.projectid\n WHERE T2.school_state = 'GA'\n GROUP BY T1.payment_method\n ORDER BY cnt DESC\n LIMIT 1\n);"} {"question_id": 3260, "db_id": "donor", "grading_method": "set", "question": "On what date did the project titled \"Lets Share Ideas\" go live?", "evidence": "Project titles are recorded in essays.title. projects.date_posted records when a project went live, as YYYY-MM-DD.", "SQL": "SELECT T1.date_posted FROM projects AS T1 INNER JOIN essays AS T2 ON T1.projectid = T2.projectid WHERE T2.title LIKE 'Lets Share Ideas'"} {"question_id": 3266, "db_id": "donor", "grading_method": "set", "question": "How many donors from the city of Pocatello are not teachers?", "evidence": "city of Pocatello refers to donor_city = 'Pocatello'; not teachers refers to is_teacher_acct = 'f'", "SQL": "SELECT COUNT(DISTINCT donationid) FROM donations WHERE donor_city = 'Pocatello' AND is_teacher_acct = 'f'"} {"question_id": 3267, "db_id": "donor", "grading_method": "set", "question": "How many schools in Suffolk County have Ph.D. teachers?", "evidence": "Suffolk County refers to School_county = 'Suffolk'; Ph.D. teachers refers to Teacher_prefix = 'Dr.'", "SQL": "SELECT COUNT(DISTINCT schoolid) FROM projects WHERE teacher_prefix = 'Dr.' AND school_county = 'Suffolk'"} {"question_id": 3268, "db_id": "donor", "grading_method": "set", "question": "What is the sum of the total donated amounts paid through Amazon?", "evidence": "paid through Amazon refers to payment_method = 'amazon'; sum of the total donated amounts refers to SUM(donation_to_project,donation_optional_support)", "SQL": "SELECT SUM(donation_to_project) + SUM(donation_optional_support) FROM donations WHERE payment_method = 'amazon'"} {"question_id": 3272, "db_id": "donor", "grading_method": "set", "question": "List by school ids projects located in the Columbia School District 93 that have a New York teaching fellow", "evidence": "located in the Columbia School District 93 refers to school_district = 'Columbia School District 93'; New York teaching fellow refers to teacher_ny_teaching_fellow = 't'", "SQL": "SELECT DISTINCT schoolid FROM projects WHERE school_district = 'Columbia School District 93' AND teacher_ny_teaching_fellow = 't'"} {"question_id": 3273, "db_id": "donor", "grading_method": "set", "question": "In which cities are Los Angeles County Suburban Metro Schools located?", "evidence": "Los Angeles County refers to school_county = 'Los Angeles'", "SQL": "SELECT school_city FROM projects WHERE school_metro = 'suburban' AND school_county = 'Los Angeles'"} {"question_id": 3275, "db_id": "donor", "grading_method": "set", "question": "What percentage of projects that received no cash donation also received a donation portion including a corporate-sponsored gift card?", "evidence": "donations.payment_method uses 'no_cash_received' for a noncash donation. payment_included_campaign_gift_card = 't' identifies a corporate-sponsored gift card.", "SQL": "WITH project_cash_status AS (\n SELECT `projectid`,\n MAX(CASE WHEN `payment_method` <> 'no_cash_received' THEN 1 ELSE 0 END) AS has_cash\n FROM donations\n GROUP BY `projectid`\n),\nprojects_no_cash AS (\n SELECT `projectid`\n FROM project_cash_status\n WHERE has_cash = 0\n),\ngift_projects AS (\n SELECT DISTINCT `projectid`\n FROM donations\n WHERE `payment_included_campaign_gift_card` = 't'\n)\nSELECT CAST(\n (SELECT COUNT(*)\n FROM projects_no_cash pn\n JOIN gift_projects gp ON pn.`projectid` = gp.`projectid`) AS REAL\n ) * 100.0 /\n (SELECT COUNT(*) FROM projects_no_cash) AS pct_projects_giftcard;"} {"question_id": 3283, "db_id": "donor", "grading_method": "set", "question": "Find out if the project with the title Team More Books! has a New York teaching fellow. Yes or No", "evidence": "title Team More Books! Refers to title = 'Team More Books!'; as a New York teaching fellow refers to teacher_ny_teaching_fellow = 't'", "SQL": "SELECT CASE WHEN T2.teacher_ny_teaching_fellow = 't' THEN 'Yes' ELSE 'No' END FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.title LIKE 'Team More Books!'"} {"question_id": 3287, "db_id": "donor", "grading_method": "set", "question": "How many Rock Hill City School projects have teacher donors?", "evidence": "Rock Hill City School refers to school_city = 'Rock Hill'; teacher donors refers to is_teacher_acct = 't'", "SQL": "SELECT COUNT(DISTINCT T1.projectid) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.school_city = 'Rock Hill' AND is_teacher_acct = 't'"} {"question_id": 3290, "db_id": "donor", "grading_method": "set", "question": "Among Fresno County schools that received donations, what was the average total donated per school?", "evidence": "Fresno County refers to projects.school_county = 'Fresno'; the donated amount refers to donations.donation_to_project + donations.donation_optional_support; average total donated per school = DIVIDE(SUM(that amount), COUNT(DISTINCT projects.schoolid)) over Fresno projects that received donations", "SQL": "SELECT SUM(T2.donation_optional_support + T2.donation_to_project) / COUNT(DISTINCT schoolid) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.school_county = 'Fresno'"} {"question_id": 3296, "db_id": "donor", "grading_method": "set", "question": "How many donations does the project \"Look, Look, We Need a Nook!\" have?", "evidence": "project \"Look, Look, We Need a Nook!\" refers to title = 'Look, Look, We Need a Nook!'", "SQL": "SELECT COUNT(*)\nFROM donations d\nJOIN essays e ON d.projectid = e.projectid\nWHERE e.`title` = 'Look, Look, We Need a Nook!';"} {"question_id": 3297, "db_id": "donor", "grading_method": "set", "question": "List the poverty level of all the schools that received donations with the zip code \"7079\".", "evidence": "zip code \"7079\" refers to donor_zip = '7079'", "SQL": "SELECT DISTINCT T2.poverty_level FROM donations AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.donor_zip = 7079"} {"question_id": 3299, "db_id": "donor", "grading_method": "set", "question": "List all the items from \"Sax Arts & Crafts\" and the zip code of the schools that received them.", "evidence": "from \"Sax Arts & Crafts\" refers to vendor_name = 'Sax Arts & Crafts'; zip code of the schools refers school_zip", "SQL": "SELECT T1.item_name, T2.school_zip FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.vendor_name = 'Sax Arts & Crafts'"} {"question_id": 3303, "db_id": "donor", "grading_method": "set", "question": "What grade level was the project \"Too Close for Comfort\" intended for?", "evidence": "The project title is essays.title = 'Too Close for Comfort'; projects.grade_level records its intended grade level.", "SQL": "SELECT T1.grade_level FROM projects AS T1 INNER JOIN essays AS T2 ON T1.projectid = T2.projectid WHERE T2.title LIKE 'Too Close for Comfort'"} {"question_id": 3304, "db_id": "donor", "grading_method": "set", "question": "What is the total number of students impacted by the projects with a donation from a donor with zip code \"22205\"?", "evidence": "zip code \"22205\" refers to donor_zip = '22205'; students impacted refers to students_reached", "SQL": "SELECT SUM(p.`students_reached`) AS total_students\nFROM `projects` p\nWHERE p.`projectid` IN (\n SELECT DISTINCT d.`projectid`\n FROM `donations` d\n WHERE d.`donor_zip` = '22205'\n);"} {"question_id": 3306, "db_id": "donor", "grading_method": "set", "question": "What percentage of technology resource entries are supplied by Best Buy for Business?", "evidence": "technology resource entries refers to resources with project_resource_type = 'Technology'; supplied by Best Buy for Business refers to vendor_name = 'Best Buy for Business'; percentage = DIVIDE(SUM(CASE WHEN vendor_name = 'Best Buy for Business' THEN 1 ELSE 0 END), COUNT(resourceid)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T1.vendor_name = 'Best Buy for Business' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.resourceid) FROM resources AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid WHERE T1.project_resource_type = 'Technology'"} {"question_id": 3308, "db_id": "video_games", "grading_method": "set", "question": "Please list all the games that have the same game genre as 3D Lemmings.", "evidence": "game refers to game_name; 3D Lemmings refers to game_name = '3D Lemmings'", "SQL": "SELECT T1.game_name FROM game AS T1 WHERE T1.genre_id = ( SELECT T.genre_id FROM game AS T WHERE T.game_name = '3D Lemmings' )"} {"question_id": 3310, "db_id": "video_games", "grading_method": "set", "question": "What is the genre of 3D Lemmings?", "evidence": "genre refers to genre_name; 3D Lemmings refers to game_name = '3D Lemmings'", "SQL": "SELECT T2.genre_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T1.game_name = '3D Lemmings'"} {"question_id": 3313, "db_id": "video_games", "grading_method": "set", "question": "Among the games published by 10TACLE Studios, how many of them are puzzles?", "evidence": "published by 10TACLE Studios refers to publisher_name = '10TACLE Studios'; puzzle refers to genre_name = 'Puzzle'", "SQL": "SELECT COUNT(T1.id) FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_id INNER JOIN publisher AS T3 ON T2.publisher_id = T3.id INNER JOIN genre AS T4 ON T1.genre_id = T4.id WHERE T4.genre_name = 'Puzzle' AND T3.publisher_name = '10TACLE Studios'"} {"question_id": 3331, "db_id": "video_games", "grading_method": "set", "question": "Show the IDs of game platforms which make the most sales in Japan.", "evidence": "id of game platform refers to game_platform_id; the most sales refers to max(num_sales); in Japan refers to region_name = 'Japan'", "SQL": "SELECT T2.game_platform_id FROM region_sales AS T2 INNER JOIN region AS T1 ON T1.id = T2.region_id WHERE T1.region_name = 'Japan' GROUP BY T2.game_platform_id HAVING SUM(T2.num_sales) = ( SELECT SUM(T4.num_sales) FROM region_sales AS T4 INNER JOIN region AS T3 ON T3.id = T4.region_id WHERE T3.region_name = 'Japan' GROUP BY T4.game_platform_id ORDER BY SUM(T4.num_sales) DESC LIMIT 1 )"} {"question_id": 3332, "db_id": "video_games", "grading_method": "set", "question": "How many platforms are available for the game Pro Evolution Soccer 2016?", "evidence": "game Pro Evolution Soccer 2016 refers to game_name = 'Pro Evolution Soccer 2016'", "SQL": "SELECT COUNT(DISTINCT T1.platform_id) FROM `game_platform` AS T1 JOIN `game_publisher` AS T3 ON T1.`game_publisher_id` = T3.`id` JOIN `game` AS T4 ON T3.`game_id` = T4.`id` WHERE T4.`game_name` = 'Pro Evolution Soccer 2016'"} {"question_id": 3339, "db_id": "video_games", "grading_method": "set", "question": "Give the number of games which were published by Ascaron Entertainment GmbH.", "evidence": "published by Ascaron Entertainment GmbH refers to publisher_name = 'Ascaron Entertainment GmbH'", "SQL": "SELECT COUNT(T2.game_id) FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id WHERE T1.publisher_name = 'Ascaron Entertainment GmbH'"} {"question_id": 3341, "db_id": "video_games", "grading_method": "set", "question": "What percentage of games in the catalog published by Namco Bandai Games are adventure games? Round your answer to 3 decimal places.", "evidence": "published by Namco Bandai Games refers to a game_publisher row joined to publisher.publisher_name = 'Namco Bandai Games'; adventure game refers to genre.genre_name = 'Adventure'; percentage = DIVIDE(COUNT(DISTINCT game.id that are Adventure), COUNT(DISTINCT game.id published by them)) * 100, rounded to 3 decimals", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN ge.genre_name='Adventure' THEN 1 ELSE 0 END) / COUNT(*) FROM game g LEFT JOIN genre ge ON ge.id=g.genre_id WHERE EXISTS (SELECT 1 FROM game_publisher gp JOIN publisher p ON p.id=gp.publisher_id WHERE gp.game_id=g.id AND p.publisher_name='Namco Bandai Games')\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 3355, "db_id": "video_games", "grading_method": "set", "question": "What is the genre ID of the game named 25 to Life?", "evidence": "the game named 25 to Life refers to game_name = '25 to Life'", "SQL": "SELECT T.genre_id FROM game AS T WHERE T.game_name = '25 to Life'"} {"question_id": 3357, "db_id": "video_games", "grading_method": "set", "question": "Provide the release years of record ID 48.", "evidence": "record ID 48 refers to game.id = 48", "SQL": "SELECT DISTINCT T3.release_year FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_id INNER JOIN game_platform AS T3 ON T2.id = T3.game_publisher_id WHERE T1.id = 48"} {"question_id": 3359, "db_id": "video_games", "grading_method": "set", "question": "List down the record ID of records released between 2000 to 2003.", "evidence": "record ID refers to game.id; released between 2000 to 2003 refers to release_year BETWEEN 2000 AND 2003", "SQL": "SELECT DISTINCT `g`.`id`\nFROM `game` AS g\nJOIN `game_publisher` AS gp ON gp.`game_id` = g.`id`\nJOIN `game_platform` AS gpl ON gpl.`game_publisher_id` = gp.`id`\nWHERE gpl.`release_year` BETWEEN 2000 AND 2003;"} {"question_id": 3360, "db_id": "video_games", "grading_method": "set", "question": "What is the number of sales in region ID 2 with game platform ID 4308?", "evidence": "number of sales refers to multiply(num_sales, 100000)", "SQL": "SELECT SUM(`num_sales`) * 100000 AS total_sales\nFROM `region_sales`\nWHERE `region_id` = 2\n AND `game_platform_id` = 4308;"} {"question_id": 3373, "db_id": "video_games", "grading_method": "set", "question": "Which publishers have a game-platform release whose sales in at least one region exceed 90% of the average sales per game-platform release in Japan?", "evidence": "the threshold refers to MULTIPLY(0.9, AVG(region_sales.num_sales) over rows where region.region_name = 'Japan'); a publisher qualifies when one of its game-platform releases has num_sales above that threshold in any region, not only Japan; return the DISTINCT publisher_name values", "SQL": "SELECT DISTINCT T5.publisher_name FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id INNER JOIN game_platform AS T3 ON T2.game_platform_id = T3.id INNER JOIN game_publisher AS T4 ON T3.game_publisher_id = T4.id INNER JOIN publisher AS T5 ON T4.publisher_id = T5.id WHERE T2.num_sales > ( SELECT AVG(T2.num_sales) * 0.9 FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id WHERE T1.region_name = 'Japan' )"} {"question_id": 3379, "db_id": "video_games", "grading_method": "set", "question": "Provide the genre name of the genre ID 3.", "evidence": "genre ID 3 refers to genre.id = 3", "SQL": "SELECT T.genre_name FROM genre AS T WHERE T.id = 3"} {"question_id": 3385, "db_id": "video_games", "grading_method": "set", "question": "Name the publisher of the Chronicles of the Sword game.", "evidence": "publisher refers to publisher_name; the Chronicles of the Sword game refers to game_name = 'Chronicles of the Sword'", "SQL": "SELECT T3.publisher_name FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_id INNER JOIN publisher AS T3 ON T2.publisher_id = T3.id WHERE T1.game_name = 'Chronicles of the Sword'"} {"question_id": 3395, "db_id": "video_games", "grading_method": "set", "question": "How many games in the catalog were released in 2001?", "evidence": "game is the game catalog. game_platform.release_year records the release year of a platform release; game_publisher links releases to games.", "SQL": "SELECT COUNT(DISTINCT g.id) FROM game g JOIN game_publisher gp ON gp.game_id=g.id JOIN game_platform p ON p.game_publisher_id=gp.id WHERE p.release_year=2001;"} {"question_id": 3421, "db_id": "video_games", "grading_method": "set", "question": "What is the genre of the game '2 Games in 1: Sonic Advance & ChuChu Rocket!'?", "evidence": "genre refers to genre_name; '2 Games in 1: Sonic Advance & ChuChu Rocket!' is a game name;", "SQL": "SELECT T2.genre_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T1.game_name = '2 Games in 1: Sonic Advance & ChuChu Rocket!'"} {"question_id": 3422, "db_id": "video_games", "grading_method": "set", "question": "How many positive sales records are there for the DS platform in the Other region?", "evidence": "region.region_name = 'Other' identifies other regions; platform.platform_name uses 'DS'. region_sales.num_sales records sales.", "SQL": "SELECT COUNT(*) FROM `region_sales` rs JOIN `game_platform` gp ON gp.`id` = rs.`game_platform_id` JOIN `platform` p ON p.`id` = gp.`platform_id` JOIN `region` r ON r.`id` = rs.`region_id` WHERE p.`platform_name` = 'DS' AND r.`region_name` = 'Other' AND rs.`num_sales` > 0;"} {"question_id": 3424, "db_id": "video_games", "grading_method": "set", "question": "How many strategy games are there?", "evidence": "strategy games refers game_name WHERE genre_name = 'Strategy';", "SQL": "SELECT COUNT(CASE WHEN T1.genre_name = 'Strategy' THEN T2.id ELSE NULL END) FROM genre AS T1 INNER JOIN game AS T2 ON T1.id = T2.genre_id"} {"question_id": 3432, "db_id": "video_games", "grading_method": "set", "question": "List the names of publishers that have the word 'Entertainment' in their name.", "evidence": "publishers that have the word 'Entertainment' in their name refers to publisher_name LIKE '%Entertainment%';", "SQL": "SELECT T.publisher_name FROM publisher AS T WHERE T.publisher_name LIKE '%Entertainment%'"} {"question_id": 3433, "db_id": "video_games", "grading_method": "set", "question": "Indicate the names of all adventure games.", "evidence": "genre.genre_name = 'Adventure' identifies the genre; game.game_name records the game name.", "SQL": "SELECT T2.game_name FROM genre AS T1 INNER JOIN game AS T2 ON T1.id = T2.genre_id WHERE T1.genre_name = 'Adventure'"} {"question_id": 3445, "db_id": "video_games", "grading_method": "set", "question": "Calculate the average game sales for the PS2 platform.", "evidence": "average = AVG(MULTIPLY(num_sales), 100000); PS2 refers to platform_name = 'PS2';", "SQL": "SELECT AVG(T3.num_sales * 100000) FROM platform AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.platform_id INNER JOIN region_sales AS T3 ON T2.id = T3.game_platform_id WHERE T1.platform_name = 'PS2'"} {"question_id": 3451, "db_id": "video_games", "grading_method": "set", "question": "What platform is the game 3Xtreme available on?", "evidence": "what platform refers to platform_name; 3Xtreme refers to game_name = '3Xtreme';", "SQL": "SELECT T2.platform_name FROM game_platform AS T1 INNER JOIN platform AS T2 ON T1.platform_id = T2.id INNER JOIN game_publisher AS T3 ON T1.game_publisher_id = T3.id INNER JOIN game AS T4 ON T3.game_id = T4.id WHERE T4.game_name = '3Xtreme'"} {"question_id": 3454, "db_id": "video_games", "grading_method": "set", "question": "How many games were sold on PS3 platform in Japan?", "evidence": "how many games = MULTIPLY(SUM(num_sales), 100000); PS3 refers to platform_name = 'PS3'; Japan refers to region_name = 'Japan';", "SQL": "SELECT SUM(T1.num_sales * 100000) FROM region_sales AS T1 INNER JOIN region AS T2 ON T1.region_id = T2.id INNER JOIN game_platform AS T3 ON T1.game_platform_id = T3.id INNER JOIN platform AS T4 ON T3.platform_id = T4.id WHERE T2.region_name = 'Japan' AND T4.platform_name = 'PS3'"} {"question_id": 3465, "db_id": "video_games", "grading_method": "set", "question": "List down the platform IDs of the games released in 2007.", "evidence": "released in 2007 refers to release_year = 2007;", "SQL": "SELECT DISTINCT T.platform_id FROM game_platform AS T WHERE T.release_year = 2007"} {"question_id": 3467, "db_id": "video_games", "grading_method": "set", "question": "Calculate the number of game publisher IDs for games released in 1984.", "evidence": "released in 1984 refers to release_year = 1984;", "SQL": "SELECT COUNT(DISTINCT `game_publisher_id`) AS num_publisher_ids FROM `game_platform` WHERE `release_year` = 1984"} {"question_id": 3468, "db_id": "video_games", "grading_method": "set", "question": "List the platform IDs of games with region ID 3.", "evidence": "region_sales.region_id identifies region 3 and links through game_platform_id to game_platform.id; game_platform.platform_id is the requested platform ID.", "SQL": "SELECT DISTINCT T2.platform_id FROM region_sales AS T1 INNER JOIN game_platform AS T2 ON T1.game_platform_id = T2.id WHERE T1.region_id = 3"} {"question_id": 3489, "db_id": "video_games", "grading_method": "set", "question": "What is the total number of adventure games released in 2005?", "evidence": "adventure games refers to genre_name = 'Adventure'; released in 2005 refers to release_year = 2005;", "SQL": "SELECT COUNT(DISTINCT T3.id) FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id INNER JOIN genre AS T4 ON T3.genre_id = T4.id WHERE T4.genre_name = 'Adventure' AND T1.release_year = 2005"} {"question_id": 3519, "db_id": "authors", "grading_method": "set", "question": "Which author of the paper \"Incremental Extraction of Keyterms for Classifying Multilingual Documents in the Web\" is affiliated with National Taiwan University Department of Computer Science and Information Engineering Taiwan?", "evidence": "\"Incremental Extraction of Keyterms for Classifying Multilingual Documents in the Web\" is the title of paper; affiliated with refers to Affiliation; \"National Taiwan University Department of Computer Science and Information Engineering Taiwan\" is the Affiliation organization", "SQL": "SELECT T1.Name FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T2.Title = 'Incremental Extraction of Keyterms for Classifying Multilingual Documents in the Web' AND T1.Affiliation = 'National Taiwan University Department of Computer Science and Information Engineering Taiwan'"} {"question_id": 3521, "db_id": "authors", "grading_method": "set", "question": "How many papers whose authors include Thomas Wiegand were published in 1995?", "evidence": "published in 1995 refers to Year = 1995; 'Thomas Wiegand' is the name of author", "SQL": "SELECT COUNT(T2.Title) FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T1.Name = 'Thomas Wiegand' AND T2.Year = 1995"} {"question_id": 3523, "db_id": "authors", "grading_method": "set", "question": "By what percentage did the number of papers published in Cases Journal exceed the number published in Molecular Brain?", "evidence": "papers published in a journal refers to the papers whose journal FullName is that journal; percentage by which Cases Journal papers exceed the Molecular Brain baseline = DIVIDE(SUBTRACT(COUNT(papers with FullName = 'Cases Journal'), COUNT(papers with FullName = 'Molecular Brain')), COUNT(papers with FullName = 'Molecular Brain')) * 100", "SQL": "SELECT 100.0 * (cases_cnt - mol_cnt) / mol_cnt AS percentage_more\nFROM (\n SELECT \n SUM(CASE WHEN J.`FullName` = 'Cases Journal' THEN 1 ELSE 0 END) AS cases_cnt,\n SUM(CASE WHEN J.`FullName` = 'Molecular Brain' THEN 1 ELSE 0 END) AS mol_cnt\n FROM `Paper` P\n JOIN `Journal` J ON P.`JournalId` = J.`Id`\n) t;"} {"question_id": 3525, "db_id": "authors", "grading_method": "set", "question": "List the paper IDs and author IDs for authors affiliated with Cairo Microsoft Innovation Lab, Egypt.", "evidence": "\"Cairo Microsoft Innovation Lab, Egypt\" is the Affiliation organization", "SQL": "SELECT PaperId, AuthorId FROM PaperAuthor WHERE Affiliation LIKE 'Cairo Microsoft Innovation Lab%'"} {"question_id": 3529, "db_id": "authors", "grading_method": "set", "question": "What is the title and journal homepage of the latest published paper?", "evidence": "latest published paper refers to Max(Year)", "SQL": "SELECT T1.Title, T2.HomePage FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Year = (SELECT MAX(T1.Year) FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id)"} {"question_id": 3532, "db_id": "authors", "grading_method": "set", "question": "What is the title of the paper published in 2003 by an author with affiliation with Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications?", "evidence": "published in 2003 refers to Year = 2003; 'Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications' is the Affiliation organization", "SQL": "SELECT DISTINCT T2.Title FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T1.Affiliation = 'Department of Network Science, Graduate School of Information Systems, The University of Electro-Communications' AND T2.Year = 2003"} {"question_id": 3533, "db_id": "authors", "grading_method": "set", "question": "List the authors and journal short name of the papers with \"chemiluminescence\" in its title and has a journal ID from 245 to 250.", "evidence": "with \"chemiluminescence\" in its title refers to Title LIKE 'chemiluminescence%'; journal ID from 245 to 250 refers to JournalId BETWEEN 245 AND 250", "SQL": "SELECT T2.Name, T3.ShortName 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.JournalId BETWEEN 245 AND 250 AND T1.Title LIKE '%chemiluminescence%'"} {"question_id": 3535, "db_id": "authors", "grading_method": "set", "question": "What is the title and author ID of paper with conference ID less than 100 in year 2006?", "evidence": "conference ID less than 100 refers to ConferenceId < 100; in year 2006 refers to Year = 2006", "SQL": "SELECT DISTINCT T1.Title, T2.AuthorId FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Year = 2006 AND T1.ConferenceId < 100"} {"question_id": 3540, "db_id": "authors", "grading_method": "set", "question": "What percentage of papers published from 2001 through 2010 were published in 2001?", "evidence": "published from 2001 through 2010 refers to Paper.Year >= 2001 AND Paper.Year < 2011; percentage = DIVIDE(SUM(CASE WHEN Year = 2001 THEN 1 ELSE 0 END), COUNT(Id)) * 100 over exactly those papers", "SQL": "SELECT CAST(SUM(CASE WHEN Year = 2001 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(Id) FROM Paper WHERE Year >= 2001 AND Year < 2011"} {"question_id": 3548, "db_id": "authors", "grading_method": "set", "question": "Among papers by authors with ID under 1000 who are affiliated with Zurich, ETH, provide paper ID, year and keyword if any.", "evidence": "authors with ID under 1000 refers to AuthorId < 1000; 'Zurich, ETH' is the Affiliation", "SQL": "SELECT T2.Id, T2.Year, T2.Keyword FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T1.AuthorId < 1000 AND T1.Affiliation = 'Zurich, ETH'"} {"question_id": 3549, "db_id": "authors", "grading_method": "set", "question": "For the paper “Inspection resistant memory: Architectural support for security from physical examination,” list the names and IDs of authors affiliated with Microsoft Research, USA.", "evidence": "\"Inspection resistant memory: Architectural support for security from physical examination\" is the title of paper;  'Microsoft Research, USA' is the Affiliation", "SQL": " SELECT T2.Name, T2.AuthorId FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Title = 'Inspection resistant memory: Architectural support for security from physical examination' AND T2.Affiliation = 'Microsoft Research, USA';"} {"question_id": 3554, "db_id": "authors", "grading_method": "subset,=,4", "question": "For the papers which were made in 2013, provide any four valid Journal ID along with short name and full name of the journal", "evidence": "valid journal ID refers to JournalId! = 0 and JournalId! = -1; made in 2013 refers to Year = 2013", "SQL": "SELECT DISTINCT T2.JournalId, T1.ShortName, T1.FullName FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T2.Year = 2013 AND T2.JournalId != 0 AND T2.JournalId != -1"} {"question_id": 3558, "db_id": "authors", "grading_method": "set", "question": "What is the conference homepage for the paper “Energy-efficiency bounds for noise-tolerant dynamic circuits”?", "evidence": "Paper.Title records the paper title; Conference.HomePage records its publication conference’s homepage.", "SQL": "SELECT T2.HomePage FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Title = 'Energy-efficiency bounds for noise-tolerant dynamic circuits'"} {"question_id": 3559, "db_id": "authors", "grading_method": "set", "question": "List the names of authors of papers with IDs from 101 to 105.", "evidence": "PaperAuthor.Name records author names as listed on papers.", "SQL": "SELECT T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Id > 100 AND T1.Id < 106"} {"question_id": 3560, "db_id": "authors", "grading_method": "subset,=,10", "question": "Among papers published in 2009, list 10 distinct conference short names.", "evidence": "Paper.Year = 2009 identifies the papers; Conference.ShortName records the conference short name.", "SQL": "SELECT C.`ShortName`\nFROM `Paper` P\nJOIN `Conference` C ON P.`ConferenceId` = C.`Id`\nWHERE P.`Year` = 2009;"} {"question_id": 3561, "db_id": "authors", "grading_method": "set", "question": "Write down homepage URL of journal for paper \"364: Induction of Mixed Chimerism and Transplantation Tolerance in a Non-Human Primate Lung Allograft Model: Early Results\".", "evidence": "paper \"364: Induction of Mixed Chimerism and Transplantation Tolerance in a Non-Human Primate Lung Allograft Model: Early Results\" refers to Title = '364: Induction of Mixed Chimerism and Transplantation Tolerance in a Non-Human Primate Lung Allograft Model: Early Results'", "SQL": "SELECT T2.HomePage FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Title = '364: Induction of Mixed Chimerism and Transplantation Tolerance in a Non-Human Primate Lung Allograft Model: Early Results'"} {"question_id": 3563, "db_id": "authors", "grading_method": "set", "question": "List the author names as recorded on papers published in 2005 with the keywords “LOAD; IDE; SNP; haplotype; asso- ciation studies”.", "evidence": "Paper.Year records publication year; Paper.Keyword stores 'KEY WORDS: LOAD; IDE; SNP; haplotype; asso- ciation studies'. PaperAuthor.Name records author names as listed on papers.", "SQL": "SELECT T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Year = 2005 AND T1.Keyword = 'KEY WORDS: LOAD; IDE; SNP; haplotype; asso- ciation studies'"} {"question_id": 3567, "db_id": "authors", "grading_method": "set", "question": "How many papers were preprinted between the years 1990 and 2000?", "evidence": "years 1990 and 2000 refers to Year BETWEEN '1990' AND '2000'; papers refers to COUNT(id)", "SQL": "SELECT COUNT(id) FROM Paper WHERE Year BETWEEN '1990' AND '2000' AND ConferenceId = 0 AND JournalId = 0"} {"question_id": 3569, "db_id": "authors", "grading_method": "set", "question": "List the short name of all conferences whose full name begins with International Symposium.", "evidence": "full name refers to FullName LIKE 'International Symposium%'", "SQL": "SELECT ShortName FROM Conference WHERE FullName LIKE 'International Symposium%'"} {"question_id": 3570, "db_id": "authors", "grading_method": "set", "question": "How many journals do not have a website?", "evidence": "do not have a website refers to HomePage = ''", "SQL": "SELECT COUNT(HomePage) FROM Journal WHERE HomePage = ''"} {"question_id": 3574, "db_id": "authors", "grading_method": "set", "question": "Write down the titles of papers that have been published in conferences that do not have a website.", "evidence": "do not have a website refers to HomePage IS NULL OR HomePage = '' OR HomePage = 'NULL'", "SQL": "SELECT T2.Title FROM Conference AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.ConferenceId WHERE T1.HomePage IS NULL OR T1.HomePage = '' OR T1.HomePage = 'NULL'"} {"question_id": 3575, "db_id": "authors", "grading_method": "set", "question": "List the distinct publication-year and journal-full-name pairs for papers in journals with no recorded short name.", "evidence": "A journal has no recorded short name when Journal.ShortName is NULL or an empty string.", "SQL": "SELECT DISTINCT\n P.`Year`,\n J.`FullName`\nFROM `Journal` AS J\nJOIN `Paper` AS P ON J.`Id` = P.`JournalId`\nWHERE J.`ShortName` IS NULL\n OR J.`ShortName` = ''"} {"question_id": 3576, "db_id": "authors", "grading_method": "set", "question": "What affiliations are listed for the authors of the paper \"A combined search for the standard model Higgs boson at s = 1.96   TeV\"?", "evidence": "PaperAuthor.Affiliation is the affiliation listed on a particular paper, rather than Author.Affiliation. In the stored Paper.Title, the gap between '1.96' and 'TeV' is a space, a non-breaking space (U+00A0), and a space.", "SQL": "SELECT DISTINCT T1.Affiliation FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T2.Title = 'A combined search for the standard model Higgs boson at s = 1.96   TeV'"} {"question_id": 3579, "db_id": "authors", "grading_method": "set", "question": "How many papers were published at the International Conference on Database Theory, and in how many distinct years?", "evidence": "the International Conference on Database Theory refers to FullName = 'International Conference on Database Theory'; published refers to year ! = 0", "SQL": "SELECT COUNT(T1.Id) AS PAPER, COUNT(DISTINCT T1.Year) AS YEARS FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE year != 0 AND T2.FullName = 'International Conference on Database Theory'"} {"question_id": 3580, "db_id": "authors", "grading_method": "set", "question": "What are the full names of the journals that published papers whose topic is Sustainability?", "evidence": "The Sustainability topic is recorded as Keyword = 'Sustainability'; journal full names are recorded in Journal.FullName.", "SQL": "SELECT T2.FullName FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Keyword = 'Sustainability'"} {"question_id": 3585, "db_id": "authors", "grading_method": "set", "question": "When was the article \"A Formal Approach to Service Component Architecture\" published?", "evidence": "article \"A Formal Approach to Service Component Architecture\" refers to Title = 'A Formal Approach to Service Component Architecture'", "SQL": "SELECT Year FROM Paper WHERE Title = 'A Formal Approach to Service Component Architecture'"} {"question_id": 3588, "db_id": "authors", "grading_method": "set", "question": "What is the full name of the journal that published the paper \"Multiple paternity in a natural population of a salamander with long-term sperm storage\"?", "evidence": "paper \"Multiple paternity in a natural population of a salamander with long-term sperm storage\" refers to Title = 'Multiple paternity in a natural population of a salamander with long-term sperm storage'", "SQL": "SELECT T2.FullName FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Title = 'Multiple paternity in a natural population of a salamander with long-term sperm storage'"} {"question_id": 3591, "db_id": "authors", "grading_method": "subset,=,2", "question": "Please list the titles of any two papers that Jun Du has written.", "evidence": "papers that Jun Du has written refers to Name = 'Jun Du'", "SQL": "SELECT DISTINCT T1.Title FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T2.Name = 'Jun Du'"} {"question_id": 3592, "db_id": "authors", "grading_method": "set", "question": "What are the distinct titles of papers written by Cheng Huang and affiliated with Microsoft?", "evidence": "paper that was written by Cheng Huang refers to Name = 'Cheng Huang'; affiliated with Microsoft refers to Affiliation LIKE '%Microsoft%'", "SQL": "SELECT DISTINCT `Title` FROM `Paper` AS p JOIN `PaperAuthor` AS pa ON pa.`PaperId` = p.`Id` WHERE pa.`Name` = 'Cheng Huang' AND pa.`Affiliation` LIKE '%Microsoft%';"} {"question_id": 3603, "db_id": "authors", "grading_method": "set", "question": "Give the title and author's name of the papers published between 2000 and 2005 that include the topic optical properties.", "evidence": "published between 2000 and 2005 refers to Year BETWEEN 2000 AND 2005; include the topic optical properties refers to Keyword LIKE '%optical properties%'; title refers to Title that are not null;", "SQL": "SELECT T1.Title, T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Keyword LIKE '%optical properties%' AND T1.Year BETWEEN 2000 AND 2005 AND T1.Title <> ''"} {"question_id": 3605, "db_id": "authors", "grading_method": "set", "question": "List the titles and author names as listed on preprints from 1997, excluding papers with no recorded title.", "evidence": "Paper.Year records the year; preprints have ConferenceId = 0 and JournalId = 0. Paper.Title is the paper title; PaperAuthor.Name is the name listed on the paper.", "SQL": "SELECT DISTINCT T1.Title, T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.ConferenceId = 0 AND T1.JournalId = 0 AND T1.Year = 1997 AND T1.Title <> ''"} {"question_id": 3610, "db_id": "authors", "grading_method": "set", "question": "How many papers are published under the conference \"Mathematics of Program Construction\"?", "evidence": "'Mathematics of Program Construction' is the FullName of conference; published means year <> 0", "SQL": "SELECT COUNT(T1.Id) FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T2.FullName = 'Mathematics of Program Construction' AND T1.year <> 0"} {"question_id": 3613, "db_id": "authors", "grading_method": "set", "question": "Who authored the paper titled \"Testing timed automata\"?", "evidence": "'Testing timed automata' is a title of a paper; Who authored refers to PaperAuthor.Name", "SQL": "SELECT T2.Name FROM Paper AS T1 INNER JOIN PaperAuthor AS T2 ON T1.Id = T2.PaperId WHERE T1.Title = 'Testing timed automata'"} {"question_id": 3618, "db_id": "authors", "grading_method": "set", "question": "How many papers are published under the journal \"Software - Practice and Experience\"?", "evidence": "papers refers to Paper.Id; 'Software - Practice and Experience' is the FullName of a journal;", "SQL": "SELECT COUNT(T1.Id) FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T2.FullName = 'Software - Practice and Experience'"} {"question_id": 3619, "db_id": "authors", "grading_method": "set", "question": "List all the paper that were under the conference homepage URL \"http://www.irma-international.org/\".", "evidence": "paper refers to Paper.Title; http://www.irma-international.org/ is the HomePage", "SQL": "SELECT T1.Title FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T2.HomePage = 'http://www.irma-international.org/'"} {"question_id": 3620, "db_id": "authors", "grading_method": "set", "question": "What was the average number of papers published per year at the Information and Knowledge Engineering conference from 2002 through 2010?", "evidence": "the conference refers to Conference.FullName = 'Information and Knowledge Engineering'; from 2002 through 2010 refers to Paper.Year >= 2002 AND Paper.Year <= 2010; average papers per year = DIVIDE(COUNT(the Paper rows at that conference in that period), 9.0), a fixed nine calendar year divisor and not the number of years that carry papers", "SQL": "SELECT CAST(COUNT(T1.Id) AS REAL) / 9.0 FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T2.FullName = 'Information and Knowledge Engineering' AND T1.Year >= 2002 AND T1.Year <= 2010"} {"question_id": 3628, "db_id": "authors", "grading_method": "set", "question": "At which conference was the paper \"Skew-Circulant Preconditioners for Systems of LMF-Based ODE Codes\" presented?", "evidence": "'Skew-Circulant Preconditioners for Systems of LMF-Based ODE Codes' is the Title of the paper; conference refers to Conference.FullName", "SQL": "SELECT T2.FullName FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T1.Title = 'Skew-Circulant Preconditioners for Systems of LMF-Based ODE Codes'"} {"question_id": 3632, "db_id": "authors", "grading_method": "set", "question": "In the year 2012, which conferences had the most papers presented? Give the short name of the conferences.", "evidence": "Papers refers to Paper.Id; short name of the conference refers to Conference.ShortName", "SQL": "SELECT T2.ShortName \nFROM Paper AS T1 \nINNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id \nWHERE T1.Year = '2012' \n AND T1.ConferenceId > 0\nGROUP BY T1.ConferenceId\nHAVING COUNT(T1.Id) = (\n SELECT COUNT(T1.Id)\n FROM Paper AS T1\n WHERE T1.Year = '2012'\n AND T1.ConferenceId > 0\n GROUP BY T1.ConferenceId\n ORDER BY COUNT(T1.Id) DESC\n LIMIT 1\n)"} {"question_id": 3633, "db_id": "authors", "grading_method": "set", "question": "How many papers were presented at 'ECSQARU' in 2003?", "evidence": "Papers refers to Paper.Id; ECSQARU is the ShortName of the conference; 2003 refers to Year = '2003'", "SQL": "SELECT COUNT(T1.Id) FROM Paper AS T1 INNER JOIN Conference AS T2 ON T1.ConferenceId = T2.Id WHERE T2.ShortName = 'ECSQARU' AND T1.Year = '2003'"} {"question_id": 3646, "db_id": "authors", "grading_method": "set", "question": "What is the short name for the journal that published the paper \"A Case of Unilateral Ashy Dermatosis\"?", "evidence": "A Case of Unilateral Ashy Dermatosis refer to Title", "SQL": "SELECT T2.ShortName FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Title = 'A Case of Unilateral Ashy Dermatosis'"} {"question_id": 3648, "db_id": "authors", "grading_method": "set", "question": "Who are the authors of the paper \"Determination of Planetary Meteorology from Aerobot Flight Sensors\"?", "evidence": "'Determination of Planetary Meteorology from Aerobot Flight Sensors' refer to title of the paper", "SQL": "SELECT pa.`Name`\nFROM `Paper` AS p\nJOIN `PaperAuthor` AS pa ON p.`Id` = pa.`PaperId`\nWHERE p.`Title` = 'Determination of Planetary Meteorology from Aerobot Flight Sensors';"} {"question_id": 3651, "db_id": "authors", "grading_method": "set", "question": "What are the different ways the name of the author, Randall Davis, is written on their papers? Exclude \"Randall Davis\" in your result.", "evidence": "Randall Davis refer to Author.Name", "SQL": "SELECT DISTINCT T1.Name FROM PaperAuthor AS T1 INNER JOIN Author AS T2 ON T1.AuthorId = T2.Id WHERE T2.Name = 'Randall Davis' AND T1.Name != 'Randall Davis'"} {"question_id": 3657, "db_id": "authors", "grading_method": "set", "question": "List the names of authors affiliated with the University of Illinois Chicago.", "evidence": "'University of Illinois Chicago' is an affiliation", "SQL": "SELECT Name FROM Author WHERE Affiliation = 'University of Illinois Chicago'"} {"question_id": 3659, "db_id": "authors", "grading_method": "set", "question": "State the title of papers published in the Ibm Journal of Research and Development.", "evidence": "Ibm Journal of Research and Development refer to FullName", "SQL": "SELECT T2.Title FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.FullName = 'Ibm Journal of Research and Development'"} {"question_id": 3661, "db_id": "authors", "grading_method": "set", "question": "How many authors have published papers in IEEE Computer?", "evidence": "IEEE Computer refers to Journal.FullName = 'IEEE Computer'; how many authors refers to COUNT(DISTINCT PaperAuthor.AuthorId) over the papers in that journal, each author counted once however many papers they wrote", "SQL": "SELECT COUNT(DISTINCT pa.AuthorId) FROM PaperAuthor AS pa JOIN Paper AS p ON pa.PaperId = p.Id JOIN Journal AS j ON p.JournalId = j.Id WHERE j.FullName = 'IEEE Computer';"} {"question_id": 3669, "db_id": "authors", "grading_method": "set", "question": "Provide the title of the latest publications published by the author 'Zuliang Du'.", "evidence": "'Zuliang Du' is the name of paper author; latest publication refers to MAX(Year)", "SQL": "SELECT T2.Title \nFROM PaperAuthor AS T1 \nINNER JOIN Paper AS T2 ON T1.PaperId = T2.Id \nWHERE T1.Name = 'Zuliang Du'\n AND T2.Year = (\n SELECT MAX(T2.Year)\n FROM PaperAuthor AS T1\n INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id\n WHERE T1.Name = 'Zuliang Du'\n )"} {"question_id": 3670, "db_id": "authors", "grading_method": "set", "question": "How many publications were published in relation to the conference 'Adaptive Multimedia Retrieval' in 2007?", "evidence": "'Adaptive Multimedia Retrieval' is the FullName of paper; in 2007 refer to Year = 2007", "SQL": "SELECT COUNT(T2.ConferenceId) FROM Conference AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.ConferenceId WHERE T1.FullName = 'Adaptive Multimedia Retrieval' AND T2.Year = 2007"} {"question_id": 3673, "db_id": "authors", "grading_method": "set", "question": "Of all publications whose keywords contain 'Turbulent Flows', what percentage were published in 'Physics of Fluids'? Round your answer to 3 decimal places.", "evidence": "keywords contain 'Turbulent Flows' refers to Paper.Keyword LIKE '%Turbulent Flows%'; percentage = ROUND(DIVIDE(SUM(CASE WHEN Journal.FullName = 'Physics of Fluids' THEN 1 ELSE 0 END), COUNT(*)) * 100, 3) over those publications, with publications having no Journal record still counted in the denominator", "SQL": "SELECT ROUND(100.0 * SUM(CASE WHEN j.FullName='Physics of Fluids' THEN 1 ELSE 0 END) / COUNT(*), 3) FROM Paper p LEFT JOIN Journal j ON p.JournalId=j.Id WHERE p.Keyword LIKE '%Turbulent Flows%'"} {"question_id": 3675, "db_id": "authors", "grading_method": "set", "question": "List out the full name and URL link of ICCI?", "evidence": "'ICCI' is the ShortName of conference; URL refer to HomePage", "SQL": "SELECT FullName, HomePage FROM Conference WHERE ShortName = 'ICCI'"} {"question_id": 3677, "db_id": "authors", "grading_method": "set", "question": "How many different papers were written by authors whose recorded author affiliation is University of Hong Kong?", "evidence": "Author.Affiliation records an author’s affiliation; 'University of Hong Kong' is the requested value. PaperAuthor records authorship of papers.", "SQL": "SELECT COUNT(DISTINCT T2.`PaperId`) FROM `Author` AS T1 JOIN `PaperAuthor` AS T2 ON T1.`Id` = T2.`AuthorId` WHERE T1.`Affiliation` = 'University of Hong Kong';"} {"question_id": 3686, "db_id": "college_completion", "grading_method": "set", "question": "Among institutions with a recorded median SAT score, what is the average of those scores in the state with the largest male graduate cohort in 2013? Round your answer to 2 decimal places.", "evidence": "the largest male graduate cohort in 2013 refers to the state with the greatest SUM(grad_cohort) where gender = 'M' and year = 2013, leaving out the 'United States' national aggregate; a recorded median SAT score refers to med_sat_value that is not the text 'NULL'; answer = ROUND(AVG(med_sat_value), 2) over the institutions in that state", "SQL": "WITH top_state AS (SELECT state FROM state_sector_grads WHERE year=2013 AND gender='M' AND state<>'United States' GROUP BY state ORDER BY SUM(CAST(grad_cohort AS INTEGER)) DESC LIMIT 1) SELECT ROUND(AVG(CAST(NULLIF(TRIM(med_sat_value),'NULL') AS REAL)), 2) FROM institution_details WHERE state IN (SELECT state FROM top_state)"} {"question_id": 3687, "db_id": "college_completion", "grading_method": "set", "question": "Name the states with the most number of graduate cohort in 2012 from private institute for profit? List all such institutes in the mentioned states.", "evidence": "most number of graduate cohort refers to MAX(SUM(grad_cohort)); in 2012 refers to year = 2012; private institute for profit refers to control = 'Private for-profit'; institutes refers to chronname;", "SQL": "WITH state_totals AS (\n SELECT `state`, SUM(CAST(`grad_cohort` AS INTEGER)) AS total_grads\n FROM `state_sector_grads`\n WHERE `year` = 2012\n AND `control` = 'Private for-profit'\n AND `state` <> 'United States'\n AND `race` = 'X'\n GROUP BY `state`\n),\ntop_state AS (\n SELECT `state`\n FROM state_totals\n WHERE total_grads = (SELECT MAX(total_grads) FROM state_totals)\n)\nSELECT i.`state`, i.`chronname`\nFROM `institution_details` i\nJOIN top_state ts ON i.`state` = ts.`state`\nWHERE i.`control` = 'Private for-profit'"} {"question_id": 3688, "db_id": "college_completion", "grading_method": "set", "question": "Which public institutions are in the state with the fewest graduate-cohort students at public institutions in 2013? List their names.", "evidence": "public refers to control = 'Public'; the state with the fewest graduate-cohort students in 2013 refers to the state whose SUM(state_sector_grads.grad_cohort) over the state_sector_grads records with year = 2013, control = 'Public', gender = 'B' and race = 'X' equals the MIN of those per-state totals; return the institution_details.chronname of the public institutions in that state", "SQL": "WITH state_totals AS (\n SELECT `state`,\n SUM(CAST(`grad_cohort` AS INTEGER)) AS total_cohort\n FROM `state_sector_grads`\n WHERE `year` = 2013\n AND `control` = 'Public'\n AND `gender` = 'B'\n AND `race` = 'X'\n GROUP BY `state`\n),\nmin_state AS (\n SELECT `state`\n FROM state_totals\n WHERE total_cohort = (SELECT MIN(total_cohort) FROM state_totals)\n)\nSELECT DISTINCT `chronname`\nFROM `institution_details`\nWHERE `state` IN (SELECT `state` FROM min_state)\n AND `control` = 'Public';"} {"question_id": 3689, "db_id": "college_completion", "grading_method": "set", "question": "Provide names of all the institutes with less than 200 graduate cohort of all races and genders in 2013. Also, please state the total number of full-time equivalent undergraduates for the institutes.", "evidence": "institute name refers to chronname; less than 200 graduate cohort refers to grad_cohort < 200; grad_cohort is stored as text and an unavailable cohort appears as empty text or as the four letters NULL, which are excluded rather than read as zero; all races refers to race = 'X'; all genders refers to gender = 'B'; in 2013 refers to year = 2013; total number of full-time equivalent undergraduates refers to fte_value;", "SQL": "SELECT DISTINCT d.`chronname`, d.`fte_value`\nFROM `institution_details` AS d\nJOIN `institution_grads` AS g ON d.`unitid` = g.`unitid`\nWHERE g.`year` = 2013 AND g.`gender` = 'B' AND g.`race` = 'X'\n AND g.`grad_cohort` NOT IN ('NULL', '')\n AND CAST(g.`grad_cohort` AS INTEGER) < 200"} {"question_id": 3693, "db_id": "college_completion", "grading_method": "set", "question": "What percentage of students across all recorded graduation cohorts at private for-profit institutions are Black?", "evidence": "private for-profit refers to institution_details.control = 'Private for-profit'; Black students refers to SUM(grad_cohort) over institution_grads rows with race = 'B' AND gender = 'B'; all students refers to the same SUM with race = 'X' AND gender = 'B'; percentage = DIVIDE(the Black students total, the all students total) * 100", "SQL": "SELECT 100.0 *\n SUM(CASE WHEN g.`race` = 'B' AND g.`gender` = 'B'\n THEN CAST(g.`grad_cohort` AS REAL) ELSE 0 END)\n / SUM(CASE WHEN g.`race` = 'X' AND g.`gender` = 'B'\n THEN CAST(g.`grad_cohort` AS REAL) ELSE 0 END) AS pct_black\nFROM `institution_details` d\nJOIN `institution_grads` g ON d.`unitid` = g.`unitid`\nWHERE d.`control` = 'Private for-profit';"} {"question_id": 3694, "db_id": "college_completion", "grading_method": "set", "question": "Calculate the percentage of Asian students among students of all races who graduated from institutions in Alabama in 2013 within 100% of the normal or expected time.", "evidence": "Asian students refers to race = 'A' and students of all races refers to race = 'X'; within institution_details state = 'Alabama' and institution_grads year = 2013, percentage = DIVIDE(SUM(grad_100 where race = 'A'), SUM(grad_100 where race = 'X')) * 100", "SQL": "SELECT 100.0 * SUM(CASE WHEN g.race = 'A' THEN CAST(g.grad_100 AS INTEGER) ELSE 0 END)\n / SUM(CASE WHEN g.race = 'X' THEN CAST(g.grad_100 AS INTEGER) ELSE 0 END) AS pct_of_asian_vs_other\n FROM `institution_details` d\n JOIN `institution_grads` g ON d.`unitid` = g.`unitid`\n WHERE d.`state` = 'Alabama'\n AND g.`year` = 2013\n AND g.`grad_100` IS NOT NULL;"} {"question_id": 3695, "db_id": "college_completion", "grading_method": "set", "question": "What is the ratio of Asian male total cohort size to Asian female total cohort size from Harvard University in 2013?", "evidence": "ratio = MULTIPLY(DIVIDE(SUM(grad_cohort WHERE Gender = 'M'), SUM( grad_cohort WHERE Gender = 'F')), 1.0); Asian refers to race = 'A'; female refers to gender = 'F'; graduates refers to grad_cohort; male refers to gender = 'M'; Harvard University refers to chronname = 'Harvard University'; in 2013 refers to year = 2013;", "SQL": "SELECT CAST(SUM(CASE WHEN T2.Gender = 'M' THEN T2.grad_cohort ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.Gender = 'F' THEN T2.grad_cohort ELSE 0 END) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T1.unitid = T2.unitid WHERE T1.chronname = 'Harvard University' AND T2.year = 2013 AND T2.race = 'A'"} {"question_id": 3696, "db_id": "college_completion", "grading_method": "set", "question": "For which institute was it harder to graduate with a bachelor’s degree, Amridge University or Auburn University?", "evidence": "institute refers to institution_details.chronname restricted to 'Amridge University' and 'Auburn University'; graduating with a bachelor's degree within normal time refers to grad_100_value; harder to graduate refers to the smaller grad_100_value of the two; return that single chronname", "SQL": "SELECT chronname FROM institution_details WHERE chronname IN ('Amridge University', 'Auburn University') ORDER BY grad_100_value LIMIT 1"} {"question_id": 3699, "db_id": "college_completion", "grading_method": "set", "question": "How many students, who graduated from Alabama State University in 2011 within 150 percent of normal/expected time, belong to the cohort type of Bachelor's/equivalent seeking cohort at 4-year institutions?", "evidence": "Alabama State University refers to chronname = 'Alabama State University'; in 2011 refers to year = 2011; Bachelor's/equivalent seeking cohort at 4-year institutions refers to cohort = '4y bach';", "SQL": "SELECT CAST(`grad_150` AS INTEGER) AS graduates\nFROM `institution_grads`\nWHERE `unitid` = (SELECT `unitid` FROM `institution_details` WHERE `chronname` = 'Alabama State University')\n AND `year` = 2011\n AND `cohort` = '4y bach'\n AND `gender` = 'B'\n AND `race` = 'X';"} {"question_id": 3709, "db_id": "college_completion", "grading_method": "set", "question": "Which institutions in Alabama had a total graduate cohort of more than 500 students in 2011? List their names.", "evidence": "Institution name is institution_details.chronname; Alabama is institution_details.state = 'Alabama'. Graduate cohort is institution_grads.grad_cohort. All-race records use race = 'X', combined-gender records use gender = 'B', and 2011 is institution_grads.year = 2011. institution_grads.cohort identifies the cohort type; cohort counts are recorded separately by type, so an institution can have multiple records for the same year, race, and gender.", "SQL": "SELECT d.`chronname`\nFROM `institution_details` AS d\nJOIN `institution_grads` AS g\n ON g.`unitid` = d.`unitid`\nWHERE d.`state` = 'Alabama'\n AND g.`year` = 2011\n AND g.`race` = 'X'\n AND g.`gender`= 'B'\nGROUP BY d.`unitid`\nHAVING SUM(CAST(g.`grad_cohort` AS INTEGER)) > 500;"} {"question_id": 3710, "db_id": "college_completion", "grading_method": "set", "question": "What's the average cohort size for Central Alabama Community College in the 3 consecutive years from 2011 to 2013?", "evidence": "institution_details.chronname records 'Central Alabama Community College'. institution_grads.grad_cohort records cohort size; gender = 'B' denotes both genders and race = 'X' denotes all races.", "SQL": "SELECT AVG(T2.grad_cohort) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.chronname = 'Central Alabama Community College' AND T2.year IN (2011, 2012, 2013) AND T2.gender = 'B' AND T2.race = 'X'"} {"question_id": 3711, "db_id": "college_completion", "grading_method": "set", "question": "What is the average percentage of students graduating within 100 percent of normal/expected time for Central Alabama Community College?", "evidence": "institution_details.chronname records 'Central Alabama Community College'. institution_grads.grad_100_rate is the percentage graduating within the expected time; race = 'X' denotes all races and gender = 'B' both genders. Empty text and the text 'NULL' denote unavailable rates.", "SQL": "SELECT AVG(CAST(g.`grad_100_rate` AS REAL)) AS avg_grad_100_rate\nFROM `institution_details` AS d\nJOIN `institution_grads` AS g ON g.`unitid` = d.`unitid`\nWHERE d.`chronname` = 'Central Alabama Community College'\n AND g.`gender` = 'B'\n AND g.`race` = 'X'\n AND g.`grad_100_rate` NOT IN ('', 'NULL')"} {"question_id": 3715, "db_id": "college_completion", "grading_method": "set", "question": "Tell the abbreviation for \"Delaware\" state.", "evidence": "abbreviation for state refers to state_abbr;", "SQL": "SELECT T FROM ( SELECT DISTINCT CASE WHEN state = 'Delaware' THEN state_abbr ELSE NULL END AS T FROM state_sector_grads ) WHERE T IS NOT NULL"} {"question_id": 3716, "db_id": "college_completion", "grading_method": "set", "question": "How many 2-year public schools are there in \"California\"?", "evidence": "2-year refers to level = '2-year'; public refers to control = 'public'; California refers to state = 'California';", "SQL": "SELECT `schools_count`\nFROM `state_sector_details`\nWHERE `state` = 'California'\n AND `level` = '2-year'\n AND `control` = 'Public';"} {"question_id": 3720, "db_id": "college_completion", "grading_method": "set", "question": "Tell the number of 4-year public schools in UT whose graduation rate exceeds the average for the state.", "evidence": "4-year refers to level = '4-year'; public refers to control = 'Public'; UT refers to state_abbr = 'UT'; graduation rate exceeds the average for the state refers to awards_per_value > awards_per_state_value;", "SQL": "SELECT COUNT(DISTINCT T1.chronname) FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T2.state = T1.state WHERE T2.state_abbr = 'UT' AND T1.level = '4-year' AND T1.control = 'Public' AND T1.awards_per_value > T1.awards_per_state_value"} {"question_id": 3723, "db_id": "college_completion", "grading_method": "set", "question": "Which 4-year private for-profit school in \"KY\" has the highest graduation 150 value? Give the ID for the school.", "evidence": "4-year refers to level = '4-year'; private for profit refers to control = 'Private for-profit'; KY refers to state_abbr = 'KY'; highest graduation 150 value refers to MAX(grad_150_value); ID of the school refers to unitid;", "SQL": "SELECT DISTINCT T1.unitid \nFROM institution_details AS T1 \nINNER JOIN state_sector_grads AS T2 ON T2.state = T1.state \nWHERE T2.state_abbr = 'KY' \n AND T1.level = '4-year' \n AND T1.control = 'Private for-profit'\n AND T1.grad_150_value = (\n SELECT MAX(T1.grad_150_value)\n FROM institution_details AS T1\n INNER JOIN state_sector_grads AS T2 ON T2.state = T1.state\n WHERE T2.state_abbr = 'KY'\n AND T1.level = '4-year'\n AND T1.control = 'Private for-profit'\n );"} {"question_id": 3726, "db_id": "college_completion", "grading_method": "set", "question": "Tell the number of 4-year private not-for-profit schools in the home state of \"Brevard Community College\".", "evidence": "4-year refers to level = '4-year'; private not-for-profit refers to control = 'Private not-for-profit'; Brevard Community College refers to chronname = 'Brevard Community College';", "SQL": "SELECT COUNT(*)\nFROM `institution_details`\nWHERE `state` = (\n SELECT `state`\n FROM `institution_details`\n WHERE `chronname` = 'Brevard Community College'\n )\n AND `level` = '4-year'\n AND `control` = 'Private not-for-profit';"} {"question_id": 3728, "db_id": "college_completion", "grading_method": "set", "question": "For the state with 113 two-year public schools, how many Asian students graduated in 2013 while seeking another degree or certificate at a two-year institution?", "evidence": "State-sector school count is state_sector_details.schools_count; 113 is the requested value. Two-year public records use level = '2-year' and control = 'Public'. Asian students use race = 'A', combined gender uses gender = 'B', the cohort code is '2y all', and 2013 is year = 2013. Graduated-student value is state_sector_grads.grad_150.", "SQL": "SELECT CAST(`grad_150` AS INTEGER) AS graduated_students FROM `state_sector_grads` WHERE `level`='2-year' AND `control`='Public' AND `race`='A' AND `gender`='B' AND `cohort`='2y all' AND `year`=2013 AND `stateid` = ( SELECT `stateid` FROM `state_sector_details` WHERE `level`='2-year' AND `control`='Public' AND `schools_count`=113 LIMIT 1);"} {"question_id": 3729, "db_id": "college_completion", "grading_method": "set", "question": "What percentage of schools in Madison Area Technical College’s home state are four-year public schools?", "evidence": "The college’s state is institution_details.state for chronname = 'Madison Area Technical College'; four-year public schools have level = '4-year' and control = 'Public'.", "SQL": "SELECT CAST(COUNT(CASE WHEN level = '4-year' AND control = 'Public' THEN 1 END) AS REAL) * 100.0 / COUNT(*) FROM institution_details WHERE state = ( SELECT state FROM institution_details WHERE chronname = 'Madison Area Technical College' )"} {"question_id": 3733, "db_id": "college_completion", "grading_method": "set", "question": "Which race categories are recorded in graduation data for states with 20 or fewer public colleges and universities combined?", "evidence": "state_sector_details.schools_count records institution counts separately by state, level, and control. Public institutions have control = 'Public'; level distinguishes two-year and four-year institutions. Race categories are recorded in state_sector_grads.race; 'X' means all students, not a race category.", "SQL": "WITH eligible_states AS (\n SELECT stateid\n FROM state_sector_details\n WHERE control = 'Public'\n GROUP BY stateid\n HAVING SUM(schools_count) <= 20\n)\nSELECT DISTINCT g.race\nFROM state_sector_grads AS g\nINNER JOIN eligible_states AS s ON s.stateid = g.stateid\nWHERE g.race <> 'X';"} {"question_id": 3741, "db_id": "college_completion", "grading_method": "set", "question": "Among female students in 2012, how many of them are from a state with the number of schools ranging from 10 to 20?", "evidence": "female refers to gender = 'F'; number of schools refers to SUM(schools_count);", "SQL": "WITH state_totals AS (\n SELECT sd.stateid\n FROM `state_sector_details` sd\n GROUP BY sd.stateid\n HAVING SUM(sd.`schools_count`) BETWEEN 10 AND 20\n)\nSELECT SUM(CAST(sg.`grad_cohort` AS INTEGER)) AS female_students\nFROM `state_sector_grads` sg\nJOIN state_totals st ON st.stateid = sg.stateid\nWHERE sg.`year` = 2012\n AND sg.`gender` = 'F'\n AND sg.`race` = 'X';"} {"question_id": 3744, "db_id": "college_completion", "grading_method": "set", "question": "In the state of Connecticut, what are the names of the institutions with the highest percent rank for freshman retention percentage within the sector?", "evidence": "name of the institution refers to chronname;  highest percent rank for freshman retention percentage within the sector refers to MAX(retain_percentile);", "SQL": "SELECT chronname FROM institution_details WHERE state = 'Connecticut' AND retain_percentile = ( SELECT MAX(retain_percentile) FROM institution_details WHERE state = 'Connecticut' )"} {"question_id": 3752, "db_id": "college_completion", "grading_method": "set", "question": "In the state with the most colleges and universities across all sectors, how many institutions have at least 90% of their undergraduates attending full-time?", "evidence": "state_sector_details.schools_count records the number of institutions in a state-sector category; United States is a national aggregate. institution_details.ft_pct records the percentage of undergraduates attending full-time.", "SQL": "WITH top_state AS (\n SELECT `state`\n FROM `state_sector_details`\n WHERE `state` <> 'United States'\n GROUP BY `state`\n ORDER BY SUM(`schools_count`) DESC\n LIMIT 1\n)\nSELECT COUNT(*) AS num_institutions\nFROM `institution_details`\nWHERE `state` = (SELECT `state` FROM top_state)\n AND `ft_pct` >= 90;"} {"question_id": 3755, "db_id": "college_completion", "grading_method": "set", "question": "Among the Ivy League Schools in 2013, which schools have the highest number of Black students who graduated within 150 percent of normal/expected time who were seeking a bachelor's/equivalent cohort at 4-year institutions?", "evidence": "Ivy League Schools refers to chronname = 'Brown University' or chronname = 'Columbia University' or chronname = 'Cornell University' or chronname = 'Dartmouth College' or chronname = 'Harvard University' or chronname = 'Princeton University' or chronname = 'University of Pennsylvania' or chronname = 'Yale University'; in 2013 refers to year = '2013'; highest number of Black students who graduated within 150 percent of normal/expected time refers to MAX(grad_150 WHERE race = 'B'); seeking a bachelor's/equivalent cohort at 4-year institutions refers to cohort = '4y bach';", "SQL": "WITH ivy AS (\n SELECT d.`chronname`,\n CAST(g.`grad_150` AS INTEGER) AS g150\n FROM `institution_details` d\n JOIN `institution_grads` g ON g.`unitid` = d.`unitid`\n WHERE d.`chronname` IN ('Brown University','Columbia University','Cornell University',\n 'Dartmouth College','Harvard University','Princeton University',\n 'University of Pennsylvania','Yale University')\n AND g.`year` = 2013\n AND g.`race` = 'B'\n AND g.`cohort` = '4y bach'\n AND g.`gender` = 'B' \n)\nSELECT `chronname`\nFROM ivy\nWHERE g150 = (SELECT MAX(g150) FROM ivy);"} {"question_id": 3757, "db_id": "college_completion", "grading_method": "set", "question": "Which school’s completion rate exceeds its national sector average by the most? For that school’s state, report the higher-education funding per resident in fiscal year 2011.", "evidence": "completion rate refers to institution_details.awards_per_value and the national sector average to awards_per_natl_value; exceeds it by the most refers to MAX(SUBTRACT(awards_per_value, awards_per_natl_value)); report both that school's chronname and state_sector_details.state_appr_value", "SQL": "SELECT i.`chronname`,\n s.`state_appr_value`\nFROM `institution_details` AS i\nJOIN `state_sector_details` AS s\n ON s.`state` = i.`state`\n AND s.`level` = i.`level`\n AND s.`control` = i.`control`\nORDER BY (i.`awards_per_value` - i.`awards_per_natl_value`) DESC\nLIMIT 1;"} {"question_id": 3760, "db_id": "public_review_platform", "grading_method": "set", "question": "How many long reviews does user No. 36139 give for the Yelp businesses?", "evidence": "long reviews refers to review_length = 'Long'; user No. refers to user_id;", "SQL": "SELECT COUNT(review_length) FROM Reviews WHERE user_id = 36139 AND review_length LIKE 'long'"} {"question_id": 3765, "db_id": "public_review_platform", "grading_method": "set", "question": "How many more businesses are categorized as Buffets than as Gyms?", "evidence": "Buffets refers to Categories.category_name LIKE 'Buffets' and Gyms to category_name LIKE 'Gyms'; how many more = SUBTRACT(SUM(CASE WHEN category_name LIKE 'Buffets' THEN 1 ELSE 0 END), SUM(CASE WHEN category_name LIKE 'Gyms' THEN 1 ELSE 0 END)), summed over the businesses categorized in Categories", "SQL": "SELECT SUM(CASE WHEN T1.category_name LIKE 'Buffets' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.category_name LIKE 'Gyms' THEN 1 ELSE 0 END) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id"} {"question_id": 3773, "db_id": "public_review_platform", "grading_method": "set", "question": "There was only one short tip that user No. 69722 gave to the Yelp business, what was the rating of that business?", "evidence": "short tip refers to tip_lenghth = 'Short'; user No. refers to user_id; ratings refers to stars;", "SQL": "SELECT T2.stars FROM Tips AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.user_id = 69722 AND T1.tip_length = 'Short'"} {"question_id": 3776, "db_id": "public_review_platform", "grading_method": "set", "question": "How many users started using Yelp in 2004 or later?", "evidence": "Users.user_yelping_since_year records the year a user joined Yelp.", "SQL": "SELECT COUNT(`user_id`) FROM `Users` WHERE `user_yelping_since_year` >= 2004;"} {"question_id": 3791, "db_id": "public_review_platform", "grading_method": "set", "question": "Which users have a high number of \"funny\" type of compliments? Give the user ID.", "evidence": "type of compliments refers to compliment_type; high number of compliments refers to number_of_compliments = 'High';", "SQL": "SELECT user_id FROM Users_Compliments WHERE number_of_compliments = 'High' AND compliment_id IN ( SELECT compliment_id FROM Compliments WHERE compliment_type LIKE 'funny' )"} {"question_id": 3794, "db_id": "public_review_platform", "grading_method": "set", "question": "For Yelp businesses that allow customers to bring their own beer, what percentage are in Phoenix?", "evidence": "allow customers to bring their own beer refers to Attributes.attribute_name = 'BYOB' with Business_Attributes.attribute_value = 'TRUE'; percentage in Phoenix = DIVIDE(SUM(CASE WHEN Business.city = 'Phoenix' THEN 1 ELSE 0 END), COUNT(those Yelp businesses)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T3.city LIKE 'Phoenix' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.business_id) AS \"percentage\" FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name LIKE 'BYOB' AND T2.attribute_value LIKE 'TRUE'"} {"question_id": 3796, "db_id": "public_review_platform", "grading_method": "set", "question": "How many active businesses are underrated?", "evidence": "active businesses refers to active = 'true'; underrated refers to review_count = 'Low';", "SQL": "SELECT COUNT(business_id) FROM Business WHERE review_count LIKE 'Low' AND active LIKE 'TRUE'"} {"question_id": 3808, "db_id": "public_review_platform", "grading_method": "set", "question": "Provide the business IDs in Tempe city whose opening hours are earlier than 8AM for at least one day of a week", "evidence": "opening hours refers to opening_time;", "SQL": "SELECT DISTINCT T1.business_id FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id WHERE T1.city LIKE 'Tempe' AND (T2.opening_time = '12AM' OR (T2.opening_time LIKE '%AM' AND CAST(REPLACE(T2.opening_time, 'AM', '') AS INTEGER) < 8))"} {"question_id": 3810, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses are in Phoenix, and what percentage of all businesses are in Phoenix?", "evidence": "", "SQL": "SELECT\n COUNT(*) AS num_phoenix,\n CAST(COUNT(*) AS REAL) * 100.0 /\n (SELECT COUNT(*) FROM `Business`) AS perc_phoenix\nFROM `Business`\nWHERE `city` = 'Phoenix';"} {"question_id": 3811, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the businesses with active life category, find the percentage of the businesses whose review count is low.", "evidence": "category refers to category_name; percentage = MULTIPLY(DIVIDE(SUM(review_count = 'Low'), SUM(category_name = 'Active Life')), 100.0);", "SQL": "SELECT CAST(SUM(CASE WHEN T3.review_count = 'Low' THEN 1 ELSE 0 END) AS REAL) * 100.0 / COUNT(*) FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id WHERE T2.category_name = 'Active Life';"} {"question_id": 3813, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses in Scottsdale are rated as \"wonderful experience\"?", "evidence": "Scottsdale refers to city = 'Scottsdale'; rated refers to stars; rated as wonderful experience refers to stars > 3;", "SQL": "SELECT COUNT(business_id) FROM Business WHERE city LIKE 'Scottsdale' AND stars > 3"} {"question_id": 3819, "db_id": "public_review_platform", "grading_method": "set", "question": "Please list all business IDs in Mesa city that received stars of over 3.", "evidence": "stars > 3", "SQL": "SELECT `business_id` FROM `Business` WHERE `city` = 'Mesa' AND `stars` > 3"} {"question_id": 3827, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses in the AZ state got low veracity of reviews?", "evidence": "low veracity of reviews refers to review_count = 'Low' and stars > 3;", "SQL": "SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND review_count LIKE 'Low' AND stars > 3"} {"question_id": 3838, "db_id": "public_review_platform", "grading_method": "set", "question": "Among Arizona businesses with recorded opening hours, how many have no Thursday opening hours recorded?", "evidence": "Thursday refers to day_of_week = 'Thursday';", "SQL": "SELECT COUNT(*) FROM ( SELECT T1.business_id FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.state LIKE 'AZ' GROUP BY T1.business_id HAVING SUM(CASE WHEN T3.day_of_week LIKE 'Thursday' THEN 1 ELSE 0 END) = 0 ) T4"} {"question_id": 3841, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses in Scottsdale have a star rating above 3?", "evidence": "Business.stars is the business-level rating.", "SQL": "SELECT COUNT(business_id) FROM Business WHERE city LIKE 'Scottsdale' AND stars > 3"} {"question_id": 3842, "db_id": "public_review_platform", "grading_method": "set", "question": "Which city has more businesses in the “Uber” review-count category, Scottsdale or Anthem? Return “Both” if they are tied.", "evidence": "Business.review_count records the review-count category; 'Uber' is one of its stored labels. Business.city records the city.", "SQL": "SELECT \n CASE \n WHEN scottsdale_count > anthem_count THEN 'Scottsdale'\n WHEN anthem_count > scottsdale_count THEN 'Anthem'\n ELSE 'Both'\n END AS result\nFROM (\n SELECT \n SUM(CASE WHEN city = 'Scottsdale' THEN 1 ELSE 0 END) AS scottsdale_count,\n SUM(CASE WHEN city = 'Anthem' THEN 1 ELSE 0 END) AS anthem_count\n FROM Business\n WHERE review_count = 'Uber'\n);"} {"question_id": 3852, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the Yelp_Businesses in Arizona, how many of them do not provide alcohol?", "evidence": "Arizona refers to state = 'AZ'; do not provide alcohol refers to attribute_name = 'Alcohol' and attribute_value = 'none' or 'no' or 'false';", "SQL": "SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name LIKE 'Alcohol' AND lower(T2.attribute_value) IN ('none', 'no', 'false') AND T3.state LIKE 'AZ'"} {"question_id": 3856, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the Yelp_Businesses which are still running, how many of them fall under the category of \"Food\"?", "evidence": "are still running refers to active = 'true'; the category of \"Food\" refers to category_name = 'Food'", "SQL": "SELECT COUNT(T3.business_id) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name LIKE 'Food' AND T3.active LIKE 'TRUE'"} {"question_id": 3868, "db_id": "public_review_platform", "grading_method": "set", "question": "How many \"Good for Kids\" Yelp_Businesses are open everyday of the week?", "evidence": "Good for Kids refers to attribute_name = 'Good for Kids' and attribute_value = 'true'; open everyday refers to day_id between 1 and 7", "SQL": "SELECT COUNT(*)\nFROM (\n SELECT bh.`business_id`\n FROM `Business_Hours` bh\n GROUP BY bh.`business_id`\n HAVING COUNT(DISTINCT bh.`day_id`) = 7\n) AS open7\nJOIN `Business_Attributes` ba ON ba.`business_id` = open7.`business_id`\nJOIN `Attributes` a ON a.`attribute_id` = ba.`attribute_id`\nWHERE a.`attribute_name` = 'Good for Kids'\n AND lower(ba.`attribute_value`) = 'true';"} {"question_id": 3871, "db_id": "public_review_platform", "grading_method": "set", "question": "List the business IDs of businesses open for more than 12 hours on Sundays.", "evidence": "Sundays refers to Days.day_of_week; Business_Hours.opening_time and closing_time use AM/PM clock times; hours open refers to SUBTRACT(closing_time, opening_time) on the 24-hour clock, plus 24 when the closing_time is not the later, so equal times give a 24-hour interval; open for more than 12 hours refers to that > 12", "SQL": "WITH time_conversions AS (SELECT bh.business_id, CASE WHEN bh.opening_time LIKE '%AM' THEN CASE WHEN REPLACE(bh.opening_time, 'AM', '') = '12' THEN 0 ELSE CAST(REPLACE(bh.opening_time, 'AM', '') AS INT) END ELSE CASE WHEN REPLACE(bh.opening_time, 'PM', '') = '12' THEN 12 ELSE CAST(REPLACE(bh.opening_time, 'PM', '') AS INT) + 12 END END AS open_hr, CASE WHEN bh.closing_time LIKE '%AM' THEN CASE WHEN REPLACE(bh.closing_time, 'AM', '') = '12' THEN 0 ELSE CAST(REPLACE(bh.closing_time, 'AM', '') AS INT) END ELSE CASE WHEN REPLACE(bh.closing_time, 'PM', '') = '12' THEN 12 ELSE CAST(REPLACE(bh.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 d.day_of_week = 'Sunday') SELECT business_id FROM time_conversions WHERE CASE WHEN close_hr > open_hr THEN close_hr - open_hr ELSE 24 - (open_hr - close_hr) END > 12;"} {"question_id": 3879, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses are in Casa Grande?", "evidence": "Casa Grande is recorded in Business.city as 'Casa Grande'.", "SQL": "SELECT COUNT(city) FROM Business WHERE city LIKE 'Casa Grande'"} {"question_id": 3880, "db_id": "public_review_platform", "grading_method": "set", "question": "What is the total number of active businesses in AZ with a low review count?", "evidence": "active businesses refers to active = 'true'; in AZ refers to state = 'AZ'", "SQL": "SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND active LIKE 'True' AND review_count LIKE 'low'"} {"question_id": 3882, "db_id": "public_review_platform", "grading_method": "set", "question": "How many users who joined Yelp between 2011 and 2013, inclusive, have a fan-count category of High?", "evidence": "Users.user_yelping_since_year is the joining year; Users.user_fans uses categories such as 'High'.", "SQL": "SELECT COUNT(user_id) FROM Users WHERE user_yelping_since_year BETWEEN 2011 AND 2013 AND user_fans LIKE 'High'"} {"question_id": 3891, "db_id": "public_review_platform", "grading_method": "set", "question": "List the category names and attribute names recorded for active businesses in Chandler, Arizona, whose review-count category is Medium.", "evidence": "Business.active = 'TRUE' denotes active businesses; Business.state = 'AZ' denotes Arizona. Business.review_count uses categories such as 'Medium'. Business_Attributes records attributes, including ones that are not enabled.", "SQL": "SELECT T3.category_name, T5.attribute_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id INNER JOIN Business_Attributes AS T4 ON T1.business_id = T4.business_id INNER JOIN Attributes AS T5 ON T4.attribute_id = T5.attribute_id WHERE T1.active LIKE 'TRUE' AND T1.state LIKE 'AZ' AND T1.city LIKE 'Chandler' AND T1.review_count LIKE 'Medium'"} {"question_id": 3892, "db_id": "public_review_platform", "grading_method": "set", "question": "List the categories of active businesses in Surprise, AZ.", "evidence": "categories refers to category_name; active businesses refers to active = 'true'; in Surprise, AZ refers to city = 'Surprise' and state = 'AZ'", "SQL": "SELECT T3.category_name FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T1.active LIKE 'TRUE' AND T1.state LIKE 'AZ' AND T1.city LIKE 'Surprise' GROUP BY T3.category_name"} {"question_id": 3909, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses has user ID 3 reviewed, and how many calendar years passed between their joining year and 2014?", "evidence": "how many businesses user ID 3 reviewed refers to COUNT(Reviews.business_id) over that user's Reviews rows; how many calendar years passed refers to SUBTRACT(2014, Users.user_yelping_since_year) for that user; the answer returns both values", "SQL": "SELECT COUNT(T1.business_id) , 2014 - T2.user_yelping_since_year FROM Reviews AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.user_id = 3"} {"question_id": 3912, "db_id": "public_review_platform", "grading_method": "set", "question": "List the IDs and average review-star ratings of users who have been elite for at least five consecutive years.", "evidence": "Elite.year_id corresponds to the calendar year in Years.actual_year. Users.user_average_stars is the stored average rating given by that user.", "SQL": "WITH Ranked AS (\n SELECT e.user_id,\n y.actual_year,\n y.actual_year - ROW_NUMBER() OVER(PARTITION BY e.user_id ORDER BY y.actual_year) AS grp\n FROM Elite e\n JOIN Years y ON e.year_id = y.year_id\n),\nConsecutive AS (\n SELECT user_id, COUNT(*) AS consecutive_years\n FROM Ranked\n GROUP BY user_id, grp\n HAVING consecutive_years >= 5\n),\nQualifiedUsers AS (\n SELECT DISTINCT user_id FROM Consecutive\n)\nSELECT q.user_id,\n u.user_average_stars\nFROM QualifiedUsers q\nJOIN Users u ON u.user_id = q.user_id;"} {"question_id": 3932, "db_id": "public_review_platform", "grading_method": "set", "question": "What is the opening time of active businesses in Surprise with a low review count?", "evidence": "Business.active = 'true' denotes an active business; Business.review_count = 'Low' denotes a low review count. Business_Hours.opening_time records opening times.", "SQL": "SELECT T2.opening_time FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city LIKE 'Surprise' AND T1.active LIKE 'TRUE' AND T1.review_count LIKE 'Low' GROUP BY T2.opening_time"} {"question_id": 3935, "db_id": "public_review_platform", "grading_method": "set", "question": "How many users who joined Yelp in 2004 have no followers?", "evidence": "joined Yelp in 2004 refers to user_yelping_since_year = 2004; no follower refers to user_fans = 'None'", "SQL": "SELECT COUNT(user_id) FROM Users WHERE user_yelping_since_year = 2004 AND user_fans LIKE 'None'"} {"question_id": 3938, "db_id": "public_review_platform", "grading_method": "set", "question": "Which cities have businesses whose Sunday hours are 10 a.m. to noon?", "evidence": "Business_Hours stores the requested times as opening_time = '10AM' and closing_time = '12PM'; 12PM is noon.", "SQL": "SELECT T1.city FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T2.opening_time LIKE '10AM' AND T2.closing_time LIKE '12PM' AND T3.day_of_week LIKE 'Sunday'"} {"question_id": 3939, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses are marked as “Open 24 Hours”?", "evidence": "Attributes.attribute_name = 'Open 24 Hours' identifies the recorded attribute; Business_Attributes.attribute_value = 'true' means it is enabled. This is a separately recorded business attribute.", "SQL": "SELECT COUNT(T2.business_id) FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id WHERE T2.attribute_value LIKE 'TRUE' AND T1.attribute_name LIKE 'Open 24 Hours'"} {"question_id": 3941, "db_id": "public_review_platform", "grading_method": "set", "question": "Which active businesses in Ahwatukee are open on Sunday?", "evidence": "Business.active = 'true' denotes an active business; Days.day_of_week uses 'Sunday'. Business_Hours records the business’s scheduled opening days.", "SQL": "SELECT T1.business_id FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city LIKE 'Ahwatukee' AND T1.active LIKE 'TRUE' AND T3.day_of_week LIKE 'Sunday'"} {"question_id": 3946, "db_id": "public_review_platform", "grading_method": "set", "question": "What is the total number of fans or followers of the users who received the most likes on their comments in the business?", "evidence": "total number of fans or followers refers to user_fans; most likes on their comments refer to MAX(SUM(likes))", "SQL": "WITH user_total_likes AS (\n SELECT \n user_id,\n SUM(likes) AS total_likes\n FROM Tips\n GROUP BY user_id\n)\nSELECT U.user_fans\nFROM Users U\nINNER JOIN user_total_likes UTL ON U.user_id = UTL.user_id\nWHERE UTL.total_likes = (\n SELECT MAX(total_likes) \n FROM user_total_likes\n);"} {"question_id": 3948, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses have shopping centers and received high review count?", "evidence": "\"Shopping Centers\" is the category_name; high review count refers to review_count = 'High'", "SQL": "SELECT COUNT(T2.business_id) FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Shopping Centers' AND T3.review_count = 'High'"} {"question_id": 3951, "db_id": "public_review_platform", "grading_method": "set", "question": "Compare and get the difference in the number of businesses that are open from 10 am to 9 pm on Monday compared to Tuesday.", "evidence": "10 am refers to opening_time = '10AM'; 9 pm refers to closing_time = '9PM'; 'Monday' and 'Tuesday' are both day_of_week; difference number of business = Subtract(Count(business_id(day_of_week = 'Monday')), Count(business_id(day_of_week = 'Tuesday')))", "SQL": "SELECT SUM(CASE WHEN T3.day_of_week = 'Monday' THEN 1 ELSE 0 END) - SUM(CASE WHEN T3.day_of_week = 'Tuesday' THEN 1 ELSE 0 END) AS DIFF FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T2.opening_time = '10AM' AND T2.closing_time = '9PM'"} {"question_id": 3954, "db_id": "public_review_platform", "grading_method": "set", "question": "How many Yelp businesses in Mesa have a four-star rating?", "evidence": "Business.stars records the business rating; Business.city records the city.", "SQL": "SELECT COUNT(business_id) FROM Business WHERE stars = 4 AND city = 'Mesa'"} {"question_id": 3968, "db_id": "public_review_platform", "grading_method": "set", "question": "How many times larger is the number of \"Women's Clothing\" Yelp businesses than \"Men's Clothing\"?", "evidence": "\"Women's Clothing\" Yelp businesses refers to  category_name = 'Women''s Clothing'; \"Men's Clothing\" refers to category_name = 'Men''s Clothing'; times larger refers to DIVIDE(COUNT(category_name = 'Women''s Clothing'), COUNT(category_name = 'Men''s Clothing'))", "SQL": "SELECT CAST(SUM(CASE WHEN T2.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) AS TIMES FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id"} {"question_id": 3977, "db_id": "public_review_platform", "grading_method": "set", "question": "For inactive businesses with a recorded music_playlist attribute, list the attribute ID, business ID, and city.", "evidence": "Business.active = 'false' denotes inactive businesses. Attributes.attribute_name = 'music_playlist' identifies the music playlist attribute.", "SQL": "SELECT T1.attribute_id, T2.business_id, T3.city FROM Attributes AS T1 INNER JOIN Business_Attributes AS T2 ON T1.attribute_id = T2.attribute_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.attribute_name = 'music_playlist' AND T3.active = 'false'"} {"question_id": 3981, "db_id": "public_review_platform", "grading_method": "subset,=,5", "question": "Under the category ‘Coffee & Tea’, list any five business IDs, their states, and their cities.", "evidence": "", "SQL": "SELECT T2.business_id, T3.state, T3.city FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id WHERE T1.category_name = 'Coffee & Tea'"} {"question_id": 3984, "db_id": "public_review_platform", "grading_method": "set", "question": "Calculate the difference between the numbers of businesses in the Men’s Clothing and Women’s Clothing categories.", "evidence": "Categories.category_name uses \"Men's Clothing\" and \"Women's Clothing\".", "SQL": "SELECT SUM(CASE WHEN T1.category_name = 'Men''s Clothing' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.category_name = 'Women''s Clothing' THEN 1 ELSE 0 END) AS diff FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id"} {"question_id": 3990, "db_id": "public_review_platform", "grading_method": "set", "question": "What percentage of businesses received a five-star rating?", "evidence": "a five-star rating refers to Business.stars = 5; percentage = DIVIDE(SUM(CASE WHEN Business.stars = 5 THEN 1 ELSE 0 END), COUNT(*)) * 100 over all Business rows", "SQL": "SELECT CAST(SUM(CASE WHEN stars = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(business_id) FROM Business"} {"question_id": 3995, "db_id": "public_review_platform", "grading_method": "set", "question": "How many business have low check-in on Sunday at 10AM?", "evidence": "on Sunday refers to day_of_week = 'Sunday'; low check-in at 10AM refers to label_time_10 = 'Low'", "SQL": "SELECT COUNT(T2.business_id) FROM Days AS T1 INNER JOIN Checkins AS T2 ON T1.day_id = T2.day_id WHERE T1.day_of_week = 'Sunday' AND T2.label_time_10 = 'Low'"} {"question_id": 4011, "db_id": "public_review_platform", "grading_method": "set", "question": "Calculate the percentage of long reviews among all five-star reviews given to businesses by Yelp users. Round your answer to 1 decimal place.", "evidence": "five-star reviews refers to Reviews.review_stars = 5; long reviews refers to review_length = 'Long'; percentage = DIVIDE(COUNT(five-star reviews whose review_length = 'Long'), COUNT(review_length over those five-star reviews)) * 100; round the final answer to 1 decimal place", "SQL": "SELECT ROUND(CAST(SUM(CASE WHEN review_length = 'Long' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(review_length), 1) FROM Reviews WHERE review_stars = 5"} {"question_id": 4015, "db_id": "public_review_platform", "grading_method": "set", "question": "List the IDs and opening and closing times, by day of the week, for businesses in Black Canyon City whose review-count category is High or Uber.", "evidence": "Business.review_count contains categories including 'High' and 'Uber'. Business_Hours opening_time and closing_time use hour strings such as '10AM' and '12PM'; 12AM is midnight and 12PM is noon. Weekday names are recorded in Days.day_of_week.", "SQL": "SELECT T1.business_id, T2.opening_time, T2.closing_time, T3.day_of_week FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city = 'Black Canyon City' AND T1.review_count IN ('High', 'Uber')"} {"question_id": 4020, "db_id": "public_review_platform", "grading_method": "set", "question": "What is the closing time of business id 4 on Saturday?", "evidence": "on Saturday refers to day_of_week = 'Saturday'", "SQL": "SELECT T2.closing_time FROM Days AS T1 INNER JOIN Business_Hours AS T2 ON T1.day_id = T2.day_id WHERE T1.day_of_week = 'Saturday' AND T2.business_id = 4"} {"question_id": 4022, "db_id": "public_review_platform", "grading_method": "set", "question": "Among users in the Medium fan-count category, how many received High-category compliments from other users?", "evidence": "Users.user_fans = 'Medium' denotes the Medium fan-count category; Users_Compliments.number_of_compliments = 'High' denotes High-category compliments.", "SQL": "SELECT COUNT(DISTINCT T1.`user_id`) FROM `Users` AS T1 JOIN `Users_Compliments` AS T2 ON T1.`user_id` = T2.`user_id` WHERE T1.`user_fans` = 'Medium' AND T2.`number_of_compliments` = 'High'"} {"question_id": 4033, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the users who received high compliments from other users, which users joined Yelp earliest?", "evidence": "high compliments refers to number_of_compliments = ' High'; joined Yelp earliest refers to min(user_yelping_since_year)", "SQL": "SELECT DISTINCT u.user_id\nFROM Users u\nJOIN Users_Compliments uc ON u.user_id = uc.user_id\nWHERE uc.number_of_compliments = 'High'\n AND u.user_yelping_since_year = (\n SELECT MIN(u2.user_yelping_since_year)\n FROM Users u2\n JOIN Users_Compliments uc2 ON u2.user_id = uc2.user_id\n WHERE uc2.number_of_compliments = 'High'\n );"} {"question_id": 4039, "db_id": "public_review_platform", "grading_method": "set", "question": "Find out which business ID are opened all the time.", "evidence": "opened all the time refers to Business_Hours where day_id BETWEEN 1 and 7 and opening_time = closing_time;", "SQL": "SELECT `business_id` FROM `Business_Hours` WHERE `day_id` BETWEEN 1 AND 7 AND `opening_time` = `closing_time` GROUP BY `business_id` HAVING COUNT(DISTINCT `day_id`) = 7"} {"question_id": 4041, "db_id": "public_review_platform", "grading_method": "set", "question": "How many users manage to get uber votes for all of the review category?", "evidence": "users refer to user_id; uber votes for all of the review category refer to review_votes_funny = 'uber' AND review_votes_useful = 'uber' AND review_votes_cool = 'uber';", "SQL": "SELECT COUNT(*) AS avg_user_average_stars FROM `Users` U WHERE U.`user_id` IN ( SELECT DISTINCT R.`user_id` FROM `Reviews` R WHERE R.`review_votes_funny` = 'Uber' AND R.`review_votes_useful` = 'Uber' AND R.`review_votes_cool` = 'Uber')"} {"question_id": 4047, "db_id": "public_review_platform", "grading_method": "set", "question": "For users in the Uber fan-count category who became elite, how many years did it take on average to first become elite after joining Yelp?", "evidence": "the Uber fan-count category refers to Users.user_fans = 'Uber'; joining Yelp refers to user_yelping_since_year; first became elite refers to MIN(Elite.year_id), the calendar year (Years.actual_year); how many years on average refers to AVG(SUBTRACT(first elite year, user_yelping_since_year)) over Uber users with an Elite record", "SQL": "WITH uber_users AS (\n SELECT `user_id`, `user_yelping_since_year`\n FROM `Users`\n WHERE `user_fans` = 'Uber'\n),\nfirst_elite AS (\n SELECT `user_id`, MIN(`year_id`) AS first_elite_year\n FROM `Elite`\n GROUP BY `user_id`\n)\nSELECT AVG(first_elite_year - user_yelping_since_year) AS avg_years_to_elite\nFROM uber_users u\nJOIN first_elite f ON u.user_id = f.user_id;"} {"question_id": 4057, "db_id": "public_review_platform", "grading_method": "set", "question": "Which business categories include businesses that are open on Sunday?", "evidence": "Business categories are stored in Categories.category_name. Sunday has day_id = 1 and day_of_week = 'Sunday'. A recorded opening time must be neither SQL NULL nor an empty string.", "SQL": "SELECT DISTINCT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T2.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T4.day_of_week = 'Sunday' AND T3.opening_time <> ''"} {"question_id": 4071, "db_id": "public_review_platform", "grading_method": "set", "question": "How many active businesses in Cave Creek have High, Medium, and Low review-count categories? Give the three counts in that order.", "evidence": "active refers to Business.active = 'true', restricted to the businesses in Cave Creek; return three counts in one row: SUM(CASE WHEN review_count = 'High' THEN 1 ELSE 0 END), then the same for 'Medium', then for 'Low'", "SQL": "SELECT SUM(CASE WHEN review_count = 'High' THEN 1 ELSE 0 END) AS high , SUM(CASE WHEN review_count = 'Medium' THEN 1 ELSE 0 END) AS Medium , SUM(CASE WHEN review_count = 'Low' THEN 1 ELSE 0 END) AS low FROM Business WHERE city = 'Cave Creek' AND active = 'true'"} {"question_id": 4072, "db_id": "public_review_platform", "grading_method": "set", "question": "Calculate the yearly average number of users who started using Yelp from 2005 to 2014.", "evidence": "avg(count(user_id)) where user_yelping_since_year BETWEEN '2005' AND '2014';", "SQL": "WITH yearly_counts AS (\n SELECT `user_yelping_since_year` AS yr,\n COUNT(*) AS num_users\n FROM `Users`\n WHERE `user_yelping_since_year` BETWEEN 2005 AND 2014\n GROUP BY `user_yelping_since_year`\n)\nSELECT AVG(num_users) AS average_new_users_per_year\nFROM yearly_counts;"} {"question_id": 4075, "db_id": "public_review_platform", "grading_method": "subset,=,5", "question": "List the IDs and names of any five categories whose names start with P.", "evidence": "Category-name matching is case-insensitive.", "SQL": "SELECT category_id, category_name FROM Categories WHERE category_name LIKE 'P%'"} {"question_id": 4081, "db_id": "public_review_platform", "grading_method": "set", "question": "List businesses that received the most likes in tips.", "evidence": "businesses that received the most likes in tips refers to business_id where MAX(SUM(likes));", "SQL": "SELECT business_id\nFROM Tips\nGROUP BY business_id\nHAVING SUM(likes) = (\n SELECT SUM(likes)\n FROM Tips\n GROUP BY business_id\n ORDER BY SUM(likes) DESC\n LIMIT 1\n);"} {"question_id": 4084, "db_id": "public_review_platform", "grading_method": "set", "question": "List the business IDs and days of the week when active businesses in Black Canyon City are open.", "evidence": "Business.active = 'true' denotes active businesses. Business_Hours records operating days, named in Days.day_of_week.", "SQL": "SELECT T2.business_id, T3.day_of_week FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T1.city = 'Black Canyon City' AND T1.active = 'true'"} {"question_id": 4087, "db_id": "public_review_platform", "grading_method": "set", "question": "How many more active businesses are recorded in Glendale than in Mesa?", "evidence": "Running businesses have Business.active = 'true'. Business.city records the city.", "SQL": "SELECT SUM(CASE WHEN city = 'Glendale' THEN 1 ELSE 0 END) - SUM(CASE WHEN city = 'Mesa' THEN 1 ELSE 0 END) AS diff FROM Business WHERE active = 'true'"} {"question_id": 4093, "db_id": "public_review_platform", "grading_method": "set", "question": "List down the businesses located at SC State with their closing days.", "evidence": "business refers to business_id; closing day refers to day_of_week for day_id that does not exist in Business_Hours;", "SQL": "SELECT b.`business_id`,\n d.`day_of_week`\nFROM Business b\nCROSS JOIN Days d\nLEFT JOIN Business_Hours bh\n ON bh.`business_id` = b.`business_id`\n AND bh.`day_id` = d.`day_id`\nWHERE b.`state` = 'SC'\n AND bh.`day_id` IS NULL;"} {"question_id": 4095, "db_id": "public_review_platform", "grading_method": "set", "question": "In which states are businesses with the beer-and-wine attribute located?", "evidence": "The beer-and-wine attribute is recorded in Business_Attributes.attribute_value as 'beer_and_wine'; Business.state records the state.", "SQL": "SELECT DISTINCT T2.state FROM Business_Attributes AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.attribute_value = 'beer_and_wine'"} {"question_id": 4103, "db_id": "public_review_platform", "grading_method": "set", "question": "How many businesses have more than 1 attribute?", "evidence": "businesses have more than 1 attribute refers to COUNT(attribute_value) > 1", "SQL": "SELECT COUNT(*)\nFROM (\n SELECT `business_id`\n FROM `Business_Attributes`\n GROUP BY `business_id`\n HAVING COUNT(*) > 1\n);"} {"question_id": 4112, "db_id": "public_review_platform", "grading_method": "set", "question": "How many active businesses in Phoenix have received at least one long review?", "evidence": "Business.active = 'true' denotes active businesses; Business.city records the city and may contain surrounding spaces. Reviews.review_length = 'Long' identifies long reviews.", "SQL": "SELECT COUNT(DISTINCT b.business_id) FROM Business b JOIN Reviews r ON r.business_id=b.business_id WHERE b.active='true' AND lower(trim(b.city))='phoenix' AND r.review_length='Long';"} {"question_id": 4121, "db_id": "public_review_platform", "grading_method": "set", "question": "What is the total number of active businesses in AZ with a medium review count?", "evidence": "active businesses refers to active = 'true'; AZ is a state; medium review count refers to review_count = 'Medium'", "SQL": "SELECT COUNT(business_id) FROM Business WHERE review_count = 'Medium' AND state = 'AZ' AND active = 'true'"} {"question_id": 4130, "db_id": "public_review_platform", "grading_method": "set", "question": "How many active businesses have the BYOB attribute and a high review count?", "evidence": "Business.active = 'true' denotes an active business; Business.review_count = 'High' denotes a high review count. BYOB permission is Attributes.attribute_name = 'BYOB' with Business_Attributes.attribute_value = 'true'.", "SQL": "SELECT COUNT(DISTINCT B.`business_id`)\nFROM `Business` B\nJOIN `Business_Attributes` BA ON B.`business_id` = BA.`business_id`\nJOIN `Attributes` A ON BA.`attribute_id` = A.`attribute_id`\nWHERE B.`active` = 'true'\n AND B.`review_count` = 'High'\n AND A.`attribute_name` = 'BYOB'\n AND BA.`attribute_value` = 'true';"} {"question_id": 4132, "db_id": "public_review_platform", "grading_method": "set", "question": "Among the active businesses located at Goodyear, AZ, list the category and attributes of businesses with a medium review count.", "evidence": "active businesses refers to active = 'true'; Goodyear is a city; AZ is a state; medium review count refers to review_count = 'Medium'", "SQL": "SELECT T3.category_name, T5.attribute_name FROM Business AS T1 INNER JOIN Business_Categories AS T2 ON T1.business_id = T2.business_id INNER JOIN Categories AS T3 ON T2.category_id = T3.category_id INNER JOIN Business_Attributes AS T4 ON T1.business_id = T4.business_id INNER JOIN Attributes AS T5 ON T4.attribute_id = T5.attribute_id WHERE T1.review_count = 'Medium' AND T1.city = 'Goodyear' AND T1.state = 'AZ' AND T1.active = 'true'"} {"question_id": 4148, "db_id": "citeseer", "grading_method": "set", "question": "What is the class label of paper ID 'chakrabarti01integrating'. How many words were cited by this paper ID?", "evidence": "", "SQL": "SELECT DISTINCT T1.class_label, COUNT(T2.word_cited_id) FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id WHERE T1.paper_id = 'chakrabarti01integrating' GROUP BY T1.class_label"} {"question_id": 4149, "db_id": "citeseer", "grading_method": "set", "question": "List all paper ID and its class type with more than 20 cited words.", "evidence": "class type refers to class_label; count(word_cited_id)>20", "SQL": "SELECT DISTINCT T1.paper_id, T1.class_label FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id GROUP BY T2.paper_id, T1.class_label HAVING COUNT(T2.word_cited_id) > 20"} {"question_id": 4152, "db_id": "citeseer", "grading_method": "set", "question": "What percentage of papers are under the ML class?", "evidence": "class refers to class_label; percentage = multiply(divide(count(paper_id where class_label = 'ML'), count(paper_id)), 100.0);", "SQL": "SELECT CAST(COUNT(CASE WHEN class_label = 'ML' THEN paper_id ELSE NULL END) AS REAL) * 100 / COUNT(paper_id) FROM paper"} {"question_id": 4154, "db_id": "citeseer", "grading_method": "set", "question": "How many papers cited by artale00expressivity contain the word identified as word3555?", "evidence": "cites.citing_paper_id identifies the paper making a citation; cites.cited_paper_id identifies the paper it cites. content.word_cited_id identifies a vocabulary word occurring in a paper.", "SQL": "SELECT COUNT(DISTINCT T2.paper_id) FROM cites AS T1 INNER JOIN content AS T2 ON T1.cited_paper_id = T2.paper_id WHERE T1.citing_paper_id = 'artale00expressivity' AND T2.word_cited_id = 'word3555'"} {"question_id": 4155, "db_id": "citeseer", "grading_method": "set", "question": "Under what classification do the papers that cited word1163 belong?", "evidence": "", "SQL": "SELECT DISTINCT T1.class_label FROM paper AS T1 INNER JOIN content AS T2 ON T1.paper_id = T2.paper_id WHERE T2.word_cited_id = 'word1163'"} {"question_id": 4170, "db_id": "simpson_episodes", "grading_method": "set", "question": "Please list the titles of episodes with more than 200 voters giving a star score of 10.", "evidence": "Vote.stars records the rating score and Vote.votes records the number of votes for that score; Episode.title records the title.", "SQL": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.votes > 200 AND T2.stars = 10;"} {"question_id": 4176, "db_id": "simpson_episodes", "grading_method": "set", "question": "List down all the roles of Matt Groening on the episode titled 'In the Name of the Grandfather' along with the episode number and series number.", "evidence": "\"Matt Groening\" is the person; 'In the Name of the Grandfather' is the title of episode; episode number refers to episode; series number refers to number_in_series", "SQL": "SELECT T2.role, T1.episode, T1.number_in_series FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Matt Groening' AND T1.title = 'In the Name of the Grandfather';"} {"question_id": 4178, "db_id": "simpson_episodes", "grading_method": "set", "question": "What is the average number of stars received by the episode titled 'Wedding for Disaster.'", "evidence": "\"Wedding for Disaster\" is the title of episode; average number of stars = Divide(Sum(stars*votes), SUM(votes))", "SQL": "SELECT SUM(`stars` * `votes`) * 1.0 / SUM(`votes`) AS average_stars\nFROM `Vote`\nWHERE `episode_id` = (\n SELECT `episode_id` FROM `Episode`\n WHERE `title` = 'Wedding for Disaster'\n);"} {"question_id": 4180, "db_id": "simpson_episodes", "grading_method": "set", "question": "What is the birth name of the person who voiced 'Helen Lovejoy?'", "evidence": "voiced refers to role; role = 'Helen Lovejoy'", "SQL": "SELECT DISTINCT T1.birth_name FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.role = 'Helen Lovejoy';"} {"question_id": 4190, "db_id": "simpson_episodes", "grading_method": "set", "question": "What is the title of episode that won the Best International TV Series Award in 2017?", "evidence": "won refers to result = 'Winner'; in 2017 refers to year = 2017", "SQL": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE SUBSTR(T1.year, 1, 4) = '2017' AND T1.award = 'Best International TV Series' AND T1.result = 'Winner';"} {"question_id": 4193, "db_id": "simpson_episodes", "grading_method": "set", "question": "Which episode received the most votes for a 10-star rating?", "evidence": "a 10-star rating refers to stars = 10; the votes an episode received for that rating refers to SUM(votes) for that episode; the most votes refers to the greatest such per-episode total; return that episode", "SQL": "WITH title_votes AS (\n SELECT e.title, SUM(v.votes) votes\n FROM `Episode` AS e\n JOIN `Vote` AS v ON v.`episode_id` = e.`episode_id`\n WHERE v.`stars` = 10\n GROUP BY v.episode_id\n) SELECT title FROM title_votes WHERE votes = (SELECT MAX(votes) FROM title_votes)"} {"question_id": 4198, "db_id": "simpson_episodes", "grading_method": "set", "question": "Among episodes with more than 950 votes, what percentage were nominated for 'Outstanding Voice-Over Performance' in 2009?", "evidence": "Award.award records the award name. Award.result = 'Nominee' means nominated without winning; 'Winner' is a separate result.", "SQL": "WITH high_votes AS (\n SELECT episode_id\n FROM Episode\n WHERE votes > 950\n), nominated AS (\n SELECT DISTINCT episode_id\n FROM Award\n WHERE year = 2009\n AND award = 'Outstanding Voice-Over Performance'\n AND result = 'Nominee'\n)\nSELECT \n 100.0 * (SELECT COUNT(*) FROM nominated WHERE episode_id IN (SELECT episode_id FROM high_votes)) /\n (SELECT COUNT(*) FROM high_votes) AS percentage;"} {"question_id": 4202, "db_id": "simpson_episodes", "grading_method": "set", "question": "What are the titles of the episodes that received the lowest rating?", "evidence": "lowest rating refers to Min(rating)", "SQL": "SELECT title FROM Episode WHERE rating = (SELECT MIN(Rating) FROM Episode);"} {"question_id": 4213, "db_id": "simpson_episodes", "grading_method": "set", "question": "What awards were won by named cast or crew members in the earliest year with such a win? List each award and its winner.", "evidence": "won refers to result = 'Winner'; first award refers to Min(year)", "SQL": "SELECT T2.`award`, T2.`person`\nFROM `Award` AS T2\nWHERE T2.`result` = 'Winner' AND T2.`person` IS NOT NULL\n AND T2.`year` = (SELECT MIN(`year`) FROM `Award` WHERE `result` = 'Winner' AND `person` IS NOT NULL)\nORDER BY T2.`award_id`;"} {"question_id": 4216, "db_id": "simpson_episodes", "grading_method": "set", "question": "List the names and birth dates of cast members born in Los Angeles who are at least 1.8 meters tall.", "evidence": "Credit.category = 'Cast' identifies cast credits.", "SQL": "SELECT DISTINCT p.`name`, p.`birthdate` FROM `Person` AS p JOIN `Credit` AS c ON c.`person` = p.`name` WHERE c.`category` = 'Cast' AND p.`birth_place` = 'Los Angeles' AND p.`height_meters` >= 1.8"} {"question_id": 4223, "db_id": "simpson_episodes", "grading_method": "set", "question": "What are the vote count and percentage for the 10-star rating of the episode with the keyword “arab stereotype”?", "evidence": "Vote.stars records the rating score; Vote.votes and Vote.percent record its vote count and percentage. Keyword.keyword uses 'arab stereotype'.", "SQL": "SELECT T2.votes, T2.percent FROM Keyword AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.keyword = 'arab stereotype' AND T2.stars = 10;"} {"question_id": 4235, "db_id": "simpson_episodes", "grading_method": "set", "question": "Name the performer who won Emmy Award for Outstanding Voice-Over Performance by playing Homer Simpson.", "evidence": "Outstanding Voice-Over Performance refers to award = 'Outstanding Voice-Over Performance'; who won refers to result = 'Winner'; Emmy refers to organization = 'Primetime Emmy Awards'; playing Homer simpson 20 refers to character = 'Homer Simpson'", "SQL": "SELECT DISTINCT T1.person FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Homer Simpson' AND T1.organization = 'Primetime Emmy Awards' AND T1.award = 'Outstanding Voice-Over Performance' AND T1.result = 'Winner';"} {"question_id": 4243, "db_id": "simpson_episodes", "grading_method": "set", "question": "List the categories for which Bonita Pietila was given credit and her role in creating the episodes.", "evidence": "", "SQL": "SELECT DISTINCT category, role FROM Credit WHERE person = 'Bonita Pietila';"} {"question_id": 4247, "db_id": "simpson_episodes", "grading_method": "set", "question": "Which episode from season 20 received the most nominations? Give its title.", "evidence": "season 20 refers to Episode.season = 20; the nominations an episode received refers to COUNT of its Award rows; the most nominations refers to the greatest such count; return the Episode.title", "SQL": "WITH title_award AS (\n SELECT T2.title, COUNT(*) cnt\n FROM Award AS T1 \n INNER JOIN Episode AS T2 \n ON T1.episode_id = T2.episode_id \n WHERE T2.season = 20\n GROUP BY T1.episode_id \n) SELECT title FROM title_award WHERE cnt = (SELECT MAX(cnt) FROM title_award)"} {"question_id": 4248, "db_id": "simpson_episodes", "grading_method": "set", "question": "Please indicate the birthplace of the crew member named Dan Castellaneta.", "evidence": "", "SQL": "SELECT birth_place FROM Person WHERE name = 'Dan Castellaneta';"} {"question_id": 4250, "db_id": "simpson_episodes", "grading_method": "set", "question": "Please list the names of crew members born before 1970.", "evidence": "Person.birthdate records the birth date.", "SQL": "SELECT name FROM Person WHERE SUBSTR(birthdate, 1, 4) < '1970';"} {"question_id": 4253, "db_id": "simpson_episodes", "grading_method": "set", "question": "Please indicate the keywords of the title \"Double, Double, Boy in Trouble\".", "evidence": "", "SQL": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Double, Double, Boy in Trouble';"} {"question_id": 4254, "db_id": "simpson_episodes", "grading_method": "set", "question": "Which episode numbers from 10 through 20 have more than 200 votes?", "evidence": "episodes from 10 to 20 refers to episode BETWEEN 10 and 20; more than 200 votes refers to votes > 200", "SQL": "SELECT `episode`\nFROM `Episode`\nWHERE `episode` BETWEEN 10 AND 20\n AND `votes` > 200;"} {"question_id": 4257, "db_id": "simpson_episodes", "grading_method": "set", "question": "Which episode id was nominated with the award Outstanding Animated Program (For Programming Less Than One Hour)?", "evidence": "star score of 10 refers to stars = 10", "SQL": "SELECT DISTINCT T1.episode_id FROM Award AS T1 WHERE T1.award = 'Outstanding Animated Program (For Programming Less Than One Hour)' AND T1.result = 'Nominee';"} {"question_id": 4262, "db_id": "simpson_episodes", "grading_method": "set", "question": "List the episode IDs for which Al Jean received a Primetime Emmy nomination in 2009 but did not win.", "evidence": "Primetime Emmy is recorded in Award.award_category. Nominated refers to Award.result = 'Nominee', excluding winners", "SQL": "SELECT T2.episode_id\nFROM Award AS T1\nINNER JOIN Episode AS T2\n ON T1.episode_id = T2.episode_id\nWHERE SUBSTR(T1.year, 1, 4) = '2009'\n AND T1.person = 'Al Jean'\n AND T1.award_category = 'Primetime Emmy'\n AND T1.result = 'Nominee';"} {"question_id": 4264, "db_id": "simpson_episodes", "grading_method": "set", "question": "What award did the character Homer Simpson achieve in 2009?", "evidence": "in 2009 refers to year = 2009", "SQL": "SELECT DISTINCT T1.award FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.year = 2009 AND T2.character = 'Homer Simpson';"} {"question_id": 4269, "db_id": "simpson_episodes", "grading_method": "set", "question": "In the crew, who was born in 1962 in California?", "evidence": "born in 1962 refers to year(birthdate) = 1962; in California refers to birth_region = 'California'", "SQL": "SELECT name FROM Person WHERE SUBSTR(birthdate, 1, 4) = '1962' AND birth_region = 'California';"} {"question_id": 4272, "db_id": "simpson_episodes", "grading_method": "subset,=,3", "question": "Please list any three episodes that have an excellent rating.", "evidence": "an excellent rating refers to 7 < rating < = 10", "SQL": "SELECT title FROM Episode WHERE rating > 7 AND rating <= 10;"} {"question_id": 4273, "db_id": "simpson_episodes", "grading_method": "set", "question": "What are ids of the top five most popular episodes?", "evidence": "most popular episodes refers to MAX(votes)", "SQL": "SELECT episode_id FROM Episode ORDER BY votes DESC LIMIT 5;"} {"question_id": 4274, "db_id": "simpson_episodes", "grading_method": "set", "question": "Please list the three episodes with the highest number of votes for the worst star rating.", "evidence": "highest number of votes refers to MAX(COUNT(votes)); worst star rating refers to stars = 1", "SQL": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = ( SELECT MIN(stars) FROM Vote ) ORDER BY T2.votes DESC LIMIT 3;"} {"question_id": 4280, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many votes of 5-star did the episode \"Lisa the Drama Queen\" receive?", "evidence": "episode \"Lisa the Drama Queen\" refers to title = 'Lisa the Drama Queen';", "SQL": "SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'Lisa the Drama Queen' AND T2.stars = 5;"} {"question_id": 4286, "db_id": "simpson_episodes", "grading_method": "set", "question": "Who is the oldest among all the casts and crews?", "evidence": "oldest refers to MIN(birthdate)", "SQL": "SELECT name FROM Person WHERE birthdate = (SELECT MIN(birthdate) FROM Person WHERE birthdate IS NOT NULL);"} {"question_id": 4287, "db_id": "simpson_episodes", "grading_method": "set", "question": "What are the episodes Oscar Cervantes is credited with? List the episode ids.", "evidence": "is credited refers to credited = 'true';", "SQL": "SELECT episode_id FROM Credit WHERE person = 'Oscar Cervantes' AND credited = 'true';"} {"question_id": 4301, "db_id": "simpson_episodes", "grading_method": "set", "question": "What percentage of votes are from the nominated but not winning episodes?", "evidence": "nominated episodes refers to result = 'Nominee'; percentage of votes = DIVIDE(SUM(result = 'Nominee'), SUM(Votes)) as percentage", "SQL": "SELECT\n SUM(E.`votes`) * 100.0 /\n (SELECT SUM(`votes`) FROM `Episode`) AS pct_votes_from_nominated_episodes\nFROM `Episode` AS E\nWHERE E.`episode_id` IN (\n SELECT DISTINCT `episode_id`\n FROM `Award`\n WHERE `result` = 'Nominee'\n);"} {"question_id": 4311, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many additional timers were born in USA?", "evidence": "additional timers refers to role = 'additional timer'; born in USA refers to birth_country = 'USA'", "SQL": "SELECT COUNT(DISTINCT T2.person) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.role = 'additional timer' AND T1.birth_country = 'USA';"} {"question_id": 4315, "db_id": "simpson_episodes", "grading_method": "set", "question": "What is the average height of people with a recorded height and at least one Animation Department credit? Round your answer to 3 decimal places.", "evidence": "at least one Animation Department credit refers to Credit.category = 'Animation Department'; a person may hold several such credits, so take each Person.name once; average height refers to AVG(Person.height_meters) over those distinct people whose height_meters IS NOT NULL, rounded to 3 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(height_meters) FROM ( SELECT DISTINCT P.name, P.height_meters FROM Person AS P JOIN Credit AS C ON P.name = C.person WHERE C.category = 'Animation Department' AND P.height_meters IS NOT NULL )\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 4328, "db_id": "simpson_episodes", "grading_method": "set", "question": "For No Loan Again, Naturally, which has an overall rating of 6.8, what percentage of votes gave it a score from 5 through 10? Round your answer to 3 decimal places.", "evidence": "Episode.title records 'No Loan Again, Naturally'; Episode.rating is its overall rating. Vote.stars records a score and Vote.votes is the number of votes at that score; Vote.percent is a separately rounded percentage.", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN v.stars BETWEEN 5 AND 10 THEN v.votes ELSE 0 END) / SUM(v.votes) FROM Vote v JOIN Episode e ON e.episode_id=v.episode_id WHERE e.title='No Loan Again, Naturally' AND e.rating=6.8\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 4333, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many different award names were recorded in 2009?", "evidence": "Award.award records the award name; Award.year records the award year.", "SQL": "SELECT COUNT(DISTINCT award) FROM Award WHERE SUBSTR(year, 1, 4) = '2009';"} {"question_id": 4335, "db_id": "simpson_episodes", "grading_method": "set", "question": "List the birth names of crew members who worked as co-executive producers and are taller than 1.60 meters.", "evidence": "Credit.role uses 'co-executive producer'; Person.birth_name is the name given at birth.", "SQL": "SELECT DISTINCT p.`birth_name`\nFROM `Person` p\nJOIN `Credit` c ON p.`name` = c.`person`\nWHERE c.`role` = 'co-executive producer'\n AND p.`height_meters` > 1.60;"} {"question_id": 4338, "db_id": "simpson_episodes", "grading_method": "set", "question": "List out the title of episodes which have star score of 2.", "evidence": "star score of 2 refers to stars = 2", "SQL": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = 2;"} {"question_id": 4342, "db_id": "simpson_episodes", "grading_method": "set", "question": "Which are the years that character Mr. Burns was nominated to an award?", "evidence": "", "SQL": "SELECT DISTINCT T1.year FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Mr. Burns' AND T1.result = 'Nominee';"} {"question_id": 4345, "db_id": "simpson_episodes", "grading_method": "set", "question": "What are the keywords of the episode which has title as Dangerous Curves?", "evidence": "", "SQL": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves';"} {"question_id": 4352, "db_id": "simpson_episodes", "grading_method": "set", "question": "How many episodes from episodes 5 through 10 of season 20, inclusive, have a credited casting role?", "evidence": "Episode.episode_id encodes season and episode as, for example, 'S20-E5'. Credit.role uses 'casting'; Credit.credited = 'true' indicates a credited role.", "SQL": "SELECT COUNT(DISTINCT e.`episode_id`)\nFROM `Episode` e\nJOIN `Credit` c ON c.`episode_id` = e.`episode_id` AND c.`credited` = 'true' AND LOWER(c.`role`) LIKE 'casting'\nWHERE e.`season` = 20 AND e.`episode_id` IN ( 'S20-E5', 'S20-E6', 'S20-E7', 'S20-E8', 'S20-E9', 'S20-E10' );"} {"question_id": 4354, "db_id": "simpson_episodes", "grading_method": "set", "question": "Give the title of the episode won in Primetime Emmy Awards 2009.", "evidence": "won refers to result = 'Winner'; in Primetime Emmy Awards refers to organization = 'Primetime Emmy Awards'; 2009 refers to year = 2009", "SQL": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.organization = 'Primetime Emmy Awards' AND T1.year = 2009 AND T1.result = 'Winner';"} {"question_id": 4368, "db_id": "student_loan", "grading_method": "set", "question": "How many students have never been absent from school?", "evidence": "have never been absent refers to `month` = 0;", "SQL": "SELECT COUNT(name) FROM longest_absense_from_school WHERE `month` = 0"} {"question_id": 4384, "db_id": "student_loan", "grading_method": "set", "question": "What is the average length, in months, of the longest school absence recorded for students with disabilities?", "evidence": "disabled.name lists students with disabilities. longest_absense_from_school.month records their longest absence in months; 0 means never absent.", "SQL": "SELECT AVG(T1.month) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.`name` = T2.`name`"} {"question_id": 4385, "db_id": "student_loan", "grading_method": "set", "question": "Name all students enlisted in the foreign legion.", "evidence": "in the foreign legion organ = 'foreign_legion';", "SQL": "SELECT name FROM enlist WHERE organ = 'foreign_legion'"} {"question_id": 4392, "db_id": "student_loan", "grading_method": "set", "question": "List all students enlisted in the air force and their recorded schools, leaving the school blank if none is recorded.", "evidence": "in the air force refers to organ = 'air_force';", "SQL": "SELECT T2.name, T1.school FROM enrolled AS T1 RIGHT JOIN enlist AS T2 ON T1.`name` = T2.`name` WHERE T2.organ = 'air_force'"} {"question_id": 4393, "db_id": "student_loan", "grading_method": "subset,=,10", "question": "List 10 students that have no due payments and are not males.", "evidence": "no due payments refers to bool = 'neg'; not males refers to not in male table", "SQL": "SELECT T1.name FROM no_payment_due AS T1 INNER JOIN person AS T2 ON T1.`name` = T2.`name` WHERE T2.`name` NOT IN ( SELECT name FROM male ) AND T1.bool = 'neg'"} {"question_id": 4395, "db_id": "student_loan", "grading_method": "set", "question": "Name all disabled students that are enrolled in SMC.", "evidence": "enrolled in SMC refers to school = 'smc';", "SQL": "SELECT T2.name FROM enrolled AS T1 INNER JOIN disabled AS T2 ON T1.`name` = T2.`name` WHERE T1.school = 'smc'"} {"question_id": 4399, "db_id": "student_loan", "grading_method": "set", "question": "How many students from SMC are unemployed?", "evidence": "from SMC refers to school = 'smc';", "SQL": "SELECT COUNT(T2.name) FROM enrolled AS T1 INNER JOIN unemployed AS T2 ON T1.`name` = T2.`name` WHERE T1.school = 'smc'"} {"question_id": 4403, "db_id": "student_loan", "grading_method": "set", "question": "What percentage of students enlisted in foreign legions have a due payment?", "evidence": "enlist.organ = 'foreign_legion' denotes the foreign legion; no_payment_due.bool = 'pos' denotes a payment due.", "SQL": "SELECT 100.0 * SUM(CASE WHEN n.`bool` = 'pos' THEN 1 ELSE 0 END) / COUNT(*) AS percent_with_due\nFROM `no_payment_due` AS n\nWHERE n.`name` IN (SELECT DISTINCT `name`\n FROM `enlist`\n WHERE `organ` = 'foreign_legion');"} {"question_id": 4408, "db_id": "student_loan", "grading_method": "set", "question": "How many students’ longest school absence was four months?", "evidence": "longest_absense_from_school.month records the longest school absence in months.", "SQL": "SELECT COUNT(name) FROM longest_absense_from_school WHERE month = 4"} {"question_id": 4409, "db_id": "student_loan", "grading_method": "set", "question": "What is the number of simultaneously unemployed and bankrupt students?", "evidence": "", "SQL": "SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name"} {"question_id": 4413, "db_id": "student_loan", "grading_method": "set", "question": "What is the employment ('employed' or 'unemployed'), disability ('disabled' or 'not_disabled'), gender ('male' or 'female') and school debt status ('pos', 'neg', or 'unknown') for student180 and student117?", "evidence": "school debt status refers to bool; bool = 'pos' means has payment due; bool = 'neg' means doesn't has payment due; student appear in male.name means he is a male; student does not appear in male.name means she is a female;", "SQL": "SELECT p.`name`,\n CASE WHEN u.`name` IS NOT NULL THEN 'unemployed' ELSE 'employed' END AS employment_status,\n CASE WHEN d.`name` IS NOT NULL THEN 'disabled' ELSE 'not_disabled' END AS disability_status,\n CASE WHEN m.`name` IS NOT NULL THEN 'male' ELSE 'female' END AS gender,\n COALESCE(n.`bool`, 'unknown') AS school_debt_status\nFROM `person` AS p\nLEFT JOIN `unemployed` AS u ON p.`name` = u.`name`\nLEFT JOIN `disabled` AS d ON p.`name` = d.`name`\nLEFT JOIN `male` AS m ON p.`name` = m.`name`\nLEFT JOIN `no_payment_due` AS n ON p.`name` = n.`name`\nWHERE p.`name` IN ('student180', 'student117');"} {"question_id": 4416, "db_id": "student_loan", "grading_method": "set", "question": "What is the ratio of disabled female students to disabled male students?", "evidence": "ratio refers to DIVIDE(COUNT(name not from male), COUNT(name from male))", "SQL": "SELECT CAST(SUM(IIF(T2.name IS NULL, 1, 0)) AS REAL) / COUNT(T2.name) FROM disabled AS T1 LEFT JOIN male AS T2 ON T1.`name` = T2.`name`"} {"question_id": 4418, "db_id": "student_loan", "grading_method": "set", "question": "List out the names of all bankrupt students that are able to make payment before due?", "evidence": "make payment before due refers to bool = 'neg';", "SQL": "SELECT T1.name FROM filed_for_bankrupcy AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'neg'"} {"question_id": 4427, "db_id": "student_loan", "grading_method": "set", "question": "Give the number of students who have payment due.", "evidence": "who have payment due refers to bool = 'pos';", "SQL": "SELECT COUNT(name) FROM no_payment_due WHERE bool = 'pos'"} {"question_id": 4428, "db_id": "student_loan", "grading_method": "set", "question": "Mention the names of disabled students who have never been absent from school.", "evidence": "longest_absense_from_school.month records the longest absence in months; zero denotes no absence. disabled records disabled students.", "SQL": "SELECT T1.name FROM disabled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name WHERE T2.month = 0"} {"question_id": 4429, "db_id": "student_loan", "grading_method": "set", "question": "How many unemployed students are enlisted in the navy organization?", "evidence": "enlisted in the navy organization refers to organ = 'navy';", "SQL": "SELECT COUNT(DISTINCT T1.`name`) AS cnt\nFROM `unemployed` AS T1\nJOIN `enlist` AS T2 ON T1.`name` = T2.`name`\nWHERE T2.`organ` = 'navy';"} {"question_id": 4437, "db_id": "student_loan", "grading_method": "set", "question": "State the names of unemployed students who had the longest absence from school.", "evidence": "unemployed students refers to the names listed in unemployed; the longest absence from school refers to MAX(longest_absense_from_school.month) taken over those unemployed students only; return the names of the students whose month equals that maximum", "SQL": "SELECT u.`name`\nFROM `unemployed` AS u\nJOIN `longest_absense_from_school` AS l ON u.`name` = l.`name`\nWHERE l.`month` = (\n SELECT MAX(l2.`month`)\n FROM `longest_absense_from_school` AS l2\n JOIN `unemployed` AS u2 ON l2.`name` = u2.`name`\n);"} {"question_id": 4438, "db_id": "student_loan", "grading_method": "set", "question": "Mention the names of unemployed students who have never been absent from school.", "evidence": "longest_absense_from_school.month = 0 denotes no recorded absence; unemployed records unemployed students.", "SQL": "SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.month = 0"} {"question_id": 4440, "db_id": "student_loan", "grading_method": "set", "question": "Mention the name of students who filed for bankruptcy and have never been absent from school.", "evidence": "have never been absent refers to month = 0;", "SQL": "SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name WHERE T1.month = 0"} {"question_id": 4441, "db_id": "student_loan", "grading_method": "set", "question": "State the names of students who filed for bankruptcy and had the longest absence from school.", "evidence": "filed for bankruptcy refers to appearing in filed_for_bankrupcy; the longest absence from school refers to longest_absense_from_school.month = MAX(month); state the names of the students who filed for bankruptcy and had that longest absence", "SQL": "SELECT f.`name` FROM `filed_for_bankrupcy` AS f JOIN `longest_absense_from_school` AS l ON f.`name` = l.`name` WHERE l.`month` = (SELECT MAX(`month`) FROM `longest_absense_from_school`)"} {"question_id": 4442, "db_id": "student_loan", "grading_method": "set", "question": "What is the gender of student1000? 'female' or 'male'", "evidence": "student name appear in Male table means student is a male, student does not appear in Male table means student is a female", "SQL": "SELECT IIF(T.result = 0, 'female', 'male') AS re FROM ( SELECT COUNT(name) AS result FROM male WHERE name = 'student1000' ) T"} {"question_id": 4447, "db_id": "student_loan", "grading_method": "set", "question": "What is the average length, in months, of students’ longest recorded school absences?", "evidence": "average length, in months, of students' longest recorded school absences = AVG(month) over every longest_absense_from_school record", "SQL": "SELECT AVG(month) FROM longest_absense_from_school"} {"question_id": 4448, "db_id": "student_loan", "grading_method": "set", "question": "Sum up the number of students enlisted in foreign legion, peace corps, or army.", "evidence": "enlisted in foreign legion refers to organ = 'foreign_legion'; peace corps refers to organ = 'peace_corps'; army refers to organ = 'army'", "SQL": "SELECT COUNT(DISTINCT name) FROM enlist WHERE organ IN ('army', 'peace_corps', 'foreign_legion')"} {"question_id": 4449, "db_id": "student_loan", "grading_method": "set", "question": "Among the students enlisted in marines, how many of them are disabled?", "evidence": "enlisted in marines refers to organ = 'marines';", "SQL": "SELECT COUNT(DISTINCT T1.name) FROM enlist AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.organ = 'marines'"} {"question_id": 4457, "db_id": "student_loan", "grading_method": "set", "question": "List all the disabled female students.", "evidence": "", "SQL": "SELECT `name`\nFROM `disabled`\nWHERE `name` NOT IN (SELECT `name` FROM `male`);"} {"question_id": 4459, "db_id": "student_loan", "grading_method": "set", "question": "Among students enlisted in the fire department, find the percentage of male students. Round your answer to 1 decimal place.", "evidence": "students enlisted in the fire department refers to enlist.organ = 'fire_department'; male students refers to those whose enlist.name appears in male; percentage = DIVIDE(COUNT(DISTINCT male student names), COUNT(DISTINCT enlisted student names)) * 100, rounded to 1 decimal place", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * COUNT(DISTINCT m.name)\n / COUNT(DISTINCT e.name) AS percentage_male\nFROM `enlist` AS e\nLEFT JOIN `male` AS m ON e.`name` = m.`name`\nWHERE e.`organ` = 'fire_department'\n) SELECT ROUND(value, 1) FROM unrounded;"} {"question_id": 4462, "db_id": "student_loan", "grading_method": "set", "question": "How many students are enrolled in UCLA school?", "evidence": "enrolled in UCLA refers to school = 'ucla';", "SQL": "SELECT COUNT(name) FROM enrolled WHERE school = 'ucla'"} {"question_id": 4475, "db_id": "student_loan", "grading_method": "subset,=,5", "question": "List 5 students who have payment due and are enlisted in Peace Corps organization.", "evidence": "have payment due refers to bool = 'pos'; organization refers to organ; organ = 'peace_corps';", "SQL": "SELECT DISTINCT T1.name FROM no_payment_due AS T1 INNER JOIN enlist AS T2 ON T2.name = T1.name WHERE T2.organ = 'peace_corps' AND T1.bool = 'pos'"} {"question_id": 4483, "db_id": "student_loan", "grading_method": "set", "question": "Provide the students' names and schools who enrolled for 15 months.", "evidence": "enrolled for 15 months refers to month = 15;", "SQL": "SELECT name, school FROM enrolled WHERE month = 15"} {"question_id": 4488, "db_id": "student_loan", "grading_method": "set", "question": "List down the student names who did not file for bankruptcy.", "evidence": "students name who did not file a bankruptcy refers to person.name who are NOT in filed_for_bankrupcy.name;", "SQL": "SELECT name FROM person WHERE name NOT IN ( SELECT name FROM filed_for_bankrupcy )"} {"question_id": 4504, "db_id": "student_loan", "grading_method": "set", "question": "Please provide a disability breakdown for each school and list each school name.", "evidence": "disability breakdown refers to the number of disabled students;", "SQL": "SELECT T1.school, COUNT(T1.name) FROM enrolled AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name GROUP BY T1.school"} {"question_id": 4507, "db_id": "student_loan", "grading_method": "set", "question": "What is the percentage decrease from the number of students whose longest absence was zero months to the number whose longest absence was nine months?", "evidence": "longest absence of zero months refers to longest_absense_from_school.month = 0 and of nine months to month = 9, one row per student; percentage decrease = DIVIDE(MULTIPLY(SUBTRACT(COUNT(students with month = 0), COUNT(students with month = 9)), 100), COUNT(students with month = 0))", "SQL": "SELECT CAST(((SUM(IIF(month = 0, 1, 0)) - SUM(IIF(month = 9, 1, 0)))) AS REAL) * 100 / SUM(IIF(month = 0, 1, 0)) FROM longest_absense_from_school"} {"question_id": 4508, "db_id": "student_loan", "grading_method": "set", "question": "Which school has the highest student enrollment, and how many of its students filed for bankruptcy?", "evidence": "enrolled.school records a student’s school; filed_for_bankrupcy records students who filed for bankruptcy.", "SQL": "WITH school_num_bkrpc AS (\n SELECT e.`school`,\n COUNT(f.`name`) AS n_bankruptcy,\n COUNT(*) AS n_enrolled\n FROM `enrolled` AS e\n LEFT JOIN `filed_for_bankrupcy` AS f ON f.`name` = e.`name`\n GROUP BY e.`school`\n) SELECT school, n_bankruptcy\nFROM school_num_bkrpc\nWHERE n_enrolled = (SELECT MAX(n_enrolled) FROM school_num_bkrpc)"} {"question_id": 4510, "db_id": "student_loan", "grading_method": "set", "question": "List out students that enrolled in occ school and enlisted in a fire department.", "evidence": "occ school refers to school = 'occ'; department refers to organ; organ = 'fire_department';", "SQL": "SELECT DISTINCT T1.`name` FROM `enlist` AS T1 JOIN `enrolled` AS T2 ON T2.`name` = T1.`name` WHERE T2.`school` = 'occ' AND T1.`organ` = 'fire_department'"} {"question_id": 4532, "db_id": "student_loan", "grading_method": "set", "question": "Count the number of female students who belong to marines organization.", "evidence": "female students refers to enlist.name who are NOT in male.name; organization refers to organ; organ = 'marines';", "SQL": "SELECT COUNT(DISTINCT e.`name`) FROM `enlist` AS e LEFT JOIN `male` AS m ON e.`name` = m.`name` WHERE e.`organ` = 'marines' AND m.`name` IS NULL"} {"question_id": 4535, "db_id": "student_loan", "grading_method": "set", "question": "Mention the payment status of student 299.", "evidence": "no_payment_due.bool uses 'pos' for a payment due and 'neg' for no payment due. Student 299 is recorded as 'student299'.", "SQL": "SELECT bool FROM no_payment_due WHERE name = 'student299'"} {"question_id": 4536, "db_id": "student_loan", "grading_method": "set", "question": "How many students are enlisted to the air force?", "evidence": "Air Force refers to organ = 'air_force';", "SQL": "SELECT COUNT(DISTINCT name) FROM enlist WHERE organ = 'air_force'"} {"question_id": 4537, "db_id": "student_loan", "grading_method": "set", "question": "How many students have been absent from school?", "evidence": "longest_absense_from_school.month records the longest school absence in months; zero denotes no absence.", "SQL": "SELECT COUNT(name) FROM longest_absense_from_school WHERE month >= 1"} {"question_id": 4541, "db_id": "student_loan", "grading_method": "set", "question": "How many disabled students are male?", "evidence": "male students are mentioned in male.name;", "SQL": "SELECT COUNT(T1.name) FROM male AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name"} {"question_id": 4548, "db_id": "student_loan", "grading_method": "set", "question": "Among students absent for 1 month, how many are enlisted in the air force?", "evidence": "longest_absense_from_school.month records absence duration in months; enlist.organ = 'air_force' denotes the air force.", "SQL": "SELECT COUNT(DISTINCT T1.name) FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T1.month = 1 AND T2.organ = 'air_force'"} {"question_id": 4554, "db_id": "student_loan", "grading_method": "set", "question": "What are the names of the students who joined the Marines?", "evidence": "Marines refers to organ = 'marines';", "SQL": "SELECT name FROM enlist WHERE organ = 'marines'"} {"question_id": 4557, "db_id": "student_loan", "grading_method": "set", "question": "What is the name of the organization in which most students are enlisted?", "evidence": "the organization refers to enlist.organ; how many students are enlisted in it refers to COUNT(DISTINCT enlist.name) for that organ, not the number of enlistment rows; the organization in which most students are enlisted refers to the maximum of those counts; return every organ at that maximum", "SQL": "SELECT organ FROM ( SELECT organ, COUNT(DISTINCT name) AS num FROM enlist GROUP BY organ ) WHERE num = ( SELECT COUNT(DISTINCT name) AS num FROM enlist GROUP BY organ ORDER BY COUNT(DISTINCT name) DESC LIMIT 1)"} {"question_id": 4558, "db_id": "student_loan", "grading_method": "set", "question": "How many students have absences of no more than 3 months?", "evidence": "absences of no more than 3 months refers to month <= 3;", "SQL": "SELECT COUNT(name) FROM longest_absense_from_school WHERE month <= 3"} {"question_id": 4560, "db_id": "student_loan", "grading_method": "set", "question": "How many female students have enlisted for the Army?", "evidence": "female students refers to enlist.name who are NOT in male.name; Army refers to organ = 'army';", "SQL": "SELECT COUNT(DISTINCT T1.`name`) AS result\nFROM `enlist` AS T1\nLEFT JOIN `male` AS T3 ON T1.`name` = T3.`name`\nWHERE T1.`organ` = 'army'\n AND T3.`name` IS NULL;"} {"question_id": 4562, "db_id": "student_loan", "grading_method": "set", "question": "How many disabled students have zero absences?", "evidence": "zero absences refers to month = 0;", "SQL": "SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name WHERE T2.month = 0"} {"question_id": 4568, "db_id": "student_loan", "grading_method": "set", "question": "Among the students who filed for bankruptcy with an absence in school of no more than 6 months, how many students enlisted for the fire department?", "evidence": "absence of no more than 6 months refers to month <= 6; department refers to organ; organ = 'fire_department';", "SQL": "SELECT COUNT(DISTINCT l.`name`) FROM `longest_absense_from_school` AS l JOIN `filed_for_bankrupcy` AS f ON f.`name` = l.`name` JOIN `enlist` AS e ON e.`name` = l.`name` WHERE l.`month` <= 6 AND e.`organ` = 'fire_department'"} {"question_id": 4569, "db_id": "student_loan", "grading_method": "set", "question": "How many employed disabled students have zero absences?", "evidence": "employed students refers to disabled.name who are NOT in unemployed.name; zero absences refers to month = 0;", "SQL": "SELECT COUNT(*)\nFROM `disabled` AS d\nJOIN `longest_absense_from_school` AS l ON l.`name` = d.`name`\nWHERE l.`month` = 0\n AND d.`name` NOT IN (SELECT `name` FROM `unemployed`);"} {"question_id": 4582, "db_id": "mental_health_survey", "grading_method": "set", "question": "How many questions in 2014's survey had more than 200 answers?", "evidence": "2014 refer to SurveyID; COUNT(QuestionID) where COUNT(AnswerText) > 200", "SQL": "SELECT COUNT(*) AS num_questions\nFROM (\n SELECT `QuestionID`\n FROM `Answer`\n WHERE `SurveyID` = 2014\n GROUP BY `QuestionID`\n HAVING COUNT(*) > 200\n) t;"} {"question_id": 4587, "db_id": "mental_health_survey", "grading_method": "set", "question": "Please list all the answers to the question \"Any additional notes or comments\" that are not null in 2014's survey.", "evidence": "question refers to questiontext; the answers that are not null refers to AnswerText ! = -1", "SQL": "SELECT T2.AnswerText FROM Question AS T1 INNER JOIN Answer AS T2 ON T1.questionid = T2.QuestionID WHERE T1.questiontext = 'Any additional notes or comments' AND T2.SurveyID = 2014 AND T2.AnswerText <> -1"} {"question_id": 4605, "db_id": "mental_health_survey", "grading_method": "set", "question": "For the question ‘What US state or territory do you work in?’, how many people answered ‘Kansas’?", "evidence": "Question.questiontext records survey questions and Answer.AnswerText records responses, including 'Kansas'.", "SQL": "SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'What US state or territory do you work in?' AND T1.AnswerText = 'Kansas'"} {"question_id": 4614, "db_id": "mental_health_survey", "grading_method": "set", "question": "How many respondents younger than 25 years old did participate in the survey in 2016?", "evidence": "respondents' and 'users' are synonyms; younger than 25 years old refers to AnswerText(SurveyID = 2016& QuestionID = 1)< 25", "SQL": "SELECT COUNT(*)\nFROM `Answer`\nWHERE `SurveyID` = 2016\n AND `QuestionID` = 1\n AND CAST(`AnswerText` AS integer) < 25;"} {"question_id": 4618, "db_id": "mental_health_survey", "grading_method": "set", "question": "How many questions were asked in the mental-health survey questionnaire?", "evidence": "Question.questiontext records a survey question’s text.", "SQL": "SELECT COUNT(questiontext) FROM Question"} {"question_id": 4620, "db_id": "mental_health_survey", "grading_method": "set", "question": "List the top three popular responses to the question of the survey in 2017 with the question ID no.85.", "evidence": "\n\nsurvey in 2017 refers to SurveyID = 2017; questionID = 85; MAX(COUNT(AnswerText))", "SQL": "SELECT AnswerText FROM Answer WHERE QuestionID = 85 AND SurveyID = 2017 GROUP BY AnswerText ORDER BY COUNT(AnswerText) DESC LIMIT 3"} {"question_id": 4622, "db_id": "disney", "grading_method": "set", "question": "In which segment did The Walt Disney Company earn more revenue in 1998: Studio Entertainment or Disney Media Networks?", "evidence": "Segment revenues are recorded in revenue.\"Studio Entertainment[NI 1]\" and revenue.\"Disney Media Networks\"; revenue.Year records the year.", "SQL": "SELECT CASE\n WHEN CAST(`Studio Entertainment[NI 1]` AS REAL) > CAST(`Disney Media Networks` AS REAL)\n THEN 'Studio Entertainment'\n ELSE 'Disney Media Networks'\n END AS bigger_segment\nFROM `revenue`\nWHERE `Year` = 1998;"} {"question_id": 4625, "db_id": "disney", "grading_method": "set", "question": "Among the movies directed by Wolfgang Reitherman, how many of them were released in December?", "evidence": "Dates in characters.release_date are stored as YYYY-MM-DD. The film’s director is recorded in director.director.", "SQL": "SELECT COUNT(movie_title) FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE strftime('%m', T1.release_date) = '12' AND T2.director = 'Wolfgang Reitherman'"} {"question_id": 4632, "db_id": "disney", "grading_method": "set", "question": "Please list the movies directed by Wolfgang Reitherman that can be watched by the general audience.", "evidence": "directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; movies refer to movie_title; general audience refers to MPAA_rating = 'G';", "SQL": "SELECT T1.movie_title FROM `movies_total_gross` AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.MPAA_rating = 'G' AND T2.director = 'Wolfgang Reitherman'"} {"question_id": 4633, "db_id": "disney", "grading_method": "set", "question": "Which character is the villain of the most popular movie?", "evidence": "the most popular movie refers to movie_title where MAX(total_gross);", "SQL": "SELECT c.`villian`\nFROM `movies_total_gross` AS m\nJOIN `characters` AS c ON m.`movie_title` = c.`movie_title`\nORDER BY CAST(REPLACE(REPLACE(m.`total_gross`, ',', ''), '$', '') AS INTEGER) DESC\nLIMIT 1;"} {"question_id": 4636, "db_id": "disney", "grading_method": "set", "question": "Which movie is the character Robin Hood in?", "evidence": "Robin Hood is the main character of the movie which refers to hero = 'Robin Hood'; movie refers to movie_title;", "SQL": "SELECT movie_title FROM characters WHERE hero = 'Robin Hood'"} {"question_id": 4639, "db_id": "disney", "grading_method": "set", "question": "Who is the hero character of the movie whose total gross was $222,527,828?", "evidence": "", "SQL": "SELECT T1.hero FROM characters AS T1 INNER JOIN movies_total_gross AS T2 ON T2.movie_title = T1.movie_title WHERE T2.total_gross = '$222,527,828'"} {"question_id": 4640, "db_id": "disney", "grading_method": "set", "question": "Which song is associated with the most popular Disney movie in 1970s?", "evidence": "the most popular movie refers to movie_title where MAX(total_gross); in 1970s refers to (cast(SUBSTR(release_date, instr(release_date, ', ') + 1) as int) between 1970 and 1979);", "SQL": "SELECT T2.song FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title WHERE CAST(SUBSTR(T1.release_date, INSTR(T1.release_date, ', ') + 1) AS int) BETWEEN 1970 AND 1979 ORDER BY CAST(REPLACE(SUBSTR(T1.total_gross, 2), ',', '') AS float) DESC LIMIT 1"} {"question_id": 4643, "db_id": "disney", "grading_method": "set", "question": "Give the name of the director of the movie in which Verna Felton was the voice actor for its character \"Aunt Sarah\".", "evidence": "", "SQL": "SELECT T1.director FROM director AS T1 INNER JOIN `voice-actors` AS T2 ON T2.movie = T1.name WHERE T2.character = 'Aunt Sarah' AND T2.`voice-actor` = 'Verna Felton'"} {"question_id": 4644, "db_id": "disney", "grading_method": "set", "question": "For the movie in which Tress MacNeille was the voice actor for its character \"Hyacinth Hippo\", what was the release date of that movie?", "evidence": "", "SQL": "SELECT T1.release_date FROM characters AS T1 INNER JOIN `voice-actors` AS T2 ON T2.movie = T1.movie_title WHERE T2.character = 'Hyacinth Hippo' AND T2.`voice-actor` = 'Tress MacNeille'"} {"question_id": 4646, "db_id": "disney", "grading_method": "set", "question": "Which Disney movie directed by Wolfgang Reitherman had the highest inflation-adjusted gross?", "evidence": "movies_total_gross.inflation_adjusted_gross records inflation-adjusted gross. Wolfgang Reitherman is recorded in director.director as 'Wolfgang Reitherman'.", "SQL": "SELECT T1.movie_title FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T2.director = 'Wolfgang Reitherman' ORDER BY CAST(REPLACE(SUBSTR(inflation_adjusted_gross, 2), ',', '') AS REAL) DESC LIMIT 1"} {"question_id": 4647, "db_id": "disney", "grading_method": "set", "question": "Who is the hero character of the adventure movie which was released on 2016/3/4?", "evidence": "Dates in characters.release_date are stored as YYYY-MM-DD. Adventure movies are labelled 'Adventure' in movies_total_gross.genre.", "SQL": "SELECT T1.hero FROM characters AS T1 INNER JOIN movies_total_gross AS T2 ON T2.movie_title = T1.movie_title WHERE T2.genre = 'Adventure' AND T1.release_date = '2016-03-04'"} {"question_id": 4648, "db_id": "disney", "grading_method": "set", "question": "The character Winnie the Pooh has appeared in two Disney movies. Which one had the higher gross?", "evidence": "Winnie the Pooh refers to characters.hero = 'Winnie the Pooh'; the higher gross refers to the greater gross revenue in movies_total_gross.total_gross; return the one of those two Disney movies whose gross revenue is greater, ORDER BY that revenue DESC LIMIT 1", "SQL": "SELECT T1.movie_title FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title WHERE T2.hero = 'Winnie the Pooh' ORDER BY CAST(REPLACE(SUBSTR(total_gross, 2), ',', '') AS REAL) DESC LIMIT 1"} {"question_id": 4656, "db_id": "disney", "grading_method": "set", "question": "How many of Gary Trousdale's movies are adventure movies?", "evidence": "Gary Trousdale refers director = 'Gary Trousdale'; the adventure movie refers to genre = 'Adventure';", "SQL": "SELECT COUNT(T.name) FROM ( SELECT T1.name FROM director AS T1 INNER JOIN movies_total_gross AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Gary Trousdale' AND T2.genre = 'Adventure' GROUP BY T1.name ) T"} {"question_id": 4657, "db_id": "disney", "grading_method": "set", "question": "Which directors worked with voice actor Bill Thompson on the most different movies? Include ties.", "evidence": "Bill Thompson refers to voice-actors.voice-actor = 'Bill Thompson'; voice-actors.movie and director.name both identify the movie of a credit; the most different movies refers to COUNT(DISTINCT director.name) per director.director equal to the greatest such count; return director.director at that count and include ties", "SQL": "SELECT T1.`director` FROM `director` AS T1 JOIN `voice-actors` AS T2 ON T1.`name` = T2.`movie` WHERE T2.`voice-actor` = 'Bill Thompson' GROUP BY T1.`director` HAVING COUNT(DISTINCT T1.`name`) = (SELECT COUNT(DISTINCT T1.`name`) count_name FROM `director` AS T1 JOIN `voice-actors` AS T2 ON T1.`name` = T2.`movie` WHERE T2.`voice-actor` = 'Bill Thompson' GROUP BY T1.`director` ORDER BY count_name DESC LIMIT 1)"} {"question_id": 4659, "db_id": "disney", "grading_method": "set", "question": "List all the voice actors in the movie directed by Ben Sharpsteen which was released on February 9, 1940.", "evidence": "Ben Sharpsteen is the director. In movies_total_gross.release_date, February 9, 1940 is recorded as 'Feb 9, 1940': abbreviated month, day, and four-digit year. In voice-actors, the text 'None' means no voice actor is recorded.", "SQL": "SELECT T2.`voice-actor` FROM director AS T1 INNER JOIN `voice-actors` AS T2 INNER JOIN movies_total_gross AS T3 ON T1.name = T2.movie AND T2.movie = T3.movie_title WHERE T1.director = 'Ben Sharpsteen' AND T3.release_date = 'Feb 9, 1940' AND T2.`voice-actor` != 'None' GROUP BY T2.`voice-actor`"} {"question_id": 4669, "db_id": "disney", "grading_method": "set", "question": "Who voiced the villain in \"The Rescuers\"?", "evidence": "The Rescuers refers to movie_title = 'The Rescuers'; who voiced refers to voice-actor;", "SQL": "SELECT T1.`voice-actor` FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T2.movie_title = T1.movie WHERE T2.movie_title = 'The Rescuers' AND T1.character = T2.villian"} {"question_id": 4676, "db_id": "disney", "grading_method": "set", "question": "What are the total grosses for the movies with Jim Cummings as the voice actor? List the movie, too.", "evidence": "", "SQL": "SELECT DISTINCT\n T2.`movie_title`,\n T2.`total_gross`\nFROM `voice-actors` AS T1\nJOIN `movies_total_gross` AS T2\n ON T2.`movie_title` = T1.`movie`\nWHERE T1.`voice-actor` = 'Jim Cummings'"} {"question_id": 4682, "db_id": "disney", "grading_method": "set", "question": "List the movie titles directed by Jack Kinney.", "evidence": "Jack Kinney refers to director = 'Jack Kinney';", "SQL": "SELECT name FROM director WHERE director = 'Jack Kinney'"} {"question_id": 4690, "db_id": "disney", "grading_method": "set", "question": "Provide the title, total gross, and MPAA rating of the movie which has a hero named Elsa.", "evidence": "Elsa is the main character of the movie which refers to hero = 'Elsa'; title refers to movie_title;", "SQL": "SELECT T1.`movie_title`,\n T1.`total_gross`,\n T1.`MPAA_rating`\nFROM `movies_total_gross` AS T1\nJOIN `characters` AS T2\n ON T1.`movie_title` = T2.`movie_title`\nWHERE T2.`hero` = 'Elsa';"} {"question_id": 4691, "db_id": "disney", "grading_method": "set", "question": "Provide the title, director, and release date of the movie voice-acted by Freddie Jones.", "evidence": "Freddie Jones refers to voice-actor = 'Freddie Jones'; title refers to movie_title;", "SQL": "SELECT T1.movie, T3.director, T2.release_date FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T1.movie = T2.movie_title INNER JOIN director AS T3 ON T3.name = T2.movie_title WHERE T1.`voice-actor` = 'Freddie Jones'"} {"question_id": 4693, "db_id": "disney", "grading_method": "set", "question": "Who directed the most popular movies with recorded directors?", "evidence": "The most popular movie refers MAX(total_gross); who directed refers to director;", "SQL": "SELECT T2.director FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.total_gross = (SELECT T1.total_gross FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name ORDER BY CAST(REPLACE(trim(T1.total_gross, '$'), ',', '') AS REAL) DESC LIMIT 1)"} {"question_id": 4694, "db_id": "disney", "grading_method": "set", "question": "List the voice actors and villains recorded for Cinderella, with the voice actor first.", "evidence": "characters.movie_title records 'Cinderella'; characters.villian records the villain. voice-actors.voice-actor records the voice actor.", "SQL": "SELECT T1.`voice-actor`, T2.villian FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T1.movie = T2.movie_title WHERE T2.movie_title = 'Cinderella'"} {"question_id": 4696, "db_id": "disney", "grading_method": "set", "question": "Provide the directors and MPAA ratings of the musical movies released in 1991.", "evidence": "Musical movies refer to genre = 'Musical'; released in 1991 refers to substr(release_date, length(release_date) - 3, length(release_date)) = '1991';", "SQL": "SELECT T2.director, T1.MPAA_rating FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T1.genre = 'Musical' AND SUBSTR(T1.release_date, LENGTH(T1.release_date) - 3, LENGTH(T1.release_date)) = '1991'"} {"question_id": 4698, "db_id": "disney", "grading_method": "set", "question": "Which movies released from 2001 through 2005 earned more than twice the average total gross for movies released in that period? Give their titles and directors, leaving the director blank when it is unknown.", "evidence": "movies_total_gross.movie_title records the title, release_date records its release date, and total_gross records gross revenue as currency text. director.director records the director’s name.", "SQL": "SELECT m.`movie_title` AS title,\n d.`director`\nFROM `movies_total_gross` m\nLEFT JOIN `director` d\n ON m.`movie_title` = d.`name`\nWHERE SUBSTR(m.`release_date`, LENGTH(m.`release_date`) - 3, 4) BETWEEN '2001' AND '2005'\n AND CAST(REPLACE(TRIM(m.`total_gross`, '$'), ',', '') AS REAL) >\n 2 * ( SELECT AVG(CAST(REPLACE(TRIM(`total_gross`, '$'), ',', '') AS REAL))\n FROM `movies_total_gross`\n WHERE SUBSTR(`release_date`, LENGTH(`release_date`) - 3, 4) BETWEEN '2001' AND '2005' );"} {"question_id": 4701, "db_id": "disney", "grading_method": "set", "question": "List the movie titles featuring voice actor Jeff Bennett.", "evidence": "Voice-acting credits are in voice-actors; movie records the title. The voice-actor field may contain multiple names separated by semicolons.", "SQL": "SELECT DISTINCT va.movie FROM `voice-actors` va JOIN json_each('[' || REPLACE(json_quote(va.`voice-actor`), ';', '\",\"') || ']') a WHERE TRIM(a.value)='Jeff Bennett'"} {"question_id": 4705, "db_id": "disney", "grading_method": "set", "question": "Provide the name of the song from the movie directed by Ben Sharpsteen.", "evidence": "Ben Sharpsteen refers to director = 'Ben Sharpsteen';", "SQL": "SELECT T1.song FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T2.director = 'Ben Sharpsteen'"} {"question_id": 4707, "db_id": "disney", "grading_method": "set", "question": "Name the villain of the movie with Scott Weinger and Brad Kane as voice actors.", "evidence": "", "SQL": "SELECT c.`villian` FROM `characters` AS c JOIN `voice-actors` AS v ON c.`movie_title` = v.`movie` WHERE v.`voice-actor` LIKE '%Scott Weinger%' AND v.`voice-actor` LIKE '%Brad Kane%'"} {"question_id": 4711, "db_id": "disney", "grading_method": "set", "question": "Among movies with a recorded song, which had the highest total gross? List their song titles.", "evidence": "total gross as a number refers to CAST(REPLACE(TRIM(total_gross, '$'), ',', '') AS REAL), which drops the currency symbols and comma separators; movies with a recorded song refers to the movies_total_gross rows paired with a characters row for the same movies; the highest total gross refers to the MAX of that number over those paired rows; list the characters.song of every paired row at that MAX", "SQL": "SELECT T2.song FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title WHERE CAST(REPLACE(trim(T1.total_gross, '$'), ',', '') AS REAL) = (SELECT CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL) FROM movies_total_gross INNER JOIN characters USING(movie_title) ORDER BY CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL) DESC LIMIT 1);"} {"question_id": 4712, "db_id": "disney", "grading_method": "set", "question": "Which directors had the most popular films from 1937 to 1990?", "evidence": "from 1937 to 1990 refers to substr(release_date, length(release_date) - 3, length(release_date)) between '1937' and '1990'; the most popular film refers to movie_title where MAX(total_gross);", "SQL": "SELECT T2.director FROM characters AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name INNER JOIN movies_total_gross AS T3 ON T3.movie_title = T1.movie_title WHERE SUBSTR(T3.release_date, LENGTH(T3.release_date) - 3, LENGTH(T3.release_date)) BETWEEN '1937' AND '1990' AND CAST(REPLACE(trim(T3.total_gross, '$'), ',', '') AS REAL)= (SELECT MAX(CAST(REPLACE(trim(T4.total_gross, '$'), ',', '') AS REAL)) FROM characters AS T5 INNER JOIN movies_total_gross AS T4 ON T5.movie_title = T4.movie_title WHERE SUBSTR(T4.release_date, LENGTH(T4.release_date) - 3, LENGTH(T4.release_date)) BETWEEN '1937' AND '1990');"} {"question_id": 4714, "db_id": "disney", "grading_method": "set", "question": "Provide the names of voice actors for the characters of films directed by Wolfgang Reitherman.", "evidence": "Wolfgang Reitherman refers to director = 'Wolfgang Reitherman';", "SQL": "SELECT DISTINCT `voice-actor`\nFROM `voice-actors`\nWHERE `movie` IN (\n SELECT `name`\n FROM `director`\n WHERE `director` = 'Wolfgang Reitherman'\n);"} {"question_id": 4716, "db_id": "disney", "grading_method": "set", "question": "Which actor voiced the main character Elsa, and who directed the movie?", "evidence": "Elsa is recorded in characters.hero and voice-actors.character as 'Elsa'. Voice actors are recorded in voice-actors.\"voice-actor\"; film directors are recorded in director.director.", "SQL": "SELECT T1.`voice-actor`,\n T3.`director`\nFROM `voice-actors` AS T1\nJOIN `characters` AS T2 ON T1.`movie` = T2.`movie_title`\nJOIN `director` AS T3 ON T2.`movie_title` = T3.`name`\nWHERE T2.`hero` = 'Elsa'\n AND T1.`character` = 'Elsa';"} {"question_id": 4718, "db_id": "disney", "grading_method": "set", "question": "What percentage of all voice actors voiced a main character in at least one Drama movie?", "evidence": "Main characters are recorded in characters.hero; 'and' separates names when more than one is listed. Voice-acting credits are in voice-actors: character and movie identify the role, and semicolons separate multiple names in voice-actor. The text 'None' or NULL means no voice actor is recorded. Movie genres are in movies_total_gross.genre. Titles can be reused for remakes; release years distinguish versions in these catalogs, although release days may differ. characters.release_date uses YYYY-MM-DD; movies_total_gross.release_date uses an abbreviated month, day and four-digit year.", "SQL": "WITH voice_credits AS (\n SELECT va.movie, va.character, TRIM(a.value) AS actor\n FROM `voice-actors` AS va\n JOIN json_each('[' || REPLACE(json_quote(va.`voice-actor`), ';', '\",\"') || ']') AS a\n WHERE a.value IS NOT NULL AND TRIM(a.value) NOT IN ('', 'None')\n),\ndrama_actors AS (\n SELECT DISTINCT vc.actor\n FROM characters AS c\n JOIN movies_total_gross AS m\n ON m.movie_title = c.movie_title\n AND SUBSTR(m.release_date, -4) = SUBSTR(c.release_date, 1, 4)\n JOIN json_each('[' || REPLACE(json_quote(c.hero), ' and ', '\",\"') || ']') AS h\n JOIN voice_credits AS vc\n ON vc.movie = c.movie_title AND vc.character = TRIM(h.value)\n WHERE m.genre = 'Drama'\n)\nSELECT 100.0 * (SELECT COUNT(*) FROM drama_actors)\n / (SELECT COUNT(DISTINCT actor) FROM voice_credits) AS percentage;"} {"question_id": 4719, "db_id": "disney", "grading_method": "set", "question": "Which Disney film was released first?", "evidence": "Dates in characters.release_date are stored as YYYY-MM-DD.", "SQL": "SELECT movie_title FROM characters WHERE julianday(release_date) = (SELECT MIN(julianday(release_date)) FROM characters)"} {"question_id": 4721, "db_id": "disney", "grading_method": "set", "question": "Who was the villain in Disney’s earliest film?", "evidence": "Dates in characters.release_date are stored as YYYY-MM-DD.", "SQL": "SELECT villian FROM characters WHERE julianday(release_date) = (SELECT MIN(julianday(release_date)) FROM characters)"} {"question_id": 4723, "db_id": "disney", "grading_method": "set", "question": "Which actor voices Akela from The Jungle Book?", "evidence": "Akela refers character = 'Akela'; which actor voices refers to voice-actor;", "SQL": "SELECT `voice-actor` FROM `voice-actors` WHERE character = 'Akela'"} {"question_id": 4725, "db_id": "disney", "grading_method": "set", "question": "Name the main character of Disney's most popular adventure movie based on its inflation-adjusted gross.", "evidence": "adventure movie refers to genre = 'Adventure'; the main character of the movie refers to hero; most popular movie based on its inflation-adjusted gross refers to where MAX(inflation_adjusted_gross);", "SQL": "WITH hero_gross AS (\n SELECT T2.hero, CAST(REPLACE(trim(T1.inflation_adjusted_gross, '$'), ',', '') AS REAL) gross\n FROM movies_total_gross AS T1 \n INNER JOIN characters AS T2 \n ON T1.movie_title = T2.movie_title \n WHERE T1.genre = 'Adventure'\n) SELECT hero FROM hero_gross WHERE gross = (SELECT MAX(gross) FROM hero_gross)"} {"question_id": 4729, "db_id": "disney", "grading_method": "set", "question": "How many voice-actors were involved in the Bambi movie?", "evidence": "Bambi is the name of the movie which refers to movie = 'Bambi';", "SQL": "SELECT COUNT(DISTINCT `voice-actor`)\nFROM `voice-actors`\nWHERE `movie` = 'Bambi';"} {"question_id": 4733, "db_id": "disney", "grading_method": "set", "question": "Name actors who voiced more than five Disney characters.", "evidence": "Actors who voiced refers to voice-actor; exclude missing actor names, including the literal 'None'; count distinct character names per actor.", "SQL": "SELECT `voice-actor` FROM `voice-actors` WHERE `voice-actor` IS NOT NULL AND `voice-actor` <> 'None' GROUP BY `voice-actor` HAVING COUNT(DISTINCT character) > 5"} {"question_id": 4739, "db_id": "legislator", "grading_method": "set", "question": "Among all the current female legislators, how many of them have not been registered in Federal Election Commission data?", "evidence": "have not been registered refers to fec_id IS NULL; female refers to gender_bio = 'F'", "SQL": "SELECT COUNT(*) FROM current WHERE (fec_id IS NULL OR fec_id = '') AND gender_bio = 'F'"} {"question_id": 4751, "db_id": "legislator", "grading_method": "set", "question": "For which state did current legislator Sherrod Brown serve during his term that started on 1993/1/5?", "evidence": "Sherrod Brown is an full official name; started on 1993/1/5 refers to start = '1993-01-05';", "SQL": "SELECT T1.state FROM `current-terms` AS T1 INNER JOIN current AS T2 ON T2.bioguide_id = T1.bioguide WHERE T1.start = '1993-01-05' AND T2.official_full_name = 'Sherrod Brown'"} {"question_id": 4753, "db_id": "legislator", "grading_method": "set", "question": "Among the current legislators who have served for more than 6 terms, how many of them were born after 1960?", "evidence": "current lists current legislators; current.birthday_bio records birth dates. current-terms records their terms of service.", "SQL": "SELECT COUNT(CID) FROM ( SELECT T1.bioguide_id AS CID FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.birthday_bio > '1960-12-31' GROUP BY T2.bioguide HAVING COUNT(T2.bioguide) > 6 )"} {"question_id": 4756, "db_id": "legislator", "grading_method": "set", "question": "How many males were members of the current legislators?", "evidence": "male refers to gender_bio = 'M'", "SQL": "SELECT COUNT(*) FROM current WHERE gender_bio = 'M'"} {"question_id": 4767, "db_id": "legislator", "grading_method": "set", "question": "What is the numeric ID of Chris Van Hollen on GovTrack.us?", "evidence": "Chris Van Hollen is an official_full_name; numeric ID on GovTrack.us refers to govtrack", "SQL": "SELECT T2.govtrack FROM current AS T1 INNER JOIN `social-media` AS T2 ON T2.bioguide = T1.bioguide_id WHERE T1.official_full_name = 'Chris Van Hollen'"} {"question_id": 4770, "db_id": "legislator", "grading_method": "set", "question": "Provide the full name of all current female legislators that chose Republican as their political party.", "evidence": "full name refers to official_full_name, which is recorded in its own column and is not first_name and last_name joined together; female refers to gender_bio = 'F'; chose Republican as their political party refers to party = 'Republican'", "SQL": "SELECT c.`official_full_name`\nFROM `current` AS c\nJOIN (\n SELECT `bioguide`, MAX(`end`) AS max_end\n FROM `current-terms`\n GROUP BY `bioguide`\n) AS ct ON c.`bioguide_id` = ct.`bioguide`\nJOIN `current-terms` t ON t.`bioguide` = ct.`bioguide` AND t.`end` = ct.`max_end`\nWHERE c.`gender_bio` = 'F'\n AND t.`party` = 'Republican';"} {"question_id": 4773, "db_id": "legislator", "grading_method": "set", "question": "What was the average yearly number of male Democrats serving from 2000 through 2021, considering only legislators listed as current?", "evidence": "The current table contains legislators classified as current in this dataset. current.gender_bio = 'M' denotes male. current-terms.party records the latest party during a term; party_affiliations records within-term changes. current-terms.start and end use YYYY-MM-DD; end is the last date of service.", "SQL": "WITH years(y) AS (\n SELECT 2000 UNION ALL SELECT 2001 UNION ALL SELECT 2002 UNION ALL SELECT 2003 UNION ALL\n SELECT 2004 UNION ALL SELECT 2005 UNION ALL SELECT 2006 UNION ALL SELECT 2007 UNION ALL\n SELECT 2008 UNION ALL SELECT 2009 UNION ALL SELECT 2010 UNION ALL SELECT 2011 UNION ALL\n SELECT 2012 UNION ALL SELECT 2013 UNION ALL SELECT 2014 UNION ALL SELECT 2015 UNION ALL\n SELECT 2016 UNION ALL SELECT 2017 UNION ALL SELECT 2018 UNION ALL SELECT 2019 UNION ALL\n SELECT 2020 UNION ALL SELECT 2021\n),\nper_year AS (\n SELECT y.y AS yr,\n COUNT(DISTINCT c.`bioguide_id`) AS male_dem_count\n FROM years y\n JOIN `current-terms` t\n ON CAST(substr(t.`start`,1,4) AS INT) <= y.y\n AND (t.`end` IS NULL OR CAST(substr(t.`end`,1,4) AS INT) >= y.y)\n JOIN `current` c ON c.`bioguide_id` = t.`bioguide`\n WHERE c.`gender_bio` = 'M'\n AND t.`party` = 'Democrat'\n GROUP BY y.y\n)\nSELECT AVG(male_dem_count) AS avg_male_dem_legislators_2000_2021\nFROM per_year;"} {"question_id": 4775, "db_id": "legislator", "grading_method": "set", "question": "Give the YouTube ID of the channel 'RepWassermanSchultz.'", "evidence": "RepWassermanSchultz refers to youtube", "SQL": "SELECT youtube_id FROM `social-media` WHERE youtube = 'RepWassermanSchultz'"} {"question_id": 4777, "db_id": "legislator", "grading_method": "set", "question": "Which party does Christopher Henderson Clark belong to?", "evidence": "Christopher Henderson Clark is full name; full name refers to first_name, middle_name, last_name", "SQL": "SELECT DISTINCT ht.`party`\nFROM `historical-terms` AS ht\nJOIN `historical` AS h\n ON h.`bioguide_id` = ht.`bioguide`\nWHERE h.`first_name` = 'Christopher'\n AND h.`middle_name` = 'Henderson'\n AND h.`last_name` = 'Clark';"} {"question_id": 4784, "db_id": "legislator", "grading_method": "set", "question": "What is the contact URL of Claire McCaskill?", "evidence": "contact URL refers to contact_form; Claire McCaskill is an official_full_name", "SQL": "SELECT T2.contact_form FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.official_full_name = 'Claire McCaskill' GROUP BY T2.contact_form"} {"question_id": 4790, "db_id": "legislator", "grading_method": "set", "question": "Among the legislators who are currently serving and will end in 2009, how many are from the Republican party?", "evidence": "the legislators who will end in 2009 refers to END 2009; from the Republican party refers to party = 'Republican'", "SQL": "SELECT COUNT(*)\n FROM `current-terms`\n WHERE STRFTIME('%Y', `end`) = '2009'\n AND `party` = 'Republican';"} {"question_id": 4792, "db_id": "legislator", "grading_method": "set", "question": "What percentage of historical senators served at least one term in class 1?", "evidence": "historical senators refers to rows of `historical-terms` with type = 'sen'; served at least one term in class 1 refers to class = 1; percentage = DIVIDE(COUNT(DISTINCT bioguide with class = 1), COUNT(DISTINCT bioguide)) * 100", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN class = 1 THEN bioguide END) / COUNT(DISTINCT bioguide) FROM `historical-terms` WHERE type = 'sen'"} {"question_id": 4797, "db_id": "legislator", "grading_method": "set", "question": "Among legislators who have an Instagram account, list down their full names and nicknames who have a Thomas ID of less than 1000.", "evidence": "have an Instagram account refers to instagram is not null; full names refers to official_full_name; nicknames refers to nickname_name; Thomas ID of less than 1000 refers to thomas_id < 1000;", "SQL": "SELECT T1.official_full_name, T1.nickname_name FROM current AS T1 INNER JOIN `social-media` AS T2 ON T2.bioguide = T1.bioguide_id WHERE T2.instagram IS NOT NULL AND T1.thomas_id < 1000"} {"question_id": 4802, "db_id": "legislator", "grading_method": "set", "question": "Report the difference between the number of all legislators who started their term in 2005 and 1875?", "evidence": "started the term in 1875 refers to start LIKE '1875%'; started the term in 2005 refers to start LIKE '2005%'", "SQL": "WITH all_terms AS ( SELECT `bioguide`, `start` FROM `historical-terms` UNION ALL SELECT `bioguide`, `start` FROM `current-terms` ) SELECT (SELECT COUNT(DISTINCT bioguide) FROM all_terms WHERE start LIKE '2005%') - (SELECT COUNT(DISTINCT bioguide) FROM all_terms WHERE start LIKE '1875%')"} {"question_id": 4805, "db_id": "legislator", "grading_method": "set", "question": "What is the birthday of Amy Klobuchar?", "evidence": "birthday refers to birthday_bio; Amy Klobuchar refers to full name; full name refers to first_name, last_name", "SQL": "SELECT birthday_bio FROM current WHERE first_name = 'Amy' AND last_name = 'Klobuchar'"} {"question_id": 4818, "db_id": "legislator", "grading_method": "set", "question": "State the opensecrets_id of the current legislator whose YouTube name is Bluetkemeyer.", "evidence": "Bluetkemeyer refers to youtube", "SQL": "SELECT T1.opensecrets_id FROM current AS T1 INNER JOIN `social-media` AS T2 ON T2.bioguide = T1.bioguide_id WHERE T2.youtube = 'BLuetkemeyer'"} {"question_id": 4823, "db_id": "legislator", "grading_method": "set", "question": "Give the religion of the current legislator whose YouTube name is MaxineWaters.", "evidence": "MaxineWaters relates to youtube", "SQL": "SELECT T2.religion_bio FROM `social-media` AS T1 INNER JOIN current AS T2 ON T1.bioguide = T2.bioguide_id WHERE T1.youtube = 'MaxineWaters'"} {"question_id": 4825, "db_id": "legislator", "grading_method": "set", "question": "How many of the current legislators are male?", "evidence": "male refers to gender_bio = 'M';", "SQL": "SELECT COUNT(*) FROM current WHERE gender_bio = 'M'"} {"question_id": 4827, "db_id": "legislator", "grading_method": "set", "question": "What is the total number of current legislators with \"John\" as their first name?", "evidence": "", "SQL": "SELECT COUNT(*) FROM current WHERE first_name = 'John'"} {"question_id": 4829, "db_id": "legislator", "grading_method": "set", "question": "List the official full names of current legislators born in 1960.", "evidence": "current.birthday_bio is the birth date, stored as YYYY-MM-DD.", "SQL": "SELECT official_full_name FROM current WHERE birthday_bio LIKE '1960%'"} {"question_id": 4830, "db_id": "legislator", "grading_method": "set", "question": "What is the google entity ID of Benjamin Hawkins?", "evidence": "", "SQL": "SELECT google_entity_id_id FROM historical WHERE first_name = 'Benjamin' AND last_name = 'Hawkins'"} {"question_id": 4841, "db_id": "legislator", "grading_method": "set", "question": "Give the state and type of term of the historical legislator with the google entity ID of kg:/m/02pyzk.", "evidence": "type of term refers to type; google entity ID refers to google_entity_id_id; google_entity_id_id = 'kg:/m/02pyzk';", "SQL": "SELECT T2.state, T2.type FROM historical AS T1 INNER JOIN `historical-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.google_entity_id_id = 'kg:/m/02pyzk'"} {"question_id": 4850, "db_id": "legislator", "grading_method": "set", "question": "How many current legislators are not senators?", "evidence": "The supplied convention identifies nonsenators by a missing class in current-terms.class.", "SQL": "SELECT COUNT(DISTINCT bioguide) FROM `current-terms` WHERE class IS NULL"} {"question_id": 4857, "db_id": "legislator", "grading_method": "set", "question": "List the first and last names of senators who were junior senators during 2009.", "evidence": "current-terms.state_rank and historical-terms.state_rank use 'junior' for a junior senator; for completed terms, rank is recorded at the term’s end. The terms tables record service start and end dates; end is the last date of service. current-terms dates use YYYY-MM-DD.", "SQL": "WITH current_legistors AS (\n SELECT T1.bioguide_id, T1.first_name, T1.last_name \n FROM current AS T1 \n INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide \n WHERE T2.start <= '2009-12-31' \n AND T2.end >= '2009-01-01'\n AND T2.state_rank = 'junior'\n), historical_legistors AS (\n SELECT T1.bioguide_id, T1.first_name, T1.last_name \n FROM historical AS T1 \n INNER JOIN `historical-terms` AS T2 ON T1.bioguide_id = T2.bioguide \n WHERE T2.start <= '2009-12-31' \n AND T2.end >= '2009-01-01'\n AND T2.state_rank = 'junior'\n) SELECT first_name, last_name\nFROM (SELECT * FROM current_legistors UNION ALL SELECT * FROM historical_legistors)\nGROUP BY bioguide_id"} {"question_id": 4861, "db_id": "legislator", "grading_method": "set", "question": "Which historical female legislators that have their term ended on the 3rd of January 1971? Return their first names and last names.", "evidence": "female legislator refers to gender_bio = 'F'; term ended on the 3rd of Januray 1971 refers to end = '1971-01-03';", "SQL": "SELECT T1.first_name, T1.last_name FROM historical AS T1 INNER JOIN `historical-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T2.end = '1971-01-03' AND T1.gender_bio = 'F'"} {"question_id": 4862, "db_id": "legislator", "grading_method": "set", "question": "List the first names and last names of all the Jewish current legislators that are serving in Florida.", "evidence": "Jewish refers to religion_bio = 'Jewish'; in Florida refers to state = 'FL';", "SQL": "SELECT T1.first_name, T1.last_name FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.religion_bio = 'Jewish' AND T2.state = 'FL' GROUP BY T1.first_name, T1.last_name"} {"question_id": 4866, "db_id": "legislator", "grading_method": "set", "question": "How many current class 1 senators belong to the Republican party?", "evidence": "senators refers to type = 'sen';", "SQL": "SELECT COUNT(DISTINCT t.`bioguide`) AS republican_class1_current\nFROM `current-terms` t\nJOIN `current` c ON c.`bioguide_id` = t.`bioguide`\nWHERE t.`type` = 'sen'\n AND t.`class` = 1\n AND t.`party` = 'Republican';"} {"question_id": 4868, "db_id": "legislator", "grading_method": "set", "question": "In California, how many representatives ended their term in 1995?", "evidence": "California refers to state = 'CA'; representatives refers to type = 'rep'; ended the term in 1995 refers to end like '1995%';", "SQL": "SELECT COUNT(*) FROM ( SELECT bioguide, `end` FROM `current-terms` WHERE `state` = 'CA' AND `type` = 'rep' AND `end` LIKE '1995%' UNION ALL SELECT bioguide, `end` FROM `historical-terms` WHERE `state` = 'CA' AND `type` = 'rep' AND `end` LIKE '1995%' ) t"} {"question_id": 4897, "db_id": "legislator", "grading_method": "set", "question": "What is the full official name of the current legislator who has served the most terms?", "evidence": "the terms a current legislator has served refers to their COUNT of current-terms rows; served the most terms refers to that count being the maximum among current legislators; return current.official_full_name", "SQL": "WITH name_term AS (\n SELECT T1.official_full_name, COUNT(*) terms\n FROM current AS T1 INNER JOIN `current-terms` AS T2 \n ON T1.bioguide_id = T2.bioguide \n GROUP BY T2.bioguide\n) SELECT official_full_name FROM name_term WHERE terms = (SELECT MAX(terms) FROM name_term)"} {"question_id": 4899, "db_id": "legislator", "grading_method": "set", "question": "What is the official full name of the current legislator whose current official Facebook presence is \"senjoniernst\"?", "evidence": "current official Facebook presence is \"senjoniernst\" refers to facebook = 'senjoniernst';", "SQL": "SELECT T1.official_full_name FROM current AS T1 INNER JOIN `social-media` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T2.facebook = 'senjoniernst'"} {"question_id": 4903, "db_id": "legislator", "grading_method": "set", "question": "How many female legislators are listed across the current and historical records?", "evidence": "current and historical record legislators; gender_bio = 'F' denotes female. bioguide_id identifies a legislator.", "SQL": "SELECT COUNT(DISTINCT `bioguide_id`) FROM (SELECT `bioguide_id`, `gender_bio` FROM `current` UNION ALL SELECT `bioguide_id`, `gender_bio` FROM `historical`) t WHERE `gender_bio` = 'F'"} {"question_id": 4924, "db_id": "olympics", "grading_method": "set", "question": "How many times has London hosted the Olympic Games?", "evidence": "London refers to city.city_name = 'London'; how many times London has hosted refers to COUNT(DISTINCT games) in games_city for that city", "SQL": "SELECT COUNT(DISTINCT 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": 4927, "db_id": "olympics", "grading_method": "set", "question": "Which sport does the event “Shooting Women’s Trap” belong to?", "evidence": "sport.sport_name records the sport; event.event_name records event names, including Shooting Women’s Trap.", "SQL": "SELECT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T2.event_name LIKE 'Shooting Women%s Trap'"} {"question_id": 4934, "db_id": "olympics", "grading_method": "set", "question": "Give the name of the tallest athlete from Sweden.", "evidence": "the tallest athlete refers to id where MAX(height); from Sweden refers to region_name = 'Sweden'; name refers to full_name;", "SQL": "WITH name_height AS (\n SELECT T3.full_name, T3.height\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 = 'Sweden'\n) SELECT full_name FROM name_height WHERE height = (SELECT MAX(height) FROM name_height)"} {"question_id": 4936, "db_id": "olympics", "grading_method": "set", "question": "Who has participated in the most Olympic Games in the database?", "evidence": "Who refers to full_name; participated in the most Olympic Games refers to MAX(COUNT(games_id));", "SQL": "WITH name_times AS (\n SELECT T1.full_name, COUNT(DISTINCT T2.games_id) num\n FROM person AS T1 \n INNER JOIN games_competitor AS T2 \n ON T1.id = T2.person_id \n GROUP BY T2.person_id\n) SELECT full_name FROM name_times WHERE num = (SELECT MAX(num) FROM name_times)"} {"question_id": 4959, "db_id": "olympics", "grading_method": "set", "question": "Who won the most medals across all their Olympic Games appearances? Give their name.", "evidence": "medals won by a competitor refers to the COUNT of that person's competitor_event records across all their Games appearances whose medal_id identifies a medal apart from 4, which denotes no medal; the most medals refers to the MAX of those counts; return the full_name of every competitor whose count is that MAX", "SQL": "WITH name_medal AS (\n SELECT p.`full_name`, COUNT(*) medals\n FROM `person` AS p\n JOIN `games_competitor` AS gc ON p.`id` = gc.`person_id`\n JOIN `competitor_event` AS ce ON gc.`id` = ce.`competitor_id`\n WHERE ce.`medal_id` IS NOT NULL AND ce.`medal_id` <> 4\n GROUP BY p.`id`\n) SELECT full_name FROM name_medal WHERE medals = (SELECT MAX(medals) FROM name_medal)"} {"question_id": 4961, "db_id": "olympics", "grading_method": "set", "question": "What sports has Chin Eei Hui competed in?", "evidence": "Chin Eei Hui is recorded in person.full_name as 'Chin Eei Hui'; sport.sport_name records sport names.", "SQL": "SELECT DISTINCT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id INNER JOIN competitor_event AS T3 ON T2.id = T3.event_id INNER JOIN games_competitor AS T4 ON T3.competitor_id = T4.id INNER JOIN person AS T5 ON T4.person_id = T5.id WHERE T5.full_name = 'Chin Eei Hui'"} {"question_id": 4962, "db_id": "olympics", "grading_method": "set", "question": "What is the name of the oldest person who participated in the Olympic Games?", "evidence": "the oldest person refers to person_id where MAX(age); name refers to full_name;", "SQL": "SELECT T1.full_name \nFROM person AS T1 \nINNER JOIN games_competitor AS T2 ON T1.id = T2.person_id \nWHERE T2.age = (\n SELECT T4.age\n FROM person AS T3 \n INNER JOIN games_competitor AS T4 ON T3.id = T4.person_id \n ORDER BY T4.age DESC LIMIT 1)"} {"question_id": 4967, "db_id": "olympics", "grading_method": "set", "question": "How many persons in total have participated in 12 meter Mixed Sailing competitions?", "evidence": "12 meter Mixed Sailing competitions refer to event_name = 'Sailing Mixed 12 metres';", "SQL": "SELECT COUNT(DISTINCT gc.`person_id`)\nFROM `competitor_event` ce\nJOIN `event` e ON ce.`event_id` = e.`id`\nJOIN `games_competitor` gc ON ce.`competitor_id` = gc.`id`\nWHERE e.`event_name` = 'Sailing Mixed 12 metres';"} {"question_id": 4969, "db_id": "olympics", "grading_method": "set", "question": "Calculate the percentage of women who have participated in Equestrianism Mixed Three-Day Event, Individual.", "evidence": "the population is the distinct people who participated, counted once each however many times they are entered; percentage of women = DIVIDE(COUNT(distinct participants where gender = 'F'), COUNT(distinct participants))*100 where event_name = 'Equestrianism Mixed Three-Day Event, Individual';", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN p.gender = 'F' THEN p.id END) / COUNT(DISTINCT p.id) AS percentage_women\nFROM `person` p\nJOIN `games_competitor` gc ON p.id = gc.person_id\nJOIN `competitor_event` ce ON gc.id = ce.competitor_id\nJOIN `event` e ON ce.event_id = e.id\nWHERE e.event_name = 'Equestrianism Mixed Three-Day Event, Individual';"} {"question_id": 4973, "db_id": "olympics", "grading_method": "set", "question": "How many athletes participated in the 2014 Winter Olympics?", "evidence": "athletes refer to person_id; 2014 Winter Olympics refer to games_name = '2014 Winter';", "SQL": "SELECT COUNT(DISTINCT T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2014 Winter'"} {"question_id": 4979, "db_id": "olympics", "grading_method": "set", "question": "List out all the medals won by Lee Chong Wei.", "evidence": "medals refer to medal_id where medal_id <> 4;", "SQL": "SELECT T1.medal_name FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN person AS T4 ON T3.person_id = T4.id WHERE T4.full_name = 'Lee Chong Wei' AND T2.medal_id <> 4"} {"question_id": 4986, "db_id": "olympics", "grading_method": "set", "question": "How many female athletes are from the Philippines?", "evidence": "female athletes refer to id where gender = 'F'; from the Philippines region_name = 'Philippines';", "SQL": "SELECT COUNT(DISTINCT T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Philippines' AND T3.gender = 'F'"} {"question_id": 4989, "db_id": "olympics", "grading_method": "set", "question": "How many athletes are there in the region where Clara Hughes is from?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT person_id) FROM person_region WHERE region_id = ( SELECT T1.region_id FROM person_region AS T1 INNER JOIN person AS T2 ON T1.person_id = T2.id WHERE T2.full_name = 'Clara Hughes' )"} {"question_id": 4995, "db_id": "olympics", "grading_method": "set", "question": "How many athletes over the age of 59 competed in the 2016 Summer Olympics?", "evidence": "over the age of 59 refers to age > 59; the 2016 Summer Olympics refer to games_name = '2016 Summer';", "SQL": "SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2016 Summer' AND T2.age > 59"} {"question_id": 5003, "db_id": "olympics", "grading_method": "set", "question": "Tell the weight of Dagfinn Sverre Aarskog.", "evidence": "", "SQL": "SELECT weight FROM person WHERE full_name = 'Dagfinn Sverre Aarskog'"} {"question_id": 5009, "db_id": "olympics", "grading_method": "set", "question": "How many 20-year-old athletes competed in the 1984 Summer Olympic Games?", "evidence": "games.games_name uses '1984 Summer'; games_competitor.age records a competitor’s age at those Games.", "SQL": "SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '1984 Summer' AND T2.age = 20"} {"question_id": 5012, "db_id": "olympics", "grading_method": "set", "question": "How many kinds of events does athletics have?", "evidence": "kinds of events refer to event_name; athletics refer to sport_name = 'Athletics';", "SQL": "SELECT COUNT(T2.event_name) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Athletics'"} {"question_id": 5016, "db_id": "olympics", "grading_method": "set", "question": "Which region has the most athletes?", "evidence": "region refers to region_name; the most athletes refer to MAX(COUNT(region_name));", "SQL": "WITH region_num AS (\n SELECT T2.region_name, COUNT(DISTINCT T1.person_id) num\n FROM person_region AS T1 \n INNER JOIN noc_region AS T2 ON T1.region_id = T2.id \n GROUP BY T2.region_name\n) SELECT region_name FROM region_num WHERE num = (SELECT MAX(num) FROM region_num)"} {"question_id": 5017, "db_id": "olympics", "grading_method": "set", "question": "Among athletes from Vanuatu with both height and weight recorded, what percentage are taller than 175 cm? Round your answer to 2 decimal places.", "evidence": "athletes from Vanuatu refers to region_name = 'Vanuatu'; with both height and weight recorded refers to height <> 0 AND weight <> 0, since missing or zero values are unrecorded; percentage taller than 175 = DIVIDE(COUNT(DISTINCT athletes with height > 175), COUNT(DISTINCT athletes)) * 100; round the final answer to 2 decimal places", "SQL": "SELECT ROUND(100.0 * COUNT(DISTINCT CASE WHEN p.height > 175 THEN p.id END) /\n COUNT(DISTINCT p.id), 2) AS percentage\nFROM noc_region AS nr\nINNER JOIN person_region AS pr ON pr.region_id = nr.id\nINNER JOIN person AS p ON p.id = pr.person_id\nWHERE nr.region_name = 'Vanuatu'\n AND p.height <> 0\n AND p.weight <> 0;"} {"question_id": 5018, "db_id": "olympics", "grading_method": "set", "question": "Calculate the average weight of male athletes from Tonga.", "evidence": "male athletes from Tonga refers to person.gender = 'M' among the athletes whose noc_region.region_name = 'Tonga'; average weight = AVG(person.weight) over those athletes, leaving out weight = 0 because zero denotes an unrecorded weight", "SQL": "SELECT AVG(p.`weight`)\nFROM `noc_region` AS nr\nJOIN `person_region` AS pr ON nr.`id` = pr.`region_id`\nJOIN `person` AS p ON p.`id` = pr.`person_id`\nWHERE nr.`region_name` = 'Tonga'\n AND p.`gender` = 'M'\n AND p.`weight` <> 0;"} {"question_id": 5020, "db_id": "olympics", "grading_method": "set", "question": "From 1900 to 1992, how many games did London host?", "evidence": "From 1900 to 1992 refers to games_year BETWEEN 1900 AND 1992; London refers to city_name = 'London'; games refer to games_name;", "SQL": "SELECT COUNT(T3.id) 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' AND T3.games_year BETWEEN 1900 AND 1992"} {"question_id": 5028, "db_id": "olympics", "grading_method": "set", "question": "How many male competitors participated in the 1948 Summer Olympics?", "evidence": "games.games_name uses '1948 Summer'; person.gender = 'M' denotes male.", "SQL": "SELECT COUNT(DISTINCT gc.`person_id`)\nFROM `games` g\nJOIN `games_competitor` gc ON g.`id` = gc.`games_id`\nJOIN `person` p ON gc.`person_id` = p.`id`\nWHERE g.`games_name` = '1948 Summer'\n AND p.`gender` = 'M';"} {"question_id": 5048, "db_id": "olympics", "grading_method": "set", "question": "Which regions are most athletes from?", "evidence": "the athletes from a region refers to its person_region associations; the most refers to the maximum COUNT of those associations over all regions; return every noc_region.region_name whose count equals that maximum", "SQL": "SELECT T2.region_name FROM person_region AS T1 INNER JOIN noc_region AS T2 ON T1.region_id = T2.id GROUP BY T2.region_name HAVING COUNT(T1.person_id) = (SELECT MAX(region_count) FROM (SELECT COUNT(T3.person_id) AS region_count FROM person_region AS T3 GROUP BY T3.region_id) AS T4);"} {"question_id": 5052, "db_id": "olympics", "grading_method": "set", "question": "How many athletes took part in the Olympic games held in Barcelona?", "evidence": "Barcelona refers to city_name = 'Barcelona';", "SQL": "SELECT COUNT(DISTINCT T1.person_id) FROM games_competitor AS T1 INNER JOIN games_city AS T2 ON T1.games_id = T2.games_id INNER JOIN city AS T3 ON T2.city_id = T3.id WHERE T3.city_name = 'Barcelona'"} {"question_id": 5059, "db_id": "olympics", "grading_method": "set", "question": "What is the average age of Argentina's athletes who participated in the Summer Olympics in 2012?", "evidence": "AVG(age) where games_name = '2012 Summer' and region_name = 'Argentina';", "SQL": "SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person_region AS T3 ON T2.person_id = T3.person_id INNER JOIN noc_region AS T4 ON T3.region_id = T4.id WHERE T1.games_name = '2012 Summer' AND T4.region_name = 'Argentina'"} {"question_id": 5060, "db_id": "olympics", "grading_method": "set", "question": "Among the medals won by men’s-basketball players, what percentage were bronze?", "evidence": "men's basketball refers to event_name = 'Basketball Men''s Basketball'; medal_name = 'NA' means no medal was awarded and is not a medal won; percentage bronze = DIVIDE(COUNT(medal_name = 'Bronze'), COUNT(medal_name != 'NA')) * 100", "SQL": "SELECT CAST(COUNT(CASE WHEN T4.medal_name = 'Bronze' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(CASE WHEN T4.medal_name != 'NA' THEN 1 ELSE NULL END) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id INNER JOIN event AS T3 ON T1.event_id = T3.id INNER JOIN medal AS T4 ON T1.medal_id = T4.id WHERE T3.event_name LIKE 'Basketball Men%s Basketball'"} {"question_id": 5069, "db_id": "olympics", "grading_method": "set", "question": "List down the games ID of games held in Tokyo.", "evidence": "Tokyo refers to city_name = 'Tokyo';", "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 = 'Tokyo'"} {"question_id": 5077, "db_id": "olympics", "grading_method": "set", "question": "How many female competitors were from Iran?", "evidence": "female competitors refer to person_id where gender = 'F'; from Iran refers to region_name = 'Iran';", "SQL": "SELECT COUNT(DISTINCT T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Iran' AND T3.gender = 'F'"} {"question_id": 5078, "db_id": "olympics", "grading_method": "set", "question": "Provide the age of the tallest competitor.", "evidence": "the tallest refers to MAX(height);", "SQL": "SELECT gc.`age`\nFROM person p\nJOIN games_competitor gc ON gc.`person_id` = p.`id`\nWHERE p.`height` = (\n SELECT MAX(p2.`height`)\n FROM person p2\n JOIN games_competitor gc2 ON gc2.`person_id` = p2.`id`\n);"} {"question_id": 5080, "db_id": "olympics", "grading_method": "set", "question": "In the 2014 Winter game, what is the percentage of competitors who age 28 years old?", "evidence": "DIVIDE(COUNT(age = 28), COUNT(id))*100 as percentage where games_name = '2014 Winter';", "SQL": "SELECT CAST(COUNT(DISTINCT CASE WHEN T2.age = 28 THEN T2.person_id END) AS REAL) * 100 / COUNT(DISTINCT T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2014 Winter'"} {"question_id": 5085, "db_id": "address", "grading_method": "set", "question": "Among all the residential areas in Delaware state, how many of them implement daylight saving?", "evidence": "\"Delaware\" is a state; implement daylight savings refers to daylight_saving = 'Yes'", "SQL": "SELECT COUNT(*) FROM `zip_data` WHERE `state` = 'DE' AND `daylight_savings` = 'Yes';"} {"question_id": 5086, "db_id": "address", "grading_method": "set", "question": "Among all the residential areas in Arecibo county, what is the zip_code of the one with the highest white population?", "evidence": "\"ARECIBO\" is the county; highest white population refers to Max(white_population)", "SQL": "SELECT T1.zip_code FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'ARECIBO' ORDER BY T1.white_population DESC LIMIT 1"} {"question_id": 5088, "db_id": "address", "grading_method": "set", "question": "Please list the names of all the counties with at least one residential area that implements daylight saving.", "evidence": "implements daylight savings refers to daylight_savings = 'Yes'", "SQL": "SELECT DISTINCT T2.county FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T1.daylight_savings = 'Yes'"} {"question_id": 5091, "db_id": "address", "grading_method": "set", "question": "Among the residential areas with the bad alias \"Internal Revenue Service\", how many of them are in the Eastern time zone?", "evidence": "\"Internal Revenue Service\" is the bad_alias; in Eastern time zone refers to time_zone = 'Eastern'", "SQL": "SELECT COUNT(T1.zip_code) FROM zip_data AS T1 INNER JOIN avoid AS T2 ON T1.zip_code = T2.zip_code WHERE T2.bad_alias = 'Internal Revenue Service' AND T1.time_zone = 'Eastern'"} {"question_id": 5100, "db_id": "address", "grading_method": "set", "question": "What are the precise locations of the cities with an area code of 787? Only report their latitude and longitude.", "evidence": "precise location refers to latitude, longitude", "SQL": "SELECT T2.latitude, T2.longitude FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = '787' GROUP BY T2.latitude, T2.longitude"} {"question_id": 5107, "db_id": "address", "grading_method": "set", "question": "In the state where Lisa Murkowski is the representative, how many cities have zero employees?", "evidence": "zero employee refers to employees = 0", "SQL": "SELECT COUNT(DISTINCT z.`city`) AS num_cities FROM `congress` AS c JOIN `zip_data` AS z ON c.`abbreviation` = z.`state` WHERE c.`first_name` = 'Murkowski' AND c.`last_name` = 'Lisa' AND z.`employees` = 0"} {"question_id": 5108, "db_id": "address", "grading_method": "set", "question": "For the three states with the highest total Asian population, list each representative’s state abbreviation, followed by their first and last names.", "evidence": "the three states with the highest total Asian population refers to grouping zip_data by state, ordering by SUM(asian_population) descending and taking the top 3; zip_data.state matches congress.abbreviation; return the state abbreviation followed by first_name and last_name for every representative in those states", "SQL": "WITH top_states AS (SELECT state FROM zip_data GROUP BY state ORDER BY SUM(asian_population) DESC LIMIT 3) SELECT T1.state, T2.first_name, T2.last_name FROM top_states AS T1 INNER JOIN congress AS T2 ON T1.state = T2.abbreviation;"} {"question_id": 5116, "db_id": "address", "grading_method": "set", "question": "List all ZIP codes in the congressional district represented by Buchanan Vernon.", "evidence": "", "SQL": "SELECT T2.zip_code FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.first_name = 'Buchanan' AND T1.last_name = 'Vernon'"} {"question_id": 5117, "db_id": "address", "grading_method": "set", "question": "Which state is area code 878 in? Give the name of the state.", "evidence": "", "SQL": "SELECT DISTINCT s.`name`\nFROM `area_code` AS a\nJOIN `zip_data` AS z ON a.`zip_code` = z.`zip_code`\nJOIN `state` AS s ON z.`state` = s.`abbreviation`\nWHERE a.`area_code` = 878;"} {"question_id": 5119, "db_id": "address", "grading_method": "set", "question": "What CBSA is ZIP code 45503 in, and where is that ZIP code located?", "evidence": "CBSA means Core-Based Statistical Area; its name is recorded in CBSA_name. ZIP-code locations are given by latitude and longitude in zip_data.", "SQL": "SELECT T1.CBSA_name, T2.latitude, T2.longitude FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.zip_code = 45503 GROUP BY T1.CBSA_name, T2.latitude, T2.longitude"} {"question_id": 5123, "db_id": "address", "grading_method": "set", "question": "What is the area code of Bishopville, SC?", "evidence": "\"Bishopville\" is the city; 'SC' is the state", "SQL": "SELECT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.city = 'Bishopville' AND T2.state = 'SC'"} {"question_id": 5126, "db_id": "address", "grading_method": "set", "question": " Name both the alias and the bad alias of zip code 38015.", "evidence": "", "SQL": "SELECT T1.alias, T2.bad_alias FROM alias AS T1 INNER JOIN avoid AS T2 ON T1.zip_code = T2.zip_code WHERE T1.zip_code = 38015"} {"question_id": 5131, "db_id": "address", "grading_method": "set", "question": "What is the area code of Phillips county in Montana?", "evidence": "\"PHILLIPS\" is the county; 'Montana' is the name of state", "SQL": "SELECT DISTINCT T1.area_code FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code INNER JOIN state AS T3 ON T2.state = T3.abbreviation WHERE T2.county = 'PHILLIPS' AND T3.name = 'Montana'"} {"question_id": 5136, "db_id": "address", "grading_method": "set", "question": "Calculate the ratio between the number of representatives in Alabama and the number of representatives in Illinois.", "evidence": "\"Alabama\" and \"Illinois\" are both state; Ratio = Divide (Count(state = 'Alabama'), Count(state = 'Illinois'))", "SQL": "SELECT CAST(COUNT(CASE WHEN state = 'Alabama' THEN cognress_rep_id ELSE NULL END) AS REAL) / COUNT(CASE WHEN state = 'Illinois' THEN cognress_rep_id ELSE NULL END) FROM congress"} {"question_id": 5140, "db_id": "address", "grading_method": "set", "question": "List all the bad alias for zip codes in Puerto Rico.", "evidence": "\"Puerto Rico\" refers to state = 'PR'", "SQL": "SELECT DISTINCT T1.bad_alias FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.state = 'PR'"} {"question_id": 5141, "db_id": "address", "grading_method": "set", "question": "What is the longitude and latitude for the district represented by Grayson Alan?", "evidence": "", "SQL": "SELECT T1.latitude, T1.longitude FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T3.first_name = 'Grayson' AND T3.last_name = 'Alan'"} {"question_id": 5142, "db_id": "address", "grading_method": "set", "question": "What state abbreviation corresponds to area code 787?", "evidence": "", "SQL": "SELECT DISTINCT T2.state FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = 787"} {"question_id": 5143, "db_id": "address", "grading_method": "set", "question": "List the first and last names of representatives whose districts have a total recorded ZIP-code population over 30,000 in 2020.", "evidence": "zip_data.population_2020 records population per ZIP code. zip_congress associates ZIP codes with districts; congress.first_name and last_name record representatives’ names.", "SQL": "SELECT c.`first_name`, c.`last_name`\nFROM `congress` AS c\nJOIN `zip_congress` AS zc ON c.`cognress_rep_id` = zc.`district`\nJOIN `zip_data` AS zd ON zc.`zip_code` = zd.`zip_code`\nGROUP BY c.`cognress_rep_id`\nHAVING SUM(zd.`population_2020`) > 30000;"} {"question_id": 5150, "db_id": "address", "grading_method": "set", "question": "Among the residential areas with an area code 939, list the city name of the residential area which has the highest Asian population?", "evidence": "highest asian population refers to Max(asian_population)", "SQL": "SELECT T2.city FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = 939 ORDER BY T2.asian_population DESC LIMIT 1"} {"question_id": 5151, "db_id": "address", "grading_method": "set", "question": "Give the name of the county and state of the city with elevation of 1039.", "evidence": "elevation of 1039 refers to elevation = 1039", "SQL": "SELECT DISTINCT country.`county`, country.`state` FROM `country` JOIN `zip_data` ON country.`zip_code` = zip_data.`zip_code` WHERE zip_data.`elevation` = 1039"} {"question_id": 5154, "db_id": "address", "grading_method": "set", "question": "Which area codes serve ZIP codes with a white population between 1,700 and 2,000?", "evidence": "White population is recorded in zip_data.white_population for each ZIP code. Area codes are recorded in area_code.area_code.", "SQL": "SELECT DISTINCT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.white_population BETWEEN 1700 AND 2000"} {"question_id": 5155, "db_id": "address", "grading_method": "set", "question": "What is the total Asian population in all cities with the alias Leeds?", "evidence": "", "SQL": "SELECT SUM(T2.asian_population) FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'Leeds'"} {"question_id": 5160, "db_id": "address", "grading_method": "set", "question": "List the counties and their state abbreviations that have a city named Dalton.", "evidence": "Dalton is the city;", "SQL": "SELECT DISTINCT c.`county`, c.`state`\nFROM `country` AS c\nJOIN `zip_data` AS z ON z.`zip_code` = c.`zip_code`\nWHERE z.`city` = 'Dalton';"} {"question_id": 5162, "db_id": "address", "grading_method": "set", "question": "For cities with area code 787, how many more have a P.O. Box Only ZIP code than have a Post Office ZIP code?", "evidence": "area code 787 refers to area_code.area_code = 787; a city refers to a DISTINCT city and state; how many more refers to SUBTRACT(COUNT(DISTINCT cities of zip_data.type = 'P.O. Box Only'), COUNT(DISTINCT cities of zip_data.type = 'Post Office')) for the cities with area code 787", "SQL": "with sub1 as (SELECT DISTINCT city, state FROM `area_code` ac JOIN `zip_data` zd ON ac.`zip_code` = zd.`zip_code` WHERE ac.`area_code` = 787 AND zd.`type` = 'P.O. Box Only' ),\nsub2 as (\nSELECT DISTINCT `city`, state FROM `area_code` ac JOIN `zip_data` zd ON ac.`zip_code` = zd.`zip_code` WHERE ac.`area_code` = 787 AND zd.`type` = 'Post Office' \n)\nSELECT (SELECT count(*) from sub1) - (SELECT count(*) from sub2) ;"} {"question_id": 5165, "db_id": "address", "grading_method": "set", "question": "Among the postal points in the District of Columbia, how many of them have an area with above 20000 black population?", "evidence": "District of Columbia refers to county = 'DISTRICT OF COLUMBIA'; postal points refer to zip_code; area with above 20000 black population refers to black_population > 20000;", "SQL": "SELECT COUNT(T1.zip_code) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.county = 'DISTRICT OF COLUMBIA' AND T2.black_population > 20000"} {"question_id": 5166, "db_id": "address", "grading_method": "set", "question": "Provide the city where zip code 19019 is located and the alias of that city.", "evidence": "", "SQL": "SELECT T2.city, T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.zip_code = 19019"} {"question_id": 5170, "db_id": "address", "grading_method": "set", "question": "Provide the counties and the zip codes in the Virgin Islands.", "evidence": "the Virgin Islands refer to state where name = 'Virgin Islands';", "SQL": "SELECT T2.county, T2.zip_code FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Virgin Islands'"} {"question_id": 5173, "db_id": "address", "grading_method": "set", "question": "Provide the zip codes and CBSA officers of the postal point in Oxford.", "evidence": "CBSA officers refer to CBSA_name; postal point refers to zip_code; Oxford is the city;", "SQL": "SELECT T2.zip_code, T1.CBSA_name FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.city = 'Oxford'"} {"question_id": 5175, "db_id": "address", "grading_method": "set", "question": "Provide the zip codes and the congress representatives' names of the postal points which are affiliated with Readers Digest.", "evidence": "representative's full names refer to first_name, last_name; postal points affiliated with Readers Digest refer to zip_code where organization = 'Readers Digest';", "SQL": "SELECT T1.zip_code, T3.first_name, T3.last_name FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T1.organization = 'Readers Digest'"} {"question_id": 5177, "db_id": "address", "grading_method": "set", "question": "Which ZIP codes are linked to a member of the House of Representatives in the database?", "evidence": "congress.House uses the label 'House of Repsentatives'. zip_congress.district identifies the representative in congress.cognress_rep_id.", "SQL": "SELECT T2.zip_code FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.House = 'House of Repsentatives' GROUP BY T2.zip_code"} {"question_id": 5180, "db_id": "address", "grading_method": "set", "question": "List all the locations of postal points with the area code \"410\".", "evidence": "latitude and longitude coordinates can be used to identify the location; postal points refer to zip_code;", "SQL": "SELECT T2.latitude, T2.longitude FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = 410"} {"question_id": 5183, "db_id": "address", "grading_method": "set", "question": "What was the population of Wilcox County, Georgia in 2010?", "evidence": "population of Wilcox County in 2010 refers to SUM(population_2010) where county = 'WILCOX' and state = GA;", "SQL": "SELECT SUM(`population_2010`)\nFROM `country` c\nJOIN `zip_data` z ON c.`zip_code` = z.`zip_code`\nWHERE c.`county` = 'WILCOX' AND c.`state` = 'GA';"} {"question_id": 5186, "db_id": "address", "grading_method": "set", "question": "What are the names of the states with the most counties?", "evidence": "the most counties refer to MAX(COUNT(county));", "SQL": "SELECT S.`name` FROM state AS S JOIN country AS C ON S.`abbreviation` = C.`state` GROUP BY C.`state` HAVING COUNT(DISTINCT C.`county`) = (SELECT MAX(CountyCount) FROM (SELECT COUNT(DISTINCT C2.`county`) AS CountyCount FROM state AS S1 JOIN country AS C2 ON S1.`abbreviation` = C2.`state` GROUP BY C2.`state`) AS CountyCounts);"} {"question_id": 5187, "db_id": "address", "grading_method": "set", "question": "What is the number of households in the \"FL-10\" district?", "evidence": "", "SQL": "SELECT SUM(`households`) FROM `zip_data` AS z JOIN `zip_congress` AS c ON z.`zip_code` = c.`zip_code` WHERE c.`district` = 'FL-10';"} {"question_id": 5189, "db_id": "address", "grading_method": "set", "question": "Which states have a total female population above the average state total? Give their full names.", "evidence": "a state's total female population refers to SUM(zip_data.female_population) over its zip_data records; the average state total refers to AVG of those per-state totals; return the full name of each state whose total is above that average", "SQL": "WITH state_totals AS (\n SELECT `state`, SUM(`female_population`) AS female_total\n FROM `zip_data`\n GROUP BY `state`\n HAVING female_total IS NOT NULL\n), avg_val AS (\n SELECT AVG(female_total) AS avg_female FROM state_totals\n)\nSELECT st.`name`\nFROM state_totals t\nJOIN state st ON st.`abbreviation` = t.`state`\nJOIN avg_val a\nWHERE t.female_total > a.avg_female;"} {"question_id": 5190, "db_id": "address", "grading_method": "set", "question": "What percentage of households are in \"Coryell\" out of its state?", "evidence": "DIVIDE(SUM(households where county = 'CORYELL') * 100, SUM(households)) as percentage;", "SQL": "WITH state_zips AS (\n SELECT DISTINCT z.`zip_code`, z.`households`\n FROM `zip_data` z\n WHERE z.`state` = (SELECT DISTINCT `state` FROM `country` WHERE `county` = 'CORYELL')\n),\n coryell_zips AS (\n SELECT DISTINCT z.`zip_code`, z.`households`\n FROM `zip_data` z\n JOIN `country` c ON c.`zip_code` = z.`zip_code`\n WHERE c.`county` = 'CORYELL'\n)\nSELECT 100.0 * (SELECT SUM(`households`) FROM coryell_zips)\n / (SELECT SUM(`households`) FROM state_zips) AS percentage;"} {"question_id": 5191, "db_id": "address", "grading_method": "set", "question": "What is the name and the position of the CBSA officer in the city of Cabo Rojo?", "evidence": "name of the CBSA officer refers to CBSA_name; position of the CBSA officer refers to CBSA_type;", "SQL": "SELECT T1.CBSA_name, T1.CBSA_type FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.city = 'Cabo Rojo' GROUP BY T1.CBSA_name, T1.CBSA_type"} {"question_id": 5196, "db_id": "address", "grading_method": "set", "question": "Which state or territory has the most recorded bad ZIP-code aliases? Give its abbreviation.", "evidence": "avoid.bad_alias records an incorrect ZIP-code alias; zip_data.state records the state or territory abbreviation.", "SQL": "SELECT T2.state FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code GROUP BY T2.state HAVING COUNT(T1.bad_alias) = (SELECT MAX(cnt) FROM (SELECT COUNT(*) AS cnt FROM avoid AS T3 INNER JOIN zip_data AS T4 ON T3.zip_code = T4.zip_code GROUP BY T4.state) AS subquery);"} {"question_id": 5198, "db_id": "address", "grading_method": "set", "question": "Which states contain ZIP codes in more than 20 metropolitan statistical areas? List their state abbreviations.", "evidence": "metropolitan statistical areas refers to CBSA.CBSA_type = 'Metro'; a state's number of them refers to COUNT(DISTINCT CBSA.CBSA) over the zip_data ZIP codes in that state; more than 20 refers to that count > 20; return the zip_data.state abbreviation of each qualifying state", "SQL": "SELECT zd.state FROM CBSA c JOIN zip_data zd ON c.CBSA = zd.CBSA WHERE c.CBSA_type = 'Metro' GROUP BY zd.state HAVING COUNT(DISTINCT c.CBSA) > 20"} {"question_id": 5199, "db_id": "address", "grading_method": "set", "question": "Provide the total population of all counties named Arecibo in 2020.", "evidence": "population of Arecibo in 2020 refers to SUM(population_2020) where county = 'ARECIBO';", "SQL": "SELECT SUM(T2.population_2020) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.county = 'ARECIBO'"} {"question_id": 5200, "db_id": "address", "grading_method": "set", "question": "Which counties include a ZIP code with more than 10,000 residents in 2010? List their names.", "evidence": "zip_data.population_2010 records a ZIP code's 2010 population. Despite its name, country maps ZIP codes to counties through zip_code, county, and state. A ZIP code can be associated with multiple counties.", "SQL": "SELECT DISTINCT c.county\nFROM country AS c\nJOIN zip_data AS z ON z.zip_code = c.zip_code\nWHERE z.population_2010 > 10000;"} {"question_id": 5201, "db_id": "address", "grading_method": "set", "question": "Which county has the most households across its ZIP codes? Give its name.", "evidence": "households across a county's ZIP codes refers to SUM(zip_data.households) over the zip_code values linked by country.zip_code, grouped by country.county and country.state; the most refers to the largest such total; give only that top county's name, taking 1", "SQL": "SELECT c.`county`\nFROM `country` c\nJOIN `zip_data` z ON z.`zip_code` = c.`zip_code`\nGROUP BY c.`county`, c.state\nORDER BY SUM(z.`households`) DESC\nLIMIT 1;"} {"question_id": 5207, "db_id": "address", "grading_method": "set", "question": "Give the county and area code of the postal point with a zip code 1116.", "evidence": "", "SQL": "SELECT T2.county, T1.area_code FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T1.zip_code = 1116"} {"question_id": 5210, "db_id": "address", "grading_method": "set", "question": "Which area codes belong to the city with the largest water area?", "evidence": "a city's water area refers to SUM(zip_data.water_area) over its ZIP codes, by zip_data.city; the city with the largest water area refers to the city whose total is the maximum of those city totals; the area codes are the area_code.area_code of that city's ZIP codes", "SQL": "SELECT DISTINCT ac.`area_code` FROM zip_data zd JOIN ( SELECT `city`, SUM(`water_area`) AS total_water FROM zip_data GROUP BY `city` ) c ON c.`city` = zd.`city` JOIN area_code ac ON ac.`zip_code` = zd.`zip_code` WHERE c.total_water = ( SELECT MAX(total_water) FROM ( SELECT `city`, SUM(`water_area`) AS total_water FROM zip_data GROUP BY `city` ) )"} {"question_id": 5211, "db_id": "address", "grading_method": "set", "question": "Provide the aliases of the cities with the highest population in year 2020.", "evidence": "A city is identified by its city and state values in zip_data. population_2020 gives the population for one ZIP-code record; a city’s population is the combined population of its ZIP-code records.", "SQL": "WITH city_totals AS (SELECT city, state, SUM(population_2020) AS population FROM zip_data GROUP BY city, state) SELECT DISTINCT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code INNER JOIN city_totals AS T3 ON T2.city = T3.city AND T2.state = T3.state WHERE T3.population = (SELECT MAX(population) FROM city_totals)"} {"question_id": 5214, "db_id": "address", "grading_method": "set", "question": "List the aliases of cities with an Asian population of 7.", "evidence": "zip_data.asian_population records the Asian population for each ZIP code. A city is identified by zip_data.city and zip_data.state. Its Asian population is the total across ZIP codes sharing that city and state. Alternate names are recorded in alias.alias and linked to ZIP codes through alias.zip_code.", "SQL": "WITH selected_cities AS (SELECT city, state FROM zip_data GROUP BY state, city HAVING SUM(asian_population) = 7)\nSELECT alias FROM zip_data T1 JOIN selected_cities T2 ON T1.city = T2.city AND T1.state = T2.state JOIN alias T3 ON T1.zip_code = T3.zip_code GROUP BY T3.zip_code"} {"question_id": 5216, "db_id": "address", "grading_method": "set", "question": "Among the postal points with alias Ponce, what is the percentage of postal points with a country level FIPS code of less than 20?", "evidence": "DIVIDE(COUNT(county_fips < 20) * 100, COUNT(county_fips)) as percentage where alias = 'Ponce';", "SQL": "SELECT CAST(COUNT(CASE WHEN T2.county_fips < 20 THEN T2.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T2.zip_code) FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'Ponce'"} {"question_id": 5217, "db_id": "address", "grading_method": "set", "question": "List down the county of postal points with a population greater than 97% of the average population of all postal points in 2020.", "evidence": "population_2020 > MULTIPLY(0.97, AVG(population_2020));", "SQL": "SELECT DISTINCT c.`county`\nFROM `country` AS c\nJOIN `zip_data` AS z ON c.`zip_code` = z.`zip_code`\nWHERE z.`population_2020` > 0.97 * (SELECT AVG(`population_2020`) FROM `zip_data`);"} {"question_id": 5218, "db_id": "address", "grading_method": "set", "question": "Count the number of postal points in the district represented by Kirkpatrick Ann.", "evidence": "postal points refer to zip_code;", "SQL": "SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.first_name = 'Kirkpatrick' AND T1.last_name = 'Ann'"} {"question_id": 5219, "db_id": "address", "grading_method": "set", "question": "Provide the zip codes and coordinates of the postal points under Allentown-Bethlehem-Easton, PA-NJ.", "evidence": "coordinates refer to latitude and longitude; under Allentown-Bethlehem-Easton, PA-NJ refers to CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ';", "SQL": "SELECT T2.zip_code, T2.latitude, T2.longitude FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ'"} {"question_id": 5221, "db_id": "address", "grading_method": "set", "question": "Who are the congress representatives of the postal points in Garfield, NJ?", "evidence": "Who are the congress representatives refer to first_name, last_name; Garfield is the city; NJ is the state", "SQL": "SELECT T3.first_name, T3.last_name FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T1.city = 'Garfield' and T1.state = 'NJ'"} {"question_id": 5227, "db_id": "address", "grading_method": "set", "question": "Provide the congress representatives' IDs of the postal points in East Springfield, PA.", "evidence": "congress representatives' IDs refer to CID; East Springfield is the city; PA is the state", "SQL": "SELECT DISTINCT c.`CID`\nFROM `zip_data` AS z\nJOIN `zip_congress` AS zc ON z.`zip_code` = zc.`zip_code`\nJOIN `congress` AS c ON c.`cognress_rep_id` = zc.`district`\nWHERE z.`city` = 'East Springfield' AND z.state = 'PA';"} {"question_id": 5228, "db_id": "address", "grading_method": "set", "question": "Who is the CBSA officer of the post point in the zip area with the highest number of employees?", "evidence": "CBSA officer refers to CBSA_name; the highest number of employees refers to MAX(employees);", "SQL": "SELECT T1.CBSA_name FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.employees = ( SELECT MAX(employees) FROM zip_data )"} {"question_id": 5229, "db_id": "address", "grading_method": "set", "question": "How many postal points with unique post office types are there in Ohio?", "evidence": "postal points refer to zip_code; unique post office types refer to type = 'Unique Post Office'; Ohio is the name of the state, in which name = 'Ohio';", "SQL": "SELECT COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Ohio' AND T2.type = 'Unique Post Office'"} {"question_id": 5234, "db_id": "beer_factory", "grading_method": "set", "question": "Please list the names of all the root beer brands that are advertised on facebook.", "evidence": "name of the root beer brand refers to BrandName; advertised on facebook refers to FacebookPage IS not NULL;", "SQL": "SELECT BrandName FROM rootbeerbrand WHERE FacebookPage IS NOT NULL"} {"question_id": 5237, "db_id": "beer_factory", "grading_method": "set", "question": "In which city is the brewery AJ Stephans Beverages located?", "evidence": "AJ Stephans refers to BreweryName = 'AJ Stephans Beverages';", "SQL": "SELECT City FROM rootbeerbrand WHERE BreweryName = 'AJ Stephans Beverages'"} {"question_id": 5238, "db_id": "beer_factory", "grading_method": "set", "question": "How many transactions had Frank-Paul Santangelo made in July, 2014?", "evidence": "in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07';", "SQL": "SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND STRFTIME('%Y-%m', T2.TransactionDate) = '2014-07'"} {"question_id": 5245, "db_id": "beer_factory", "grading_method": "set", "question": "Please list the full names of the customers who have purchased at least one root beer produced by AJ Stephans Beverages.", "evidence": "full name = First, Last; customers who have purchased at least one root beer refers to CustomerID > = 1; produced by AJ Stephans Beverages refers to BreweryName = 'AJ Stephans Beverages';", "SQL": "SELECT DISTINCT T1.First, T1.Last 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 T4.BreweryName = 'AJ Stephans Beverages'"} {"question_id": 5249, "db_id": "beer_factory", "grading_method": "set", "question": "Please list the dates on which a male customer has purchased more than 3 root beers.", "evidence": "dates of purchase refers to TransactionDate; male customer refers to Gender = 'M'; purchased more than 3 root beers refers to COUNT(CustomerID) > 3;", "SQL": "SELECT DISTINCT sub.`TransactionDate`\nFROM (\n SELECT t.`TransactionDate`, t.`CustomerID`, COUNT(*) AS cnt\n FROM `transaction` AS t\n JOIN `customers` AS c ON c.`CustomerID` = t.`CustomerID`\n WHERE c.`Gender` = 'M'\n GROUP BY t.`CustomerID`, t.`TransactionDate`\n HAVING COUNT(*) > 3\n) AS sub;"} {"question_id": 5250, "db_id": "beer_factory", "grading_method": "set", "question": "What is the average number of root beers of the brand A&W sold in a day in August, 2015?", "evidence": "average = DIVIDE(SUM(COUNT(RootBeerID WHERE BrandName = 'A&W' AND SUBSTR(TransactionDate, 1, 4) = '2015' AND SUBSTR(TransactionDate, 6, 2) = '08')), 31); A&W refers to BrandName = 'A&W'; in August, 2015 refers to SUBSTR(TransactionDate, 1, 4) = '2015' AND SUBSTR(TransactionDate, 6, 2) = '08';", "SQL": "SELECT CAST(COUNT(T1.BrandID) AS REAL) / 31 FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2015-08%' AND T3.BrandName = 'A&W'"} {"question_id": 5252, "db_id": "beer_factory", "grading_method": "set", "question": "Tell the number of reviews given by James House.", "evidence": "", "SQL": "SELECT COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'James' AND T1.Last = 'House'"} {"question_id": 5255, "db_id": "beer_factory", "grading_method": "set", "question": "Provide the name of the location where transaction no.100885 happened.", "evidence": "name of the location refers to LocationName; transaction no. refers to TransactionID; TransactionID = 100885;", "SQL": "SELECT T2.LocationName FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.TransactionID = 100885"} {"question_id": 5259, "db_id": "beer_factory", "grading_method": "set", "question": "For the customer who leaves the review content of \"Tastes like Australia.\", when was his/her first purchase date?", "evidence": "review content of \"Tastes like Australia.\" refers to Review = 'Tastes like Australia.';", "SQL": "SELECT T1.FirstPurchaseDate FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Review = 'Tastes like Australia.'"} {"question_id": 5264, "db_id": "beer_factory", "grading_method": "set", "question": "What percentage of River City brand root beer reviews received a 5-star rating?", "evidence": "River City refers to rootbeerbrand.BrandName = 'River City'; percentage of that brand's root beer reviews with a 5-star rating = DIVIDE(COUNT(CASE WHEN rootbeerreview.StarRating = 5 THEN 1 ELSE NULL END), COUNT(rootbeerreview.StarRating)) * 100", "SQL": "SELECT CAST(COUNT(CASE WHEN T2.StarRating = 5 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.StarRating) FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'River City'"} {"question_id": 5266, "db_id": "beer_factory", "grading_method": "set", "question": "How many female customers permit the company to send regular emails to them?", "evidence": "female refers to Gender = 'F'; customer permits the company to send regular emails to them refers to SubscribedToEmailList = 'TRUE';", "SQL": "SELECT COUNT(CustomerID) FROM customers WHERE Gender = 'F' AND SubscribedToEmailList = 'TRUE'"} {"question_id": 5280, "db_id": "beer_factory", "grading_method": "set", "question": "Between Sac State Union and Sac State American River Courtyard, which location sold the most Dog n Suds root beer?", "evidence": "Between Sac State Union and Sac State American River Courtyard refers to LocationName IN('Sac State American River Courtyard', 'Sac State Union'); Dog n Suds refers to BrandName = 'Dog n Suds'; sold the most root beer refers to MAX(COUNT(BrandID));", "SQL": "SELECT l.`LocationName`\nFROM `transaction` tr\nJOIN `rootbeer` rb ON tr.`RootBeerID` = rb.`RootBeerID`\nJOIN `rootbeerbrand` br ON rb.`BrandID` = br.`BrandID`\nJOIN `location` l ON tr.`LocationID` = l.`LocationID`\nWHERE br.`BrandName` = 'Dog n Suds'\n AND l.`LocationName` IN ('Sac State American River Courtyard', 'Sac State Union')\nGROUP BY l.`LocationID`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 5281, "db_id": "beer_factory", "grading_method": "set", "question": "How many canned A&W were purchased in 2016?", "evidence": "canned refers to ContainerType = 'Can'; A&W refers to BrandName = 'A&W'; in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31';", "SQL": "SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.ContainerType = 'Can' AND T2.BrandName = 'A&W' AND T1.PurchaseDate LIKE '2016%'"} {"question_id": 5282, "db_id": "beer_factory", "grading_method": "set", "question": "What is the precise location of Sac State Union?", "evidence": "precise location = Latitude, Longitude; Sac State Union refers to LocationName = 'Sac State Union';", "SQL": "SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State Union'"} {"question_id": 5284, "db_id": "beer_factory", "grading_method": "set", "question": "For Dr Pepper Snapple Group brands purchased from 2014 through 2016, list each brand and its percentage of those purchase records. Round the percentages to two decimal places.", "evidence": "Dr Pepper Snapple Group brands refers to rootbeerbrand.BreweryName = 'Dr Pepper Snapple Group'; 2014 through 2016 refers to rootbeer.PurchaseDate falling in the years 2014, 2015 and 2016; each brand's percentage = ROUND(DIVIDE(COUNT(its purchase rows), COUNT(all such rows)) * 100, 2); return BrandName with that percentage", "SQL": "SELECT BrandName, ROUND(pct, 2) FROM (SELECT T1.BrandName, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BreweryName = 'Dr Pepper Snapple Group' AND T2.PurchaseDate >= '2014-01-01' AND T2.PurchaseDate <= '2016-12-31') AS pct FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BreweryName = 'Dr Pepper Snapple Group' AND T2.PurchaseDate >= '2014-01-01' AND T2.PurchaseDate <= '2016-12-31' GROUP BY T2.BrandID)"} {"question_id": 5292, "db_id": "beer_factory", "grading_method": "set", "question": "What percentage of sales transactions took place at Sac State American River Courtyard? Round your answer to 3 decimal places.", "evidence": "Sac State American River Courtyard refers to location.LocationName = 'Sac State American River Courtyard'; percentage = DIVIDE(COUNT(transactions at that location), COUNT(all transaction.TransactionID joined to a location)) * 100, rounded to 3 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT CAST(COUNT(CASE WHEN T2.LocationName = 'Sac State American River Courtyard' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 5295, "db_id": "beer_factory", "grading_method": "set", "question": "What is the average cost of root beers purchased for more than 2 dollars and sold in bottles?", "evidence": "average cost = DIVIDE(SUM(PurchasePrice), COUNT(RootBeerID) WHERE PurchasePrice > 2); more than 2 dollars refers to PurchasePrice > 2; in bottles refers to ContainerType = 'Bottle';", "SQL": "SELECT AVG(T2.PurchasePrice) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T1.ContainerType = 'Bottle' AND T2.PurchasePrice > 2"} {"question_id": 5302, "db_id": "beer_factory", "grading_method": "set", "question": "Among the male customers in Sacramento, what percentage bought Dominion root beer in 2014?", "evidence": "customers.Gender = 'M' denotes male; customers.City records 'Sacramento'. rootbeerbrand.BrandName records 'Dominion'; transaction.TransactionDate records purchase date.", "SQL": "SELECT CAST(COUNT(DISTINCT CASE WHEN T4.BrandName = 'Dominion' AND T2.TransactionDate LIKE '2014%' THEN T1.CustomerID ELSE NULL END) AS REAL) * 100 / COUNT(DISTINCT 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.City = 'Sacramento' AND T1.Gender = 'M'"} {"question_id": 5304, "db_id": "beer_factory", "grading_method": "set", "question": "List the first names, last names, and email addresses of customers who used American Express at Sac State Union.", "evidence": "customers.First and customers.Last record first and last names; customers.Email records email. transaction.CreditCardType uses 'American Express'; location.LocationName uses 'Sac State Union'.", "SQL": "SELECT DISTINCT T1.First, T1.Last, T1.Email FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN location AS T3 ON T2.LocationID = T3.LocationID WHERE T3.LocationName = 'Sac State Union' AND T2.CreditCardType = 'American Express'"} {"question_id": 5308, "db_id": "beer_factory", "grading_method": "set", "question": "From which cities are the customers who gave 5 stars in their reviews in November 2012?", "evidence": "5 stars refers to StarRating = 5; in November 2012 refers to ReviewDate LIKE '2012-11%';", "SQL": "SELECT DISTINCT T1.City FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2012-11-01' AND '2012-11-30'"} {"question_id": 5309, "db_id": "beer_factory", "grading_method": "set", "question": "What beer brands did Peg Winchester review?", "evidence": "Brand names are recorded in rootbeerbrand.BrandName; Peg Winchester is recorded in customers.First and customers.Last.", "SQL": "SELECT T3.BrandName 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 = 'Peg' AND T1.Last = 'Winchester'"} {"question_id": 5310, "db_id": "beer_factory", "grading_method": "set", "question": "Which root beer brand received 1-star ratings most often?", "evidence": "1-star ratings refers to rootbeerreview.StarRating = 1; return the single rootbeerbrand.BrandName with the greatest COUNT of such reviews, grouped by BrandName", "SQL": "SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = 1 GROUP BY T1.BrandName ORDER BY COUNT(T1.BrandName) DESC LIMIT 1"} {"question_id": 5311, "db_id": "beer_factory", "grading_method": "set", "question": "Which credit card type was used most often to purchase non-alcoholic beer?", "evidence": "non-alcoholic beer refers to rootbeerbrand.Alcoholic = 'FALSE'; credit card type refers to transaction.CreditCardType; used most often refers to the CreditCardType with the greatest COUNT of transaction rows for those non-alcoholic brands, returning that one type", "SQL": "SELECT T2.CreditCardType FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T3.Alcoholic = 'FALSE' GROUP BY T2.CreditCardType ORDER BY COUNT(T2.CreditCardType) DESC LIMIT 1"} {"question_id": 5314, "db_id": "beer_factory", "grading_method": "set", "question": "What star rating is the most common for beers containing corn syrup?", "evidence": "most common refers to MAX(COUNT(StarRating)); containing corn syrup refers to CornSyrup = 'TRUE';", "SQL": "SELECT T2.StarRating FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.CornSyrup = 'TRUE' GROUP BY T2.StarRating ORDER BY COUNT(T2.StarRating) DESC LIMIT 1"} {"question_id": 5316, "db_id": "beer_factory", "grading_method": "set", "question": "What brands of beers are manufactured at coordinates 38,566,129, -121,426,432?", "evidence": "coordinates 38,566,129, -121,426,432 refers to Latitude = 38.566129 AND Longitude = -121.426432;", "SQL": "SELECT DISTINCT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN geolocation AS T3 ON T1.LocationID = T3.LocationID WHERE T3.Latitude = '38.566129' AND T3.Longitude = '-121.426432'"} {"question_id": 5323, "db_id": "beer_factory", "grading_method": "set", "question": "How many female mailing-list subscribers from Sacramento gave a 4-star rating between January 3 and October 26, 2013, inclusive?", "evidence": "Gender F denotes female, and SubscribedToEmailList TRUE denotes an email-list subscriber. ReviewDate is the review date. Rating refers to StarRating.", "SQL": "SELECT COUNT(DISTINCT T1.CustomerID) \nFROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID \nWHERE T2.StarRating = 4 AND T1.City = 'Sacramento' AND T1.Gender = 'F' AND T1.SubscribedToEmailList = 'TRUE' AND T2.ReviewDate BETWEEN '2013-01-03' AND '2013-10-26'"} {"question_id": 5326, "db_id": "beer_factory", "grading_method": "set", "question": "How many times did Anna Himes use her Mastercard when paying between 12/25/2014 and 5/20/2016 ?", "evidence": "Mastercard refers to CreditCardType = 'MasterCard'; between 12/25/2014 and 5/20/2016 refers to TransactionDate BETWEEN '2014-12-25' AND '2016-05-20';", "SQL": "SELECT COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Anna' AND T1.Last = 'Himes' AND T2.CreditCardType = 'MasterCard' AND T2.TransactionDate BETWEEN '2014-12-25' AND '2016-05-20'"} {"question_id": 5327, "db_id": "beer_factory", "grading_method": "set", "question": "What is the average star rating female customers gave brand 10018 between January 25, 2013, and March 10, 2015, inclusive?", "evidence": "BrandID identifies the brand; 10018 is the requested brand. Gender = 'F' denotes female. StarRating is the review score, and ReviewDate is the date of the review.", "SQL": "SELECT AVG(T2.StarRating) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.BrandID = 10018 AND T1.Gender = 'F' AND T2.ReviewDate BETWEEN '2013-01-25' AND '2015-03-10'"} {"question_id": 5328, "db_id": "beer_factory", "grading_method": "set", "question": "What is the brand name of the root beer that gained a 1-star rating from customer ID 331115 while saying, \"Yuk, more like licorice soda\"?", "evidence": "1-star rating refers to StarRating = 1; saying, \"Yuk, more like licorice soda\" refers to Review = 'Yuk, more like licorice soda.';", "SQL": "SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.CustomerID = 331115 AND T2.Review = 'Yuk, more like licorice soda.' AND T2.StarRating = 1"} {"question_id": 5329, "db_id": "beer_factory", "grading_method": "set", "question": "Calculate the total purchases made by customers using their Visa credit cards in the Sac State American River Courtyard between 6/3/2014 and 11/27/2015.", "evidence": "total purchases = SUM(PurchasePrice); Visa credit card refers to CreditCardType = 'Visa'; Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard'; between 6/3/2014 and 11/27/2015 refers to TransactionDate BETWEEN '2014-06-03' AND '2015-11-27';", "SQL": "SELECT SUM(T1.PurchasePrice) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T2.LocationName = 'Sac State American River Courtyard' AND T1.CreditCardType = 'Visa' AND T1.TransactionDate BETWEEN '2014-06-03' AND '2015-11-27'"} {"question_id": 5331, "db_id": "beer_factory", "grading_method": "set", "question": "What is the precise coordinate of Sac State Union?", "evidence": "precise coordinate = Latitude, Longitude; Sac State Union refers to LocationName = 'Sac State Union';", "SQL": "SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State Union'"} {"question_id": 5332, "db_id": "beer_factory", "grading_method": "set", "question": "What did the customer say in his or her review of Bulldog root beer on 7/26/2013?", "evidence": "Bulldog refers to BrandName = 'Bulldog'; on 7/26/2013 refers to ReviewDate = '2013-07-26';", "SQL": "SELECT T2.Review FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'Bulldog' AND T2.ReviewDate = '2013-07-26'"} {"question_id": 5334, "db_id": "beer_factory", "grading_method": "set", "question": "Give me the full name of the first customer, and tell me how long ago he or she wrote his or her first review since making his or her first purchase.", "evidence": "full name = First, Last; how long ago = SUBTRACT(ReviewDate, FirstPurchaseDate); first customer refers to MIN(FirstPurchaseDate)", "SQL": "WITH first_customer AS (\n SELECT `CustomerID`, `First`, `Last`, `FirstPurchaseDate`\n FROM `customers`\n ORDER BY `FirstPurchaseDate`\n LIMIT 1\n),\nfirst_review AS (\n SELECT `CustomerID`, MIN(`ReviewDate`) AS FirstReviewDate\n FROM `rootbeerreview`\n WHERE `CustomerID` = (SELECT `CustomerID` FROM first_customer)\n)\nSELECT first_customer.`First`,\n first_customer.`Last`,\n julianday(first_review.FirstReviewDate) - julianday(first_customer.FirstPurchaseDate) AS days_since_purchase_to_first_review\nFROM first_customer\nJOIN first_review USING(`CustomerID`);"} {"question_id": 5335, "db_id": "beer_factory", "grading_method": "set", "question": "What is the credit card type used by Kenneth Walton?", "evidence": "", "SQL": "SELECT DISTINCT T2.CreditCardType FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Kenneth' AND T1.Last = 'Walton'"} {"question_id": 5336, "db_id": "beer_factory", "grading_method": "set", "question": "What is the container type and brand name for root beer ID 100054?", "evidence": "", "SQL": "SELECT r.ContainerType,\n b.BrandName\nFROM rootbeer AS r\nJOIN rootbeerbrand AS b ON r.BrandID = b.BrandID\nWHERE r.RootBeerID = 100054;"} {"question_id": 5337, "db_id": "beer_factory", "grading_method": "set", "question": "List out the ids of the root beers bought by Tim Ocel and Dawn Childress.", "evidence": "", "SQL": "SELECT T2.RootBeerID FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T2.CustomerID = T1.CustomerID WHERE (T1.First = 'Tim' AND T1.Last = 'Ocel') OR (T1.First = 'Dawn' AND T1.Last = 'Childress')"} {"question_id": 5340, "db_id": "beer_factory", "grading_method": "set", "question": "How many transactions purchased a root beer from a brand in California?", "evidence": "California refers to State = 'CA';", "SQL": "SELECT COUNT(T3.RootBeerID) FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID INNER JOIN `transaction` AS T3 ON T2.RootBeerID = T3.RootBeerID WHERE T1.State = 'CA'"} {"question_id": 5342, "db_id": "beer_factory", "grading_method": "set", "question": "How many more bottled root beer listings are there for Louisiana brands than for Missouri brands?", "evidence": "bottled refers to rootbeer.ContainerType = 'Bottle'; Louisiana brands refers to rootbeerbrand.State = 'LA' and Missouri brands to rootbeerbrand.State = 'MO'; how many more refers to SUBTRACT(COUNT(bottled rootbeer listings of LA brands), COUNT(bottled rootbeer listings of MO brands))", "SQL": "SELECT ( SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.State = 'LA' AND T1.ContainerType = 'Bottle' ) - ( SELECT COUNT(T3.BrandID) FROM rootbeer AS T3 INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T4.State = 'MO' AND T3.ContainerType = 'Bottle' ) AS DIFFERENCE"} {"question_id": 5347, "db_id": "beer_factory", "grading_method": "set", "question": "What is the best seller root beer brand and what is the average star rating for this root beer?", "evidence": "best seller root beer refers to MAX(COUNT(BrandID)); average star rating = AVG(StarRating);", "SQL": "WITH best_seller AS (\n SELECT rb.`BrandID`\n FROM `transaction` t\n JOIN `rootbeer` rb ON rb.`RootBeerID` = t.`RootBeerID`\n GROUP BY rb.`BrandID`\n ORDER BY COUNT(*) DESC \n LIMIT 1\n)\nSELECT b.`BrandName`,\n AVG(rv.`StarRating`) AS AvgStarRating\nFROM best_seller bs\nJOIN `rootbeerbrand` b ON b.`BrandID` = bs.`BrandID`\nLEFT JOIN `rootbeerreview` rv ON rv.`BrandID` = bs.`BrandID`\nGROUP BY b.`BrandName`;"} {"question_id": 5350, "db_id": "beer_factory", "grading_method": "set", "question": "Among customers who subscribed to the email list, what percentage are female?", "evidence": "percentage = MULTIPLY(DIVIDE(COUNT(CustomerID WHERE Gender = 'F'), COUNT(CustomerID) WHERE SubscribedToEmailList = 'TRUE'), 100); female refers to Gender = 'F'; subscribed to the email list refers to SubscribedToEmailList = 'TRUE';", "SQL": "SELECT CAST(COUNT(CASE WHEN Gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(SubscribedToEmailList) FROM customers WHERE SubscribedToEmailList = 'TRUE'"} {"question_id": 5354, "db_id": "beer_factory", "grading_method": "set", "question": "Which brand has the lowest star rating with a \"Too spicy!\" review?", "evidence": "lowest star rating refers to MIN(StarRating); \"Too spicy!\" review refers to Review = 'Too Spicy!';", "SQL": "SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = (SELECT MIN(StarRating) FROM rootbeerbrand AS T3 INNER JOIN rootbeerreview AS T4 ON T3.BrandID = T4.BrandID WHERE T4.Review = 'Too Spicy!') AND T2.Review = 'Too Spicy!'"} {"question_id": 5357, "db_id": "beer_factory", "grading_method": "set", "question": "What is the precise location of the place where Tommy Kono made a purchase in 2014?", "evidence": "precise location = Latitude, Longitude; in 2014 refers to TransactionDate LIKE '2014%';", "SQL": "SELECT DISTINCT T1.Latitude, T1.Longitude FROM geolocation AS T1 INNER JOIN `transaction` AS T2 ON T2.LocationID = T1.LocationID INNER JOIN customers AS T3 ON T3.CustomerID = T2.CustomerID WHERE T3.First = 'Tommy' AND T3.Last = 'Kono' AND T2.TransactionDate LIKE '2014%'"} {"question_id": 5358, "db_id": "beer_factory", "grading_method": "set", "question": "What is the email address of the customer who made a purchase in transaction 100016?", "evidence": "email address refers to Email; transaction 100016 refers to TransactionID = 100016;", "SQL": "SELECT T1.Email FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.TransactionID = '100016'"} {"question_id": 5361, "db_id": "beer_factory", "grading_method": "set", "question": "Please name the root beer brand that has the highest market evaluation and acceptance.", "evidence": "root beer brands refers to BrandName; highest market evaluation and acceptance refers to MAX(COUNT(StarRating = 5));", "SQL": "SELECT `b`.`BrandName`\nFROM `rootbeerbrand` AS `b`\nJOIN `rootbeerreview` AS `r` ON `b`.`BrandID` = `r`.`BrandID`\nWHERE `r`.`StarRating` = 5\nGROUP BY `b`.`BrandID`, `b`.`BrandName`\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 ) t\n)"} {"question_id": 5369, "db_id": "sales", "grading_method": "set", "question": "List down the product name for products from id 1 to 10.", "evidence": "products from id 1 to 10 refers to ProductID BETWEEN 1 AND 10;", "SQL": "SELECT Name FROM Products WHERE ProductID BETWEEN 1 AND 10"} {"question_id": 5376, "db_id": "sales", "grading_method": "set", "question": "List down product ids that were purchased by customers called Abby.", "evidence": "", "SQL": "SELECT DISTINCT T1.ProductID FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Abby'"} {"question_id": 5390, "db_id": "sales", "grading_method": "set", "question": "Calculate the total quantity of products purchased by customer called Adam.", "evidence": "", "SQL": "SELECT SUM(T2.Quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Adam'"} {"question_id": 5392, "db_id": "sales", "grading_method": "set", "question": "Among the products, how many of them are freebies?", "evidence": "freebies refers to Price = 0;", "SQL": "SELECT COUNT(ProductID) FROM Products WHERE Price = 0"} {"question_id": 5393, "db_id": "sales", "grading_method": "set", "question": "Write down the name of products whose sale quantity is more than 950.", "evidence": "quantity is more than 950 refers to SUM(Quantity) > 950;", "SQL": "SELECT p.`Name`\nFROM `Products` AS p\nJOIN `Sales` AS s ON p.`ProductID` = s.`ProductID`\nGROUP BY p.`ProductID`\nHAVING SUM(s.`Quantity`) > 950;"} {"question_id": 5398, "db_id": "sales", "grading_method": "set", "question": "How much higher is the price of 'HL Mountain Frame - Black, 42' than the price of 'LL Mountain Frame - Black, 42'?", "evidence": "how much higher refers to SUBTRACT(the unit Products.Price of 'HL Mountain Frame - Black, 42', the unit Products.Price of 'LL Mountain Frame - Black, 42')", "SQL": "SELECT ( SELECT Price FROM Products WHERE Name = 'HL Mountain Frame - Black, 42' ) - ( SELECT Price FROM Products WHERE Name = 'LL Mountain Frame - Black, 42' ) AS num"} {"question_id": 5401, "db_id": "sales", "grading_method": "set", "question": "How many customers served by Innes E. del Castillo purchased Short-Sleeve Classic Jersey, L?", "evidence": "'Short-Sleeve Classic Jersey, L' is name of product;", "SQL": "SELECT COUNT(DISTINCT `Sales`.`CustomerID`)\nFROM `Sales`\nJOIN `Employees` ON `Sales`.`SalesPersonID` = `Employees`.`EmployeeID`\nJOIN `Products` ON `Sales`.`ProductID` = `Products`.`ProductID`\nWHERE `Employees`.`FirstName` = 'Innes'\n AND `Employees`.`MiddleInitial` = 'e'\n AND `Employees`.`LastName` = 'del Castillo'\n AND `Products`.`Name` = 'Short-Sleeve Classic Jersey, L';"} {"question_id": 5403, "db_id": "sales", "grading_method": "set", "question": "How many sales people managed to sell Headlights - Weatherproof?", "evidence": "'Headlights - Weatherproof' is name of product", "SQL": "SELECT COUNT(DISTINCT S.`SalesPersonID`)\nFROM `Products` P\nJOIN `Sales` S ON P.`ProductID` = S.`ProductID`\nWHERE P.`Name` = 'Headlights - Weatherproof';"} {"question_id": 5413, "db_id": "sales", "grading_method": "set", "question": "Indicate the quantity of Blade products sold.", "evidence": "'Blade' is name of product;", "SQL": "SELECT SUM(`Sales`.`Quantity`) AS TotalQuantity\nFROM `Sales`\nJOIN `Products` ON `Products`.`ProductID` = `Sales`.`ProductID`\nWHERE `Products`.`Name` = 'Blade';"} {"question_id": 5418, "db_id": "sales", "grading_method": "set", "question": "List the first names of customers who purchased products from salesperson ID 1.", "evidence": "", "SQL": "SELECT DISTINCT c.`FirstName`\nFROM `Customers` AS c\nJOIN `Sales` AS s ON c.`CustomerID` = s.`CustomerID`\nWHERE s.`SalesPersonID` = 1;"} {"question_id": 5427, "db_id": "sales", "grading_method": "set", "question": "How many of the employees have the last name \"Ringer\" ?", "evidence": "", "SQL": "SELECT COUNT(LastName) FROM Employees WHERE LastName = 'Ringer'"} {"question_id": 5438, "db_id": "sales", "grading_method": "set", "question": "What is the price and name of the product bought by Erica Lu?", "evidence": "", "SQL": "SELECT DISTINCT T3.Price, T3.Name FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID WHERE T2.FirstName = 'Erica' AND T2.LastName = 'Lu'"} {"question_id": 5440, "db_id": "sales", "grading_method": "set", "question": "In sales ID between 30 and 40, who is the customer that bought a total quantity of 403?", "evidence": "who refers to FirstName, LastName;", "SQL": "SELECT c.FirstName,\n c.LastName\nFROM Sales AS s\nJOIN Customers AS c ON c.CustomerID = s.CustomerID\nWHERE s.SalesID BETWEEN 30 AND 40\nGROUP BY c.CustomerID, c.FirstName, c.LastName\nHAVING SUM(s.Quantity) = 403;"} {"question_id": 5443, "db_id": "sales", "grading_method": "set", "question": "Which products are tied for the highest price? Give their names.", "evidence": "the highest price refers to Products.Price = MAX(Price) over all products, so every product tied at that price qualifies; return their Name values", "SQL": "SELECT Name FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products )"} {"question_id": 5450, "db_id": "sales", "grading_method": "set", "question": "How many units of 'Mountain-500 Black, 42' were sold in total?", "evidence": "units sold refers to Sales.Quantity; how many units of 'Mountain-500 Black, 42' were sold in total refers to SUM(Sales.Quantity) over the sales of 'Mountain-500 Black, 42'", "SQL": "SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain-500 Black, 42'"} {"question_id": 5455, "db_id": "sales", "grading_method": "set", "question": "Which Mountain-500 Black variant was purchased the most?", "evidence": "Mountain-500 Black variants refers to Products.Name LIKE 'Mountain-500 Black%'; purchased the most refers to the Name with the greatest SUM(Sales.Quantity), taking the single top one; return that Products.Name", "SQL": "SELECT T1.Name\nFROM `Products` AS T1\nJOIN `Sales` AS T2 ON T1.ProductID = T2.ProductID\nWHERE T1.Name LIKE 'Mountain-500 Black%'\nGROUP BY T1.Name\nORDER BY SUM(T2.Quantity) DESC\nLIMIT 1;"} {"question_id": 5458, "db_id": "sales", "grading_method": "set", "question": "How many employees sold more than 20,000 units of \"Touring-2000 Blue, 50\"?", "evidence": "Products.Name uses 'Touring-2000 Blue, 50'; Sales.Quantity records units sold and Sales.SalesPersonID identifies the employee making the sale.", "SQL": "SELECT COUNT(*)\nFROM (\n SELECT `SalesPersonID`\n FROM `Sales` s\n JOIN `Products` p ON s.`ProductID` = p.`ProductID`\n WHERE p.`Name` = 'Touring-2000 Blue, 50'\n GROUP BY `SalesPersonID`\n HAVING SUM(s.`Quantity`) > 20000\n) AS t;"} {"question_id": 5466, "db_id": "sales", "grading_method": "set", "question": "Among employees who sold Blade, who had the highest sales amount? Report the full name.", "evidence": "Blade refers to Products.Name = 'Blade'; sales amount refers to MULTIPLY(Sales.Quantity, Products.Price); the highest sales amount refers to the greatest SUM of that amount among the employees who sold Blade; report the full name", "SQL": "SELECT e.FirstName, e.MiddleInitial, e.LastName FROM Employees AS e JOIN Sales AS s ON e.EmployeeID = s.SalesPersonID JOIN Products AS p ON s.ProductID = p.ProductID WHERE p.Name = 'Blade' GROUP BY e.EmployeeID ORDER BY SUM(s.Quantity * p.Price) DESC LIMIT 1"} {"question_id": 5469, "db_id": "sales", "grading_method": "set", "question": "Which products sold fewer units in total than the average per product, including products with no sales? List their names.", "evidence": "a product's total units sold refers to SUM(Sales.Quantity) for its ProductID, taken as 0 when the product has no sales; the average per product refers to AVG of those per-product totals over every product in Products; return Products.Name for each product whose total is below that average", "SQL": "WITH prod_tot AS (\n SELECT p.`ProductID`, COALESCE(SUM(s.`Quantity`),0) AS total_qty\n FROM `Products` p\n LEFT JOIN `Sales` s ON s.`ProductID` = p.`ProductID`\n GROUP BY p.`ProductID`\n)\nSELECT p.`Name`\nFROM prod_tot pt\nJOIN `Products` p ON p.`ProductID` = pt.`ProductID`\nWHERE pt.total_qty < (SELECT AVG(total_qty) FROM prod_tot);"} {"question_id": 5470, "db_id": "menu", "grading_method": "set", "question": "How many dishes do not have correct data for the year in which it appeared first?", "evidence": "do not have correct data refers to first_appeared < 1851 or first_appeared > 2012;", "SQL": "SELECT COUNT(*) FROM Dish WHERE first_appeared < 1851 OR first_appeared > 2012"} {"question_id": 5473, "db_id": "menu", "grading_method": "set", "question": "How many menus with the name \"Waldorf Astoria\" have 4 pages?", "evidence": "4 pages refers to page_count = 4;", "SQL": "SELECT COUNT(*) FROM Menu WHERE name = 'Waldorf Astoria' AND page_count = 4"} {"question_id": 5479, "db_id": "menu", "grading_method": "set", "question": "Among the menus in which the dish \"Clear green turtle\" had appeared, how many of them used the dollar as their currency?", "evidence": "Clear green turtle is a name of dish; dollar as currency refers to currency = 'Dollars';", "SQL": "SELECT SUM(CASE WHEN T3.currency = 'Dollars' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Clear green turtle'"} {"question_id": 5481, "db_id": "menu", "grading_method": "set", "question": "Please list the names of all the dishes that appeared on the menu \"Zentral Theater Terrace\".", "evidence": "Zentral Theater Terrace is a name of menu;", "SQL": "SELECT DISTINCT T4.name FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.name = 'Zentral Theater Terrace'"} {"question_id": 5485, "db_id": "menu", "grading_method": "set", "question": "Please list the IDs of menus without a sponsor that include the dish ‘Clear green turtle’.", "evidence": "Menu.sponsor records a menu’s sponsor; a missing sponsor is represented by NULL. Dish.name records dish names, including 'Clear green turtle'.", "SQL": "SELECT T2.menu_id FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Clear green turtle' AND T3.sponsor IS NULL"} {"question_id": 5507, "db_id": "menu", "grading_method": "set", "question": "Please describe the menu sponsored by Noviomagus physically.", "evidence": "describe the menu physically refers to physical_description; sponsored by Noviomagus refers to sponsor LIKE 'Noviomagus';", "SQL": "SELECT physical_description FROM Menu WHERE sponsor LIKE 'Noviomagus'"} {"question_id": 5508, "db_id": "menu", "grading_method": "set", "question": "What is the occasion for menu with ID 12463?", "evidence": "", "SQL": "SELECT occasion FROM Menu WHERE id = 12463"} {"question_id": 5509, "db_id": "menu", "grading_method": "set", "question": "List the distinct locations of all menus sponsored by Norddeutscher Lloyd Bremen.", "evidence": "Menu.location records a menu’s location; its sponsor is recorded in Menu.sponsor as 'Norddeutscher Lloyd Bremen'.", "SQL": "SELECT DISTINCT location FROM Menu WHERE sponsor = 'Norddeutscher Lloyd Bremen'"} {"question_id": 5514, "db_id": "menu", "grading_method": "set", "question": "State the id of menu with the longest full height.", "evidence": "longest full height refers to MAX(full_height);", "SQL": "SELECT menu_id FROM MenuPage ORDER BY full_height DESC LIMIT 1"} {"question_id": 5517, "db_id": "menu", "grading_method": "set", "question": "List down the distinct page numbers for menu with dishes on the right upper corner.", "evidence": "on the right upper corner refers to xpos > 0.75 AND ypos < 0.25;", "SQL": "SELECT DISTINCT T2.page_number FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id INNER JOIN MenuItem AS T3 ON T2.id = T3.menu_page_id WHERE T3.xpos > 0.75 AND T3.ypos < 0.25"} {"question_id": 5518, "db_id": "menu", "grading_method": "set", "question": "Which dishes have menu entries created in April? List their names.", "evidence": "MenuItem.created_at records when a menu entry was created; Dish.name records the dish name.", "SQL": "SELECT DISTINCT T2.name FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE SUBSTR(T1.created_at, 7, 1) = '4'"} {"question_id": 5520, "db_id": "menu", "grading_method": "set", "question": "What is the highest price of the regular prices of dishes with menu item ID 1 to 5?", "evidence": "highest price refers to MAX(price); menu item ID 1 to 5 refers to MenuItem.id BETWEEN 1 AND 5;", "SQL": "SELECT T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T2.id BETWEEN 1 AND 5 ORDER BY T2.price DESC LIMIT 1"} {"question_id": 5523, "db_id": "menu", "grading_method": "set", "question": "Calculate the total price of items for menu with ID 12882.", "evidence": "total price = SUM(price);", "SQL": "SELECT SUM(T2.price) FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id WHERE T1.menu_id = 12882"} {"question_id": 5524, "db_id": "menu", "grading_method": "set", "question": "List the top five dishes in descending order of price.", "evidence": "Dish.highest_price records a dish’s highest recorded price.", "SQL": "SELECT name FROM Dish ORDER BY highest_price DESC LIMIT 5"} {"question_id": 5525, "db_id": "menu", "grading_method": "set", "question": "Among the dishes, how many of them are for free?", "evidence": "free refers to lowest_price = 0;", "SQL": "SELECT COUNT(*) FROM Dish WHERE lowest_price = 0"} {"question_id": 5527, "db_id": "menu", "grading_method": "set", "question": "Write down the ids of the top ten menus with the highest dish count.", "evidence": "highest dish count refers to MAX(dish_count);", "SQL": "SELECT id FROM Menu ORDER BY dish_count DESC LIMIT 10"} {"question_id": 5530, "db_id": "menu", "grading_method": "set", "question": "Tally the dishes that have appeared on the menu for more than 100 years.", "evidence": "appeared on the menu for more than 100 years refers to SUBTRACT(Dish.last_appeared, Dish.first_appeared) > 100, with no endpoint adjustment; only dishes whose first_appeared and last_appeared both lie BETWEEN 1851 AND 2012 count; tally refers to COUNT(*) of those dishes", "SQL": "SELECT COUNT(*) AS num_dishes_over_100_years\nFROM `Dish`\nWHERE `first_appeared` BETWEEN 1851 AND 2012\n AND `last_appeared` BETWEEN 1851 AND 2012\n AND (`last_appeared` - `first_appeared`) > 100;"} {"question_id": 5531, "db_id": "menu", "grading_method": "set", "question": "How many dishes have valid first and last appearance years spanning fewer than five calendar years, counting both endpoint years?", "evidence": "spanning fewer than five calendar years counting both endpoints refers to SUBTRACT(Dish.last_appeared, Dish.first_appeared) + 1 < 5; valid years refers to first_appeared and last_appeared both BETWEEN 1851 AND 2012; the answer is COUNT(*) of the dishes meeting both", "SQL": "SELECT COUNT(*) FROM `Dish` WHERE `last_appeared` - `first_appeared` + 1 < 5 AND last_appeared >= 1851 AND last_appeared <= 2012 AND first_appeared >= 1851 AND first_appeared <= 2012;"} {"question_id": 5550, "db_id": "menu", "grading_method": "set", "question": "Among the menus sponsored by Pacific Mail Steamship Company, how many menus have no more than 2 pages?", "evidence": "sponsored by Pacific Mail Steamship Company refers to sponsor = 'PACIFIC MAIL STEAMSHIP COMPANY'; no more than 2 pages refers to page_count < = 2;", "SQL": "SELECT COUNT(*)\nFROM Menu\nWHERE sponsor = 'PACIFIC MAIL STEAMSHIP COMPANY' AND page_count <= 2;"} {"question_id": 5552, "db_id": "menu", "grading_method": "set", "question": "What is the menu id of the menu sponsored by Occidental and Oriental Steamship Company with the highest number of pages?", "evidence": "sponsored by Occidental and Oriental Steamship Company refers to sponsor = 'OCCIDENTAL & ORIENTAL STEAMSHIP COMPANY'; highest number of pages refers to MAX(page_count);", "SQL": "SELECT `id`\nFROM `Menu`\nWHERE `sponsor` = 'OCCIDENTAL & ORIENTAL STEAMSHIP COMPANY'\n AND `page_count` = (\n SELECT MAX(`page_count`)\n FROM `Menu`\n WHERE `sponsor` = 'OCCIDENTAL & ORIENTAL STEAMSHIP COMPANY'\n );"} {"question_id": 5556, "db_id": "menu", "grading_method": "set", "question": "Which menus have the highest total listed price for “Baked apples with cream”? Give their sponsors.", "evidence": "“Baked apples with cream” refers to Dish.name = 'Baked apples with cream'; a menu's total listed price for it refers to SUM(MenuItem.price) over that menu's listings of that dish, grouped by Menu.id; return Menu.sponsor for every menu whose total equals the MAX of those totals", "SQL": "SELECT T4.sponsor FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id INNER JOIN Dish AS T3 ON T2.dish_id = T3.id INNER JOIN Menu AS T4 ON T4.id = T1.menu_id WHERE T3.name = 'Baked apples with cream' GROUP BY T4.id HAVING SUM(T2.Price) = (SELECT MAX(TotalPrice) FROM (SELECT T5.id, SUM(T6.Price) AS TotalPrice FROM Menu AS T5 INNER JOIN MenuPage AS T7 ON T5.id = T7.menu_id INNER JOIN MenuItem AS T6 ON T7.id = T6.menu_page_id INNER JOIN Dish AS T8 ON T6.dish_id = T8.id WHERE T8.name = 'Baked apples with cream' GROUP BY T5.id) AS MenuPrices);"} {"question_id": 5566, "db_id": "menu", "grading_method": "set", "question": "Which menu page has a bigger width, page 1 of \"Zentral Theater Terrace\" or page 1 of \"Young's Hotel\"?", "evidence": "if (full_width where page_number = 1 AND menu.name = 'Zentral Theater Terrace') >(full_width where page_number = 1 AND menu.name = 'Young''s Hotel'), it means Zentral Theater Terrace menu page is bigger than Young's Hotel; if(full_width WHERE page_number = 1 AND menu.name = 'Young''s Hotel') <(full_width WHERE page_number = 1 AND menu.name = 'Zentral Theater Terrace'), it means Young's Hotel menu page is bigger than Zentral Theater Terrace;", "SQL": "SELECT CASE WHEN SUM(CASE WHEN T1.name = 'Zentral Theater Terrace' THEN T2.full_width ELSE 0 END) - SUM(CASE WHEN T1.name = 'Young''s Hotel' THEN T2.full_width ELSE 0 END) > 0 THEN 'Zentral Theater Terrace' ELSE 'Young''s Hotel' END FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id WHERE T2.page_number = 1"} {"question_id": 5569, "db_id": "menu", "grading_method": "set", "question": "How many dishes are there on page 1 of menu ID12882?", "evidence": "page 1 refers to page_number = 1;", "SQL": "SELECT SUM(CASE WHEN T1.page_number = 1 THEN 1 ELSE 0 END) FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id WHERE T1.menu_id = 12882"} {"question_id": 5577, "db_id": "menu", "grading_method": "set", "question": "On average, how many different dishes appear on each page of the menu with ID 12882? Round your answer to 1 decimal place.", "evidence": "different dishes on a page refers to COUNT(DISTINCT MenuItem.dish_id) for that menu_page_id, counting 0 for a page with no entries; on average per page refers to AVG of those counts, one for each page of the menu with ID 12882, ROUND(that average, 1)", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(dishes) FROM (SELECT mp.id,COUNT(DISTINCT mi.dish_id) AS dishes FROM MenuPage mp LEFT JOIN MenuItem mi ON mi.menu_page_id=mp.id WHERE mp.menu_id=12882 GROUP BY mp.id)\n) SELECT ROUND(value, 1) FROM unrounded;"} {"question_id": 5583, "db_id": "shipping", "grading_method": "set", "question": "Among the customers having at least one shipment in 2017, how many of them have an annual revenue of over 30000000?", "evidence": "shipment in 2017 refers to Cast(ship_date AS DATE) = 2017; annual revenue of over 30000000 refers to annual_revenue > 30000000", "SQL": "SELECT COUNT(COUNTCUSID) FROM ( SELECT COUNT(T1.cust_id) AS COUNTCUSID FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id WHERE STRFTIME('%Y', T2.ship_date) = '2017' AND T1.annual_revenue > 30000000 GROUP BY T1.cust_id HAVING COUNT(T2.ship_id) >= 1 ) T3"} {"question_id": 5587, "db_id": "shipping", "grading_method": "set", "question": "What is the heaviest shipment sent to New York City?", "evidence": "New York City refers to city.city_name = 'New York'; the heaviest shipment refers to MAX(shipment.weight) over the shipment rows sent to that destination city", "SQL": "SELECT MAX(T1.weight) FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T2.city_name = 'New York'"} {"question_id": 5605, "db_id": "shipping", "grading_method": "set", "question": "What is the average number of shipments done by the Kenworth trucks?", "evidence": "\"Kenworth\" is the make of truck; average = Divide (Count(ship_id where make = 'Kenworth'), Count(truck_id where make = 'Kenworth'))", "SQL": "SELECT CAST(COUNT(T2.ship_id) AS REAL) / COUNT(DISTINCT T1.truck_id) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T1.make = 'Kenworth'"} {"question_id": 5608, "db_id": "shipping", "grading_method": "set", "question": "What is the full name of the driver who transported the first shipment of the company?", "evidence": "first shipment of the company refers to Min(ship_date); full name refers to first_name, last_name", "SQL": "SELECT d.`first_name`, d.`last_name` \nFROM `driver` d\nJOIN `shipment` s\n ON s.`driver_id` = d.`driver_id`\nWHERE s.`ship_date` = (SELECT MIN(`ship_date`) FROM `shipment`);"} {"question_id": 5609, "db_id": "shipping", "grading_method": "set", "question": "In total, how many shipments were transported to Olympic Camper Sales Inc?", "evidence": "\"Olympic Camper Sales Inc\" is the cust_name", "SQL": "SELECT COUNT(T2.ship_id) FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id WHERE T1.cust_name = 'Olympic Camper Sales Inc'"} {"question_id": 5616, "db_id": "shipping", "grading_method": "set", "question": "How many shipments did Holger Nohr transport to North Las Vegas overall?", "evidence": "\"North Las Vegas\" is the city_name", "SQL": "SELECT COUNT(*) FROM driver AS T1 INNER JOIN shipment AS T2 ON T1.driver_id = T2.driver_id INNER JOIN city AS T3 ON T3.city_id = T2.city_id WHERE T1.first_name = 'Holger' AND T1.last_name = 'Nohr' AND T3.city_name = 'North Las Vegas'"} {"question_id": 5618, "db_id": "shipping", "grading_method": "set", "question": "Determine the percentage of manufacturers among all of Texas's customers.", "evidence": "\"Texas\" refers to state = 'TX'; 'manufacturer' is the cust_type; ", "SQL": "SELECT CAST(SUM(CASE WHEN cust_type = 'manufacturer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM customer WHERE state = 'TX'"} {"question_id": 5624, "db_id": "shipping", "grading_method": "set", "question": "Identify the full name of the driver who delivered a shipment to the city of New York in February 2016.", "evidence": "\"New York\" is the city_name; in February 2016 refers to ship_date LIKE '2016-02%'; full name refers to first_name, last_name", "SQL": "SELECT DISTINCT d.`first_name`, d.`last_name`\nFROM `shipment` AS s\nJOIN `city` AS c ON c.`city_id` = s.`city_id`\nJOIN `driver` AS d ON d.`driver_id` = s.`driver_id`\nWHERE c.`city_name` = 'New York'\n AND s.`ship_date` LIKE '2016-02%';"} {"question_id": 5632, "db_id": "shipping", "grading_method": "set", "question": "List the weight of each shipments transported by Peterbilt.", "evidence": "\"Peterbilt\" is the make", "SQL": "SELECT T2.weight FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE make = 'Peterbilt'"} {"question_id": 5633, "db_id": "shipping", "grading_method": "set", "question": "What is the model year of the truck used in shipment id 1003?", "evidence": "shipment id 1003 refers to ship_id = 1003", "SQL": "SELECT T1.model_year FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T2.ship_id = '1003'"} {"question_id": 5637, "db_id": "shipping", "grading_method": "set", "question": "State the address of drivers who transported the shipment with total weight greater than 50000 pounds .", "evidence": "shipment with weight greater than 50000 pounds refers to Sum(weight) > 50000", "SQL": "SELECT T2.address FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id GROUP BY T2.driver_id HAVING SUM(T1.weight) > 50000"} {"question_id": 5646, "db_id": "shipping", "grading_method": "set", "question": "How many customers who live in California that are retailers?", "evidence": "\"retailer\" is the cust_type; live in California refers to state = 'CA'", "SQL": "SELECT COUNT(*) FROM customer WHERE cust_type = 'retailer' AND state = 'CA'"} {"question_id": 5649, "db_id": "shipping", "grading_method": "set", "question": "What is the annual revenue of Klett & Sons Repair?", "evidence": "\"Klett & Sons Repair\" is the cust_name", "SQL": "SELECT annual_revenue FROM customer WHERE cust_name = 'Klett & Sons Repair'"} {"question_id": 5654, "db_id": "shipping", "grading_method": "set", "question": "Provide the brand of the truck and the name of the driver that transported goods in Klett & Sons Repair.", "evidence": "\"Klett & Sons Repair\" is the cust_name; brand of truck refers to make; name of driver refers to first_name, last_name", "SQL": "SELECT DISTINCT T3.make, T4.first_name, T4.last_name\nFROM `customer` AS T1\nJOIN `shipment` AS T2 ON T1.`cust_id` = T2.`cust_id`\nJOIN `truck` AS T3 ON T3.`truck_id` = T2.`truck_id`\nJOIN `driver` AS T4 ON T4.`driver_id` = T2.`driver_id`\nWHERE T1.`cust_name` = 'Klett & Sons Repair';"} {"question_id": 5663, "db_id": "shipping", "grading_method": "set", "question": "How many shipments were shipped by the driver named Zachary Hicks?", "evidence": "", "SQL": "SELECT COUNT(*)\nFROM `shipment` s\nJOIN `driver` d ON s.`driver_id` = d.`driver_id`\nWHERE d.`first_name` = 'Zachery'\n AND d.`last_name` = 'Hicks';"} {"question_id": 5670, "db_id": "shipping", "grading_method": "set", "question": "What is the model year of the truck used for shipment ID 1245?", "evidence": "", "SQL": "SELECT T1.model_year FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T2.ship_id = '1245'"} {"question_id": 5684, "db_id": "language_corpus", "grading_method": "set", "question": "Which Catalan-language Wikipedia pages have the longest titles? List their titles and character counts.", "evidence": "the longest titles refers to LENGTH(pages.title) = MAX(LENGTH(title)) over all rows of pages, counting characters including spaces and punctuation; return both the title and its character count LENGTH(title), for every page tied at that maximum", "SQL": "SELECT `title`, LENGTH(`title`) AS title_character_count FROM `pages` WHERE LENGTH(`title`) = (SELECT MAX(LENGTH(`title`)) FROM `pages`);"} {"question_id": 5685, "db_id": "language_corpus", "grading_method": "set", "question": "List the titles of Catalan Wikipedia pages containing fewer than 10 distinct words.", "evidence": "pages.lid = 1 denotes Catalan. pages.words counts distinct words in page content, not in the title.", "SQL": "SELECT `title`\nFROM `pages`\nWHERE `lid` = 1\n AND `words` < 10;"} {"question_id": 5688, "db_id": "language_corpus", "grading_method": "set", "question": "List the titles for all Catalan language wikipedia page from revision page id 106600 to 106700.", "evidence": "from revision page id 106600 to 106700 refers to revision BETWEEN 106600 AND 106700", "SQL": "SELECT title FROM pages WHERE (revision BETWEEN 106600 AND 106700) AND lid = 1"} {"question_id": 5694, "db_id": "language_corpus", "grading_method": "set", "question": "Calculate the average number of the word occurrences in which ‘system’ appeared as the first word in the pair.", "evidence": "average word occurrences = divide(sum(occurrences), count(occurrences)); ‘system’ appeared as the first word refers to w1st = 'system'", "SQL": "SELECT AVG(T2.occurrences) FROM words AS T1 INNER JOIN biwords AS T2 ON T1.wid = T2.w1st WHERE T2.w1st = ( SELECT wid FROM words WHERE word = 'system' )"} {"question_id": 5696, "db_id": "language_corpus", "grading_method": "set", "question": "Which word pairs occur most often in the Catalan corpus? List both words in each pair, including ties.", "evidence": "the Catalan corpus refers to biwords.lid = 1; occur most often refers to biwords.occurrences = MAX(occurrences) over the lid = 1 rows; return both words of each such pair as words.word, the w1st word then the w2nd word, including ties", "SQL": "SELECT w1.`word` AS first_word, w2.`word` AS second_word FROM `biwords` b JOIN `words` w1 ON w1.`wid` = b.`w1st` JOIN `words` w2 ON w2.`wid` = b.`w2nd` WHERE b.`lid` = 1 AND b.`occurrences` = ( SELECT MAX(`occurrences`) FROM `biwords` WHERE `lid` = 1)"} {"question_id": 5701, "db_id": "language_corpus", "grading_method": "set", "question": "What are the titles of the Catalan language Wikipedia page with the least number of different words?", "evidence": "least number of different words refers to min(count(words));", "SQL": "with sub as (SELECT pid, count(distinct wid) as num FROM pages_words GROUP by pid)\nSELECT title FROM pages T1 JOIN sub T2 on T1.pid = T2.pid WHERE num = (SELECT min(num) FROM sub)"} {"question_id": 5713, "db_id": "language_corpus", "grading_method": "set", "question": "Is \"88\" the word id for word \"Animals\"? Output YES or NO", "evidence": "word id \"88\" refers to wid = 88", "SQL": "SELECT CASE\n WHEN EXISTS (SELECT 1\n FROM `words`\n WHERE `wid` = 88\n AND `word` = 'Animals')\n THEN 'YES' ELSE 'NO' END AS YORN;"} {"question_id": 5714, "db_id": "language_corpus", "grading_method": "set", "question": "How many occurrences of the word ‘del’ are associated with the page titled ‘Any anomalístic’?", "evidence": "pages.title records the page title; words.word records the word. pages_words.occurrences records occurrences of that word on that page.", "SQL": "SELECT T2.occurrences 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 = 'del' AND T3.title = 'Any anomalístic'"} {"question_id": 5721, "db_id": "language_corpus", "grading_method": "set", "question": "Indicate which is the word that is repeated the most times.", "evidence": "repeated the most times refer to MAX(occurrences);", "SQL": "SELECT word FROM words WHERE occurrences = ( SELECT MAX(occurrences) FROM words )"} {"question_id": 5722, "db_id": "language_corpus", "grading_method": "set", "question": "Indicate the page id of Wikipedia about Catalan language of all the pages that have a numeric value in their title.", "evidence": "the page id of Wikipedia refers to pid; numeric value contains only numbers, LIKE '%0%' OR '%1%' OR '%2%' OR '%3%' OR '%4%' OR '%5%' OR '%6%' OR '%7%' OR '%8%' OR '%9%';", "SQL": "SELECT `pid` FROM `pages` WHERE `lid` = 1 AND ( `title` LIKE '%0%' OR `title` LIKE '%1%' OR `title` LIKE '%2%' OR `title` LIKE '%3%' OR `title` LIKE '%4%' OR `title` LIKE '%5%' OR `title` LIKE '%6%' OR `title` LIKE '%7%' OR `title` LIKE '%8%' OR `title` LIKE '%9%' )"} {"question_id": 5733, "db_id": "language_corpus", "grading_method": "set", "question": "Indicate if there is any pair formed by the words fukunaga and d'egees. Output YES or NO.", "evidence": "Pair is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word;  w1st = word = 'fukunaga' or w2nd = word = 'fukunaga'; w1st = word = 'd''egees' or w2nd = word = 'd''egees';", "SQL": "WITH f AS (SELECT wid FROM words WHERE word = 'fukunaga'),\n d AS (SELECT wid FROM words WHERE word = 'd''egees')\nSELECT CASE\n WHEN EXISTS (SELECT 1\n FROM biwords, f, d\n WHERE (w1st = f.wid AND w2nd = d.wid)\n OR (w1st = d.wid AND w2nd = f.wid))\n THEN 'YES'\n ELSE 'NO'\n END;"} {"question_id": 5739, "db_id": "language_corpus", "grading_method": "set", "question": "How frequently did the words 1 and 25 appear together?", "evidence": "How frequently refers to occurrences;  word 1 refers to wid = 1; word 25 refers to wid = 25; appear together means pair, which is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word;  w1st or w2nd = wid = 1; w1st or w2nd = wid = 25;", "SQL": "SELECT SUM(`occurrences`) AS frequency FROM `biwords` WHERE (`w1st` = 1 AND `w2nd` = 25) OR (`w1st` = 25 AND `w2nd` = 1)"} {"question_id": 5761, "db_id": "language_corpus", "grading_method": "set", "question": "What is the locale of the language of the page titled \"Anys 90\"?", "evidence": "page titled \"Anys 90\" refers to title = 'Anys 90';", "SQL": "SELECT T1.locale FROM langs AS T1 INNER JOIN pages AS T2 ON T1.lid = T2.lid WHERE T2.title = 'Anys 90'"} {"question_id": 5770, "db_id": "language_corpus", "grading_method": "set", "question": "Return the total number of distinct pages that contain at least one word with more than 3,000 occurrences on that page.", "evidence": "with more than 3,000 occurrences refers to occurrences > 3000;", "SQL": "select count(distinct pid) from pages_words WHERE occurrences > 3000"} {"question_id": 5781, "db_id": "language_corpus", "grading_method": "set", "question": "How many words are there in total on the pages that the word \"grec\" has occurred for 52 times?", "evidence": "the word \"grec\" refers to word = 'grec'; occurred for 52 times refers to occurrences = 52", "SQL": "SELECT SUM(T3.words) 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 = 'grec' AND T2.occurrences = 52"} {"question_id": 5782, "db_id": "language_corpus", "grading_method": "set", "question": "What's the occurrence of the biwords pair whose first word is \"àbac\" and second word is \"xinès\"?", "evidence": "àbac refers to word = 'àbac'; xinès refers to word = 'xinès'; occurrence refers to occurrences", "SQL": "SELECT occurrences FROM biwords WHERE w1st = ( SELECT wid FROM words WHERE word = 'àbac' ) AND w2nd = ( SELECT wid FROM words WHERE word = 'xinès' )"} {"question_id": 5786, "db_id": "language_corpus", "grading_method": "set", "question": "What is the total occurrence of the biwords pairs with \"àbac\" as its first word?", "evidence": "occurrence refers to occurrences; àbac refers to word = 'àbac'; first word refers to w1st", "SQL": "SELECT SUM(b.`occurrences`) AS total_occurrences\nFROM `biwords` AS b\nJOIN `words` AS w ON w.`wid` = b.`w1st`\nWHERE w.`word` = 'àbac';"} {"question_id": 5790, "db_id": "language_corpus", "grading_method": "set", "question": "Which word has the most repetitions in the Catalan language? Give the ID of the word.", "evidence": "word with the most repetitions refers to MAX(occurrences); ID of the word refers to wid", "SQL": "SELECT wid FROM langs_words WHERE lid = 1 AND occurrences = ( SELECT MAX(occurrences) FROM langs_words WHERE lid = 1)"} {"question_id": 5795, "db_id": "language_corpus", "grading_method": "set", "question": "For the biwords pair that appears \"116430\" times, what is the second word of the pair?", "evidence": "the biwords pair that appears \"116430\" times refers to occurrences = 116430; second word of the pair refers to w2nd", "SQL": "SELECT T1.word FROM words AS T1 INNER JOIN biwords AS T2 ON T1.wid = T2.w2nd WHERE T2.occurrences = 116430"} {"question_id": 5817, "db_id": "language_corpus", "grading_method": "set", "question": "What is the title of the page on which the word \"grec\" has an occurrence of 52 times.", "evidence": "occurrence of 52 times refers to pages_words.occurrences = 52; grec refers to word = 'grec'", "SQL": "SELECT T3.title 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 = 'grec' AND T2.occurrences = 52"} {"question_id": 5820, "db_id": "airline", "grading_method": "set", "question": "How many flights were there on 2018/8/1?", "evidence": "on 2018/8/1 refers to FL_DATE = '2018/8/1';", "SQL": "SELECT COUNT(*) FROM Airlines WHERE FL_DATE = '2018/8/1'"} {"question_id": 5822, "db_id": "airline", "grading_method": "set", "question": "Please list the destination cities of all the flights that were cancelled on 2018/8/1.", "evidence": "destination cities refers to DEST; cancelled refers to CANCELLED = 1; on 2018/8/1 refers to FL_DATE = '2018/8/1';", "SQL": "SELECT DEST FROM Airlines WHERE FL_DATE = '2018/8/1' AND CANCELLED = 1 GROUP BY DEST"} {"question_id": 5826, "db_id": "airline", "grading_method": "set", "question": "What are the destination airport names for the flights with the longest departure delay on August 1, 2018?", "evidence": "on August 1, 2018 refers to Airlines.FL_DATE = '2018/8/1'; the longest departure delay refers to MAX(Airlines.DEP_DELAY) over that day's flights; the destination airport name refers to the Airports.Description of the airport that Airlines.DEST identifies; return that Description for every one of those flights whose DEP_DELAY equals the maximum", "SQL": "WITH dest_delay AS (SELECT DEST, DEP_DELAY FROM Airlines WHERE FL_DATE = '2018/8/1')\nSELECT T1.Description FROM Airports AS T1 INNER JOIN dest_delay AS T2 ON T1.Code = T2.DEST WHERE T2.DEP_DELAY = (SELECT MAX(DEP_DELAY) FROM dest_delay)"} {"question_id": 5827, "db_id": "airline", "grading_method": "set", "question": "Among the flights departing from John F. Kennedy International, how many of them arrived earlier than scheduled?", "evidence": "departing from refers to ORIGIN; John F. Kennedy International refers to Description = 'New York, NY: John F. Kennedy International'; arrived earlier than scheduled refers to ARR_DELAY < 0;", "SQL": "SELECT SUM(CASE WHEN T2.ARR_DELAY < 0 THEN 1 ELSE 0 END) AS count FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.ORIGIN WHERE T1.Description = 'New York, NY: John F. Kennedy International'"} {"question_id": 5828, "db_id": "airline", "grading_method": "set", "question": "Among all the flights scheduled to depart from John F. Kennedy International on 2018/8/1, when was the earliest one scheduled to depart?", "evidence": "depart from refers to ORIGIN; John F. Kennedy International refers to Description = 'New York, NY: John F. Kennedy International'; on 2018/8/1 refers to FL_DATE = '2018/8/1'; earliest one scheduled to depart refers to MIN(CRS_DEP_TIME);", "SQL": "SELECT MIN(`CRS_DEP_TIME`) AS earliest_scheduled_dep\nFROM `Airlines` AS a\nJOIN `Airports` AS ap ON ap.`Code` = a.`ORIGIN`\nWHERE ap.`Description` = 'New York, NY: John F. Kennedy International'\n AND a.`FL_DATE` = '2018/8/1';"} {"question_id": 5832, "db_id": "airline", "grading_method": "set", "question": "What are the flight numbers of the flights operated by American Airlines Inc. that had the longest delay in departure?", "evidence": "flight numbers refers to OP_CARRIER_FL_NUM; American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; longest delay in departure refers to MAX(DEP_DELAY);", "SQL": "SELECT a.`OP_CARRIER_FL_NUM` FROM `Airlines` AS a JOIN `Air Carriers` AS c ON a.`OP_CARRIER_AIRLINE_ID` = c.`Code` WHERE c.`Description` = 'American Airlines Inc.: AA' AND a.DEP_DELAY = (SELECT MAX(DEP_DELAY) FROM `Airlines` AS a2 JOIN `Air Carriers` AS c2 ON a2.`OP_CARRIER_AIRLINE_ID` = c2.`Code` WHERE c2.`Description` = 'American Airlines Inc.: AA');"} {"question_id": 5833, "db_id": "airline", "grading_method": "set", "question": "Among the flights operated by American Airlines Inc., how many of them were scheduled to land in New York?", "evidence": "American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; land in New York refers to DEST = 'JFK';", "SQL": "SELECT SUM(CASE WHEN T2.DEST = 'JFK' THEN 1 ELSE 0 END) AS count FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST INNER JOIN `Air Carriers` AS T3 ON T2.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T3.Description = 'American Airlines Inc.: AA'"} {"question_id": 5835, "db_id": "airline", "grading_method": "set", "question": "Which airline operated more flights on 2018/8/1, American Airlines Inc. or Endeavor Air Inc.?", "evidence": "SUM(Description = 'American Airlines Inc.: AA') > SUM(Description = 'Endeavor Air Inc.: 9E') means American Airlines Inc. operated more flights than  Endeavor Air Inc; SUM(Description = 'American Airlines Inc.: AA') < SUM(Description = 'Endeavor Air Inc.: 9E') means Endeavor Air Inc. operated more flights than American Airlines Inc.; on 2018/8/1 refers to FL_DATE = '2018/8/1';", "SQL": "SELECT CASE WHEN COUNT(CASE WHEN T3.Description = 'American Airlines Inc.: AA' THEN 1 ELSE NULL END) > \nCOUNT(CASE WHEN T3.Description = 'Endeavor Air Inc.: 9E' THEN 1 ELSE NULL END) THEN 'American Airlines Inc.' ELSE 'Endeavor Air Inc.' END AS RESULT \nFROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.ORIGIN INNER JOIN `Air Carriers` AS T3 ON T2.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T2.FL_DATE = '2018/8/1'"} {"question_id": 5837, "db_id": "airline", "grading_method": "set", "question": "How many flights did American Airlines Inc. operate per day on average during August 2018, excluding cancellations?", "evidence": "American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; during August 2018 refers to Airlines.FL_DATE LIKE '2018/8%'; excluding cancellations refers to CANCELLED = 0; flights per day on average = DIVIDE(COUNT(those flights), 31.0), 31 being the days of August", "SQL": "SELECT CAST(COUNT(*) AS REAL)/31 AS avg_flights_per_day FROM `Airlines` A JOIN `Air Carriers` C ON A.`OP_CARRIER_AIRLINE_ID` = C.`Code` WHERE C.`Description` = 'American Airlines Inc.: AA' AND A.`FL_DATE` LIKE '2018/8%' AND A.`CANCELLED` = 0"} {"question_id": 5840, "db_id": "airline", "grading_method": "set", "question": "Provide the number of flights that landed on Oakland Airport on 2018/8/7.", "evidence": "landed on refers to DEST AND CANCELLED=0; Oakland Airport refers to Description which contains 'Oakland'; on 2018/8/7 refers to FL_DATE = '2018/8/7';", "SQL": "SELECT SUM(CASE WHEN T1.Description LIKE '%Oakland%' THEN 1 ELSE 0 END) AS count FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST WHERE T2.FL_DATE = '2018/8/7' AND T2.CANCELLED=0"} {"question_id": 5842, "db_id": "airline", "grading_method": "set", "question": "How many flights landed early at Miami Airport on 2018/8/12?", "evidence": "landed on refers to DEST; landed earlier refers to ARR_DELAY < 0; Miami Airport refers to DEST = 'MIA'; on 2018/8/12 refers to FL_DATE = '2018/8/12';", "SQL": "SELECT COUNT(*) FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST WHERE T2.FL_DATE = '2018/8/12' AND T2.DEST = 'MIA' AND T2.ARR_DELAY < 0"} {"question_id": 5843, "db_id": "airline", "grading_method": "set", "question": "How many flights from American Airlines were cancelled due to a type A cancellation code?", "evidence": "American Airlines refers to Description = 'American Airlines Inc.: AA'; cancelled refers to Cancelled = 1; cancelled due to type A cancellation code refers to CANCELLATION_CODE = 'A';", "SQL": "SELECT COUNT(*) FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.CANCELLATION_CODE = 'A' AND T2.Description = 'American Airlines Inc.: AA' AND T1.CANCELLED = 1"} {"question_id": 5847, "db_id": "airline", "grading_method": "set", "question": "Provide the name of the airport where the most flights landed on 2018/8/15.", "evidence": "landed on 2018/8/15 refers to Airlines.FL_DATE = '2018/8/15'; the airport where a flight landed refers to the Airports row that Airlines.DEST identifies; the most flights refers to the arrival airport with the greatest COUNT of those flights, taking the top 1; provide that airport's Airports.Description", "SQL": "SELECT A.`Description`\nFROM `Airports` A\nJOIN `Airlines` L ON A.`Code` = L.`DEST`\nWHERE L.`FL_DATE` = '2018/8/15'\nGROUP BY A.`Code`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 5852, "db_id": "airline", "grading_method": "set", "question": "Among flights arriving in Pittsburgh with both actual and scheduled flight durations recorded, what percentage took less time than scheduled?", "evidence": "arriving in Pittsburgh refers to flights whose Airlines.DEST identifies an Airports row with Description LIKE '%Pittsburgh%'; restrict to flights with Airlines.ACTUAL_ELAPSED_TIME IS NOT NULL AND Airlines.CRS_ELAPSED_TIME IS NOT NULL; took less time than scheduled refers to ACTUAL_ELAPSED_TIME < CRS_ELAPSED_TIME; percentage = DIVIDE(SUM(CASE WHEN ACTUAL_ELAPSED_TIME < CRS_ELAPSED_TIME THEN 1 ELSE 0 END), COUNT(*)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T1.ACTUAL_ELAPSED_TIME < T1.CRS_ELAPSED_TIME THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Airlines AS T1 INNER JOIN Airports AS T2 ON T2.Code = T1.DEST WHERE T2.Description LIKE '%Pittsburgh%' AND T1.CRS_ELAPSED_TIME IS NOT NULL AND T1.ACTUAL_ELAPSED_TIME IS NOT NULL"} {"question_id": 5854, "db_id": "airline", "grading_method": "set", "question": "How many flights departed on time on 8/1/2018?", "evidence": "departed on time refers to DEP_DELAY < = 0 and CANCELLED=0; on 8/1/2018 refers to FL_DATE = '2018/8/1';", "SQL": "SELECT COUNT(*)\nFROM `Airlines`\nWHERE `FL_DATE` = '2018/8/1'\n AND `CANCELLED` = 0\n AND `DEP_DELAY` <= 0;"} {"question_id": 5855, "db_id": "airline", "grading_method": "set", "question": "What are the codes of the airport found in Ankara, Turkey?", "evidence": "airport found in Ankara, Turkey refers to Description like '%Ankara, Turkey%';", "SQL": "SELECT Code FROM Airports WHERE Description LIKE '%Ankara, Turkey%'"} {"question_id": 5857, "db_id": "airline", "grading_method": "set", "question": "What is the IATA code of the Anita Bay Airport in Anita Bay, Alaska?", "evidence": "IATA code refers to Code; Anita Bay Airport in Anita Bay, Alaska refers to Description = 'Anita Bay, AK: Anita Bay Airport';", "SQL": "SELECT Code FROM Airports WHERE Description = 'Anita Bay, AK: Anita Bay Airport'"} {"question_id": 5861, "db_id": "airline", "grading_method": "set", "question": "On August 2018, which day had the highest number of cancelled flights which were scheduled to depart from Dallas/Fort Worth International due to the most serious reasons?", "evidence": "On August 2018 refers to FL_DATE like '2018/8%'; day with the highest number of cancelled flights refers to MAX(COUNT(FL_DATE WHERE CANCELLED = 1)); cancelled due to the most serious reasons refers to CANCELLATION_CODE = 'A'; in Dallas/Fort Worth International refers to Description = 'Dallas/Fort Worth, TX: Dallas/Fort Worth International';", "SQL": "SELECT T2.FL_DATE FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.ORIGIN WHERE T2.FL_DATE LIKE '2018/8%' AND T1.Description = 'Dallas/Fort Worth, TX: Dallas/Fort Worth International' AND T2.ORIGIN = 'DFW' AND T2.CANCELLED = 1 AND T2.CANCELLATION_CODE = 'A' GROUP BY T2.FL_DATE ORDER BY COUNT(T2.FL_DATE) DESC LIMIT 1"} {"question_id": 5862, "db_id": "airline", "grading_method": "set", "question": "List the tail numbers of all the aircraft that arrived on time at Meadows Field airport in August of 2018?", "evidence": "tail number refers to TAIL_NUM; arrived on time refers to ARR_DELAY < = 0; Meadows Field airport refers to Description = 'Bakersfield, CA: Meadows Field'; in August of 2018 refers to FL_DATE like '2018/8%';", "SQL": "SELECT T2.TAIL_NUM FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST WHERE T2.FL_DATE LIKE '2018/8%' AND T1.Description = 'Bakersfield, CA: Meadows Field' AND T2.ARR_DELAY <= 0 GROUP BY T2.TAIL_NUM"} {"question_id": 5869, "db_id": "airline", "grading_method": "set", "question": "From which airport did Republic Airline operate the most flights?", "evidence": "Republic Airline is recorded in Description as 'Republic Airline: YX'. ORIGIN identifies the departure airport.", "SQL": "SELECT T2.`ORIGIN`\nFROM `Air Carriers` AS T1\nJOIN `Airlines` AS T2\n ON T1.`Code` = T2.`OP_CARRIER_AIRLINE_ID`\nWHERE T1.`Description` = 'Republic Airline: YX'\nGROUP BY T2.`ORIGIN`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 5871, "db_id": "airline", "grading_method": "set", "question": "How many hours of delay did Delta Air Lines flights incur because of late-arriving aircraft in August 2018? Round your answer to 1 decimal place.", "evidence": "Delta Air Lines refers to `Air Carriers`.Description = 'Delta Air Lines Inc.: DL'; in August 2018 refers to FL_DATE LIKE '2018/8/%'; delay due to a late-arriving aircraft refers to LATE_AIRCRAFT_DELAY in minutes; hours of delay = DIVIDE(SUM(LATE_AIRCRAFT_DELAY), 60), rounded to 1 decimal place", "SQL": "WITH unrounded(value) AS (\nSELECT cast(SUM(`LATE_AIRCRAFT_DELAY`) as REAL)/60\n FROM `Airlines` AS a\n JOIN `Air Carriers` AS c ON c.`Code` = a.`OP_CARRIER_AIRLINE_ID`\n WHERE c.`Description` = 'Delta Air Lines Inc.: DL'\n AND a.`FL_DATE` LIKE '2018/8/%'\n) SELECT ROUND(value, 1) FROM unrounded;"} {"question_id": 5873, "db_id": "airline", "grading_method": "set", "question": "What is the code of Mississippi Valley Airlines?", "evidence": "Mississippi Valley Airlines refers to Description like 'Mississippi Valley Airlines%';", "SQL": "SELECT Code FROM `Air Carriers` WHERE Description LIKE 'Mississippi Valley Airlines%'"} {"question_id": 5881, "db_id": "airline", "grading_method": "set", "question": "Which flight carrier operator flies from Atlantic City to Fort Lauderdale?", "evidence": "flight carrier operator refers to Description; from Atlantic City refers to ORIGIN = 'ACY'; to Fort Lauderdale refers to DEST = 'FLL';", "SQL": "SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.ORIGIN = 'ACY' AND T1.DEST = 'FLL' GROUP BY T2.Description"} {"question_id": 5882, "db_id": "airline", "grading_method": "set", "question": "What is the airport description of the airport code A11?", "evidence": "", "SQL": "SELECT Description FROM Airports WHERE Code = 'A11'"} {"question_id": 5883, "db_id": "airline", "grading_method": "set", "question": "What is the total number of flights that have Oklahoma City as their origin?", "evidence": "Oklahoma as origin refers to Origin = 'OKC';", "SQL": "SELECT COUNT(*) AS num FROM Airlines WHERE Origin = 'OKC'"} {"question_id": 5885, "db_id": "airline", "grading_method": "set", "question": "Provide the destinations of flight number 1596.", "evidence": "destination refers to DEST; flight number refers to OP_CARRIER_FL_NUM; OP_CARRIER_FL_NUM = 1596;", "SQL": "SELECT DEST FROM Airlines WHERE OP_CARRIER_FL_NUM = 1596"} {"question_id": 5886, "db_id": "airline", "grading_method": "set", "question": "List the description of the airports that have code that ends with number 3?", "evidence": "code that ends with number 3 refers to Code like '%3';", "SQL": "SELECT Description FROM Airports WHERE Code LIKE '%3'"} {"question_id": 5887, "db_id": "airline", "grading_method": "set", "question": "Give the code of the airport described as Driftwood Bay, AK: Driftwood Bay Airport.", "evidence": "Driftwood Bay, AK: Driftwood Bay Airport refers to Description = 'Driftwood Bay, AK: Driftwood Bay Airport';", "SQL": "SELECT Code FROM Airports WHERE Description = 'Driftwood Bay, AK: Driftwood Bay Airport'"} {"question_id": 5888, "db_id": "airline", "grading_method": "set", "question": "How many cancelled flights are there?", "evidence": "cancelled flights refers to CANCELLED = 1;", "SQL": "SELECT COUNT(*) FROM Airlines WHERE CANCELLED = 1"} {"question_id": 5889, "db_id": "airline", "grading_method": "set", "question": "List the tail number of flights that flew on August 17, 2018.", "evidence": "tail number refers to TAIL_NUM; on August 17, 2018 refers to FL_DATE = '2018/8/17';", "SQL": "SELECT TAIL_NUM FROM Airlines WHERE FL_DATE = '2018/8/17' GROUP BY TAIL_NUM"} {"question_id": 5890, "db_id": "airline", "grading_method": "set", "question": "Provide the origin of the flight that has the shortest actual elapsed time.", "evidence": "shortest actual elapsed time refers to MIN(ACTUAL_ELAPSED_TIME);", "SQL": "SELECT `ORIGIN`\nFROM `Airlines`\nWHERE `ACTUAL_ELAPSED_TIME` = (\n SELECT MIN(`ACTUAL_ELAPSED_TIME`)\n FROM `Airlines`\n WHERE `ACTUAL_ELAPSED_TIME` IS NOT NULL\n);"} {"question_id": 5891, "db_id": "airline", "grading_method": "set", "question": "Provide the date and tail number for each flight operated by ExpressJet Airlines Inc.: EV.", "evidence": "date of flight refers to FL_DATE; tail number of flight refers to TAIL_NUM; ExpressJet Airlines Inc.: EV refers to Description = 'ExpressJet Airlines Inc.: EV';", "SQL": "SELECT T1.FL_DATE, T1.TAIL_NUM FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T2.Description = 'ExpressJet Airlines Inc.: EV'"} {"question_id": 5896, "db_id": "airline", "grading_method": "set", "question": "Give the actual elapsed time of the flights with air carrier named Spirit Air Lines: NK.", "evidence": "actual elapsed time refers to ACTUAL_ELAPSED_TIME; Semo Aviation Inc.: SEM. Refers to Description = 'Spirit Air Lines: NK';", "SQL": "SELECT T2.ACTUAL_ELAPSED_TIME FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Spirit Air Lines: NK'"} {"question_id": 5897, "db_id": "airline", "grading_method": "set", "question": "Among the flights with air carrier described as Delta Air Lines Inc.: DL, what is the tail number of the flight with the longest departure delay?", "evidence": "Delta Air Lines Inc.: DL refers to Description = 'Delta Air Lines Inc.: DL'; tail number refers to TAIL_NUM; longest departure delay refers to MAX(DEP_DELAY);", "SQL": "SELECT T2.TAIL_NUM FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Delta Air Lines Inc.: DL' ORDER BY T2.DEP_DELAY DESC LIMIT 1"} {"question_id": 5902, "db_id": "airline", "grading_method": "set", "question": "What is the total number of flights that flew on August 2, 2018 with air carrier described as Horizon Air?", "evidence": "on August 2, 2018 refers to FL_DATE = '2018/8/2'; Horizon Air refers to Description which includs 'Horizon Air';", "SQL": "SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%Horizon Air%' AND T2.FL_DATE = '2018/8/2'"} {"question_id": 5904, "db_id": "airline", "grading_method": "set", "question": "List the flight date of flights with air carrier described as Endeavor Air Inc.: 9E which have an actual elapsed time below 40.", "evidence": "flight date refers to FL_DATE; Endeavor Air Inc.: 9E refers to Description = 'Endeavor Air Inc.: 9E'; actual elapsed time below 40 refers to ACTUAL_ELAPSED_TIME < 40", "SQL": "SELECT DISTINCT T2.FL_DATE FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ACTUAL_ELAPSED_TIME < 40 AND T1.Description = 'Endeavor Air Inc.: 9E'"} {"question_id": 5911, "db_id": "airline", "grading_method": "set", "question": "Among all recorded American Airlines flights, what percentage have a recorded departure earlier than scheduled?", "evidence": "American Airlines refers to Description LIKE '%American Airlines%'; a departure earlier than scheduled refers to DEP_DELAY < 0, since a negative delay means departure before schedule; percentage = DIVIDE(SUM(CASE WHEN DEP_DELAY < 0 THEN 1 ELSE 0 END), COUNT(*)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T2.DEP_DELAY < 0 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%American Airlines%'"} {"question_id": 5913, "db_id": "books", "grading_method": "set", "question": "What is the publication date of the book with the most pages?", "evidence": "book with the most pages refers to Max(num_pages)", "SQL": "SELECT publication_date FROM book ORDER BY num_pages DESC LIMIT 1"} {"question_id": 5917, "db_id": "books", "grading_method": "set", "question": "Please give the title of the oldest book published by publisher \"Thomas Nelson\".", "evidence": "\"Thomas Nelson\" is the publisher_name; oldest book refers to Min(publication_date)", "SQL": "SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' ORDER BY T1.publication_date ASC LIMIT 1"} {"question_id": 5918, "db_id": "books", "grading_method": "set", "question": "Among the books published by publisher \"Thomas Nelson\", how many of them have over 300 pages?", "evidence": "\"Thomas Nelson\" is the publisher_name; books with over 300 pages refers to num_pages > 300", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' AND T1.num_pages > 300"} {"question_id": 5919, "db_id": "books", "grading_method": "set", "question": "What is the name of the publisher of the book with the most pages?", "evidence": "book with the most pages refers to Max(num_pages); name of publisher refers to publisher_name", "SQL": "SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id ORDER BY T1.num_pages DESC LIMIT 1"} {"question_id": 5920, "db_id": "books", "grading_method": "set", "question": "How many books are in English?", "evidence": "books in English refers to language_name like '%English%'", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name LIKE '%English%'"} {"question_id": 5924, "db_id": "books", "grading_method": "set", "question": "Among Lucas Wyldbore’s book order lines, how many are for books with more than 300 pages?", "evidence": "book.num_pages records the number of pages; Lucas Wyldbore is recorded in customer.first_name and customer.last_name.", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_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 T4.first_name = 'Lucas' AND T4.last_name = 'Wyldbore' AND T1.num_pages > 300"} {"question_id": 5926, "db_id": "books", "grading_method": "set", "question": "How much money on average does Lucas Wyldbore spend on book orders?", "evidence": "average spend on book orders = AVG (price)", "SQL": "SELECT AVG(order_total)\nFROM (\n SELECT T1.order_id,\n SUM(T1.price) AS order_total\n FROM `order_line` AS T1\n JOIN `cust_order` AS T2 ON T2.`order_id` = T1.`order_id`\n JOIN `customer` AS T3 ON T3.`customer_id` = T2.`customer_id`\n WHERE T3.`first_name` = 'Lucas'\n AND T3.`last_name` = 'Wyldbore'\n GROUP BY T1.`order_id`\n);"} {"question_id": 5927, "db_id": "books", "grading_method": "set", "question": "Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13?", "evidence": "books over $13 refers to price > 13; percentage = Divide (Sum (order_id where price > 13), Count (order_id)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T1.price > 13 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'"} {"question_id": 5933, "db_id": "books", "grading_method": "set", "question": "Which language was book id 1405 written in?", "evidence": "language written in refers to language_name;", "SQL": "SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.book_id = 1405"} {"question_id": 5934, "db_id": "books", "grading_method": "set", "question": "Which customer has made the most orders? Show his/her full name.", "evidence": "most order refers to Max(Count(order_id)); customer refers to first_name, last_name", "SQL": "SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1"} {"question_id": 5936, "db_id": "books", "grading_method": "set", "question": "How many books did David Foster Wallace write?", "evidence": "\"David Foster Wallace\" is the author_name;", "SQL": "SELECT COUNT(T1.title) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'David Foster Wallace'"} {"question_id": 5938, "db_id": "books", "grading_method": "set", "question": "Which country does Malina Johnson live in currently?", "evidence": "country refers to country_name", "SQL": "SELECT T4.country_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T3.address_id = T2.address_id INNER JOIN country AS T4 ON T4.country_id = T3.country_id WHERE T1.first_name = 'Malina' AND T1.last_name = 'Johnson' AND T2.status_id = 1"} {"question_id": 5940, "db_id": "books", "grading_method": "set", "question": "Which country does Žirovnica city belong to?", "evidence": "\"Žirovnica\" is the city; country refers to country_name", "SQL": "SELECT T1.country_name FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T2.city = 'Žirovnica'"} {"question_id": 5946, "db_id": "books", "grading_method": "set", "question": "How many orders in 2022 have Iran as their destinations?", "evidence": "Iran as their destination refers to country_name = 'Iran'; orders in 2022 refers to order_date LIKE '2022%'", "SQL": "SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id INNER JOIN cust_order AS T3 ON T3.dest_address_id = T2.address_id WHERE T1.country_name = 'Iran' AND STRFTIME('%Y', T3.order_date) = '2022'"} {"question_id": 5947, "db_id": "books", "grading_method": "set", "question": "Among Daisey Lamball's orders, how many were shipped via International shipping?", "evidence": "via international shipping refers to method_name = 'International'", "SQL": "SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Daisey' AND T1.last_name = 'Lamball' AND T3.method_name = 'International'"} {"question_id": 5954, "db_id": "books", "grading_method": "set", "question": "What is the name of the publisher who published Agatha Christie's first book?", "evidence": "\"Agatha Christie\" is the author_name; name of publisher refers to publisher_name; first book refers to Min(publication_date)", "SQL": "SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Agatha Christie' ORDER BY T1.publication_date ASC LIMIT 1"} {"question_id": 5957, "db_id": "books", "grading_method": "set", "question": "What are the names of the publishers that published the most books?", "evidence": "published the most books refers to the per-publisher COUNT of books equal to the maximum such count over all publishers; return publisher.publisher_name for every publisher holding that maximum", "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_name HAVING COUNT(T2.publisher_id) = (SELECT MAX(TotalBooks) FROM (SELECT T3.publisher_id, COUNT(T3.book_id) AS TotalBooks FROM book AS T3 INNER JOIN publisher AS T4 ON T3.publisher_id = T4.publisher_id GROUP BY T4.publisher_id) AS PublisherBookCounts);"} {"question_id": 5960, "db_id": "books", "grading_method": "set", "question": "How many of the books authored by Al Gore have less than 400 pages?", "evidence": "Author names are recorded in author.author_name; book_author links authors to books through author_id and book_id. Page counts are recorded in book.num_pages.", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Al Gore' AND T1.num_pages < 400"} {"question_id": 5961, "db_id": "books", "grading_method": "set", "question": "List the author and publisher names for books published on July 10, 1997.", "evidence": "author's name refers to author_name; publisher's name refers to publisher_name; book published on July 10, 1997 refers to publication_date LIKE '1997-07-10'", "SQL": "SELECT T3.author_name, T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T1.publication_date = '1997-07-10'"} {"question_id": 5963, "db_id": "books", "grading_method": "set", "question": "List the titles of books that are most expensive.", "evidence": "most expensive book refers to Max(price)", "SQL": "SELECT b.`title` FROM `book` AS b JOIN `order_line` AS ol ON b.`book_id` = ol.`book_id` GROUP BY b.`book_id` HAVING MAX(ol.`price`) = (SELECT MAX(`price`) FROM `order_line`)"} {"question_id": 5966, "db_id": "books", "grading_method": "set", "question": "Among the books that cost less than 1 dollar, how many were published by Berkley Trade?", "evidence": "book cost less than 1 dollar refers to price < 1; 'Berkley Trade' is the publisher_name;", "SQL": "SELECT COUNT(DISTINCT b.`book_id`)\nFROM `book` b\nJOIN `publisher` p ON p.`publisher_id` = b.`publisher_id`\nJOIN `order_line` ol ON ol.`book_id` = b.`book_id`\nWHERE p.`publisher_name` = 'Berkley Trade'\n AND ol.`price` < 1;"} {"question_id": 5972, "db_id": "books", "grading_method": "set", "question": "In books authored by Abraham Lincoln, what is the percentage of the books published in 1992?", "evidence": "\"Abraham Lincoln\" is the author_name; published in 1992 refers to publication_date LIKE '1992%'; percentage = Divide (Sum(publication_date LIKE '1992%'), Count(publication_date)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T1.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Abraham Lincoln'"} {"question_id": 5985, "db_id": "books", "grading_method": "set", "question": "How many customers are from Australia?", "evidence": "\"Australia\" is the country_name;", "SQL": "SELECT COUNT(DISTINCT `ca`.`customer_id`) \nFROM `customer_address` AS `ca`\nJOIN `address` AS `a` ON `a`.`address_id` = `ca`.`address_id`\nJOIN `country` AS `c` ON `c`.`country_id` = `a`.`country_id`\nWHERE `c`.`country_name` = 'Australia';"} {"question_id": 5988, "db_id": "books", "grading_method": "set", "question": "What percentage of orders in 2020 used international shipping?", "evidence": "orders in 2020 refers to the cust_order records whose order_date falls in 2020; international shipping refers to shipping_method.method_name = 'International' for the shipping used by that order; percentage = DIVIDE(SUM(CASE WHEN method_name = 'International' THEN 1 ELSE 0 END), COUNT(*)) * 100 over those 2020 orders", "SQL": "SELECT CAST(SUM(CASE WHEN T2.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id WHERE STRFTIME('%Y', T1.order_date) = '2020'"} {"question_id": 5990, "db_id": "books", "grading_method": "set", "question": "Which year has the most customer orders?", "evidence": "year with the most customer orders refers to Max(count(order_id))", "SQL": "SELECT strftime('%Y', order_date) FROM cust_order GROUP BY strftime('%Y', order_date) ORDER BY COUNT(strftime('%Y', order_date)) DESC LIMIT 1"} {"question_id": 5992, "db_id": "books", "grading_method": "set", "question": "List all of the books that were published in 1995.", "evidence": "published in 1995 refers to publication_date LIKE '1995%'; list of book refers to title", "SQL": "SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1995'"} {"question_id": 5993, "db_id": "books", "grading_method": "set", "question": "What are the most common domains for the email addresses among all the customers?", "evidence": "most common domain for the email refers to Max(Count(SUBSTR(email, CHARINDEX('@', email) + 1, length(email) - charindex('@', email))))", "SQL": "SELECT SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) AS ym FROM customer GROUP BY SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) HAVING COUNT(*) = (SELECT MAX(TotalCount) FROM (SELECT SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) AS domain, COUNT(*) AS TotalCount FROM customer GROUP BY domain) AS DomainCounts);"} {"question_id": 5995, "db_id": "books", "grading_method": "set", "question": "Among languages represented in the books, which languages are tied for appearing in the fewest books?", "evidence": "a language's books refers to the COUNT of book records with that book_language.language_id, counted over languages appearing in the books; the fewest refers to the minimum such count; return every language_name tied at that minimum", "SQL": "WITH language_frequency AS (SELECT language_name, COUNT(*) cnt FROM book JOIN book_language USING(language_id) GROUP BY language_name)\nSELECT language_name FROM language_frequency WHERE cnt = (SELECT MIN(cnt) FROM language_frequency)"} {"question_id": 6006, "db_id": "books", "grading_method": "set", "question": "Which customer has the most addresses?", "evidence": "customer refers to first_name, last_name; the most address refers to Max(count(address_id))", "SQL": "with sub as (SELECT c.first_name,\n c.last_name,\n COUNT(ca.address_id) as num\nFROM customer AS c\nJOIN customer_address AS ca ON ca.customer_id = c.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\n)\nSELECT first_name, last_name from sub where num = (SELECT max(num) from sub)"} {"question_id": 6009, "db_id": "books", "grading_method": "set", "question": "Other than zero, what is the lowest price paid by a customer for an order?", "evidence": "other than 0 refers to price ! = 0; lowest price paid refers to Min(price)", "SQL": "SELECT MIN(total_price)\nFROM (\n SELECT `order_id`, SUM(`price`) AS total_price\n FROM `order_line`\n GROUP BY `order_id`\n) \nWHERE total_price <> 0;"} {"question_id": 6010, "db_id": "books", "grading_method": "set", "question": "How many customers have an address that is located in the city of Villeneuve-la-Garenne?", "evidence": "\"Villeneuve-la-Garenne\" is the city", "SQL": "SELECT COUNT(DISTINCT ca.customer_id) FROM customer_address AS ca JOIN address AS a ON ca.address_id = a.address_id WHERE a.city = 'Villeneuve-la-Garenne'"} {"question_id": 6015, "db_id": "books", "grading_method": "set", "question": "Which books have the most expensive price?", "evidence": "most expensive book refers to Max(price)", "SQL": "WITH max_price AS (\n SELECT MAX(`price`) AS max_price\n FROM `order_line`\n)\nSELECT DISTINCT b.`title`\nFROM `order_line` ol\nJOIN `book` b ON ol.`book_id` = b.`book_id`\nJOIN max_price m ON ol.`price` = m.max_price;"} {"question_id": 6016, "db_id": "books", "grading_method": "set", "question": "How many customers ordered the book titled \"Anleitung zum Zickigsein\"", "evidence": "\"Anleitung zum Zickigsein\" is the title of the book", "SQL": "SELECT COUNT(DISTINCT co.`customer_id`)\nFROM `book` b\nJOIN `order_line` ol ON b.`book_id` = ol.`book_id`\nJOIN `cust_order` co ON ol.`order_id` = co.`order_id`\nWHERE b.`title` = 'Anleitung zum Zickigsein';"} {"question_id": 6017, "db_id": "books", "grading_method": "set", "question": "What is the most expensive price paid by a customer for the book \"Bite Me If You Can (Argeneau #6)\"?", "evidence": "\"Bite Me If You Can (Argeneau #6)\" is the title of the book; most expensive price refers to Max(price)", "SQL": "SELECT MAX(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'Bite Me If You Can (Argeneau #6)'"} {"question_id": 6018, "db_id": "books", "grading_method": "set", "question": "How many customers ordered the youngest book?", "evidence": "youngest book refers to Max(publiation_date)", "SQL": "SELECT COUNT(DISTINCT co.customer_id)\nFROM book b\nJOIN order_line ol ON b.book_id = ol.book_id\nJOIN cust_order co ON co.order_id = ol.order_id\nWHERE b.publication_date = (SELECT MAX(publication_date) FROM book);"} {"question_id": 6023, "db_id": "books", "grading_method": "set", "question": "Among the books that were published by Scholastic, how many were written by J.K. Rowling?", "evidence": "publisher.publisher_name records Scholastic; author.author_name records J.K. Rowling.", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN book_author AS T3 ON T3.book_id = T1.book_id INNER JOIN author AS T4 ON T4.author_id = T3.author_id WHERE T2.publisher_name = 'Scholastic' AND T4.author_name = 'J.K. Rowling'"} {"question_id": 6024, "db_id": "books", "grading_method": "set", "question": "What are the names of all the publishers who have published at least 30 books?", "evidence": "published at least 30 books refers to COUNT(book.book_id) >= 30 for the publisher, grouping book rows by publisher_id; return publisher.publisher_name for each publisher that meets it", "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, T2.publisher_name HAVING COUNT(T2.publisher_name) >= 30"} {"question_id": 6025, "db_id": "books", "grading_method": "set", "question": "Indicate the street name and the last number of the street for each address.", "evidence": "street refers to street_name; last number of each street refers to Substr (street_number, -1)", "SQL": "SELECT `street_name`, SUBSTR(`street_number`, -1) AS last_digit\nFROM `address`;"} {"question_id": 6029, "db_id": "books", "grading_method": "set", "question": "How many books were ordered in the last month of the year 2020?", "evidence": "ordered in last month of the year 2020 refers to Substr(order_date, 1, 7) = '2020-12'", "SQL": "SELECT COUNT(*) AS books_ordered\nFROM `order_line` AS ol\nJOIN `cust_order` AS co ON ol.`order_id` = co.`order_id`\nWHERE co.`order_date` >= '2020-12-01'\n AND co.`order_date` < '2021-01-01';"} {"question_id": 6032, "db_id": "books", "grading_method": "set", "question": "Which customer addresses are no longer active?", "evidence": "no longer active refers to address_status = 'Inactive'; customer address refers to street_number, street_name, city", "SQL": "SELECT a.`street_number`,\n a.`street_name`,\n a.`city`\nFROM `address` AS a\nJOIN `customer_address` AS ca ON ca.`address_id` = a.`address_id`\nJOIN `address_status` AS s ON s.`status_id` = ca.`status_id`\nWHERE LOWER(s.`address_status`) = 'inactive';"} {"question_id": 6033, "db_id": "books", "grading_method": "set", "question": "What is the full name of the customers who live in Baiyin city currently?", "evidence": "full name refers to first_name, last_name; 'Baiyin' is the city", "SQL": "SELECT DISTINCT `c`.`first_name`, `c`.`last_name`\nFROM `customer` AS `c`\nJOIN `customer_address` AS `ca` ON `ca`.`customer_id` = `c`.`customer_id`\nJOIN `address` AS `a` ON `a`.`address_id` = `ca`.`address_id`\nWHERE `a`.`city` = 'Baiyin' AND `ca`.`status_id` = 1;"} {"question_id": 6034, "db_id": "books", "grading_method": "set", "question": "What is the email of the customers who place their orders with priority method?", "evidence": "priority method refers to method_name = 'Priority'", "SQL": "SELECT DISTINCT T1.email FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T3.method_name = 'Priority'"} {"question_id": 6038, "db_id": "books", "grading_method": "set", "question": "What is the highest price at which a customer bought the book 'The Prophet'?", "evidence": "\"The Prophet\" is the title of the book; highest price refers to Max(price)", "SQL": "SELECT MAX(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Prophet'"} {"question_id": 6041, "db_id": "books", "grading_method": "set", "question": "How many books under 300 pages has HarperCollins Publishers published?", "evidence": "under 300 pages refers to num_pages < 300; 'HarperCollins Publishers' is the publisher_name", "SQL": "SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'HarperCollins Publishers' AND T1.num_pages < 300"} {"question_id": 6044, "db_id": "books", "grading_method": "set", "question": "What percentage of the orders placed by Kaleena were shipped by the international method?", "evidence": "Kaleena refers to customer.first_name = 'Kaleena'; the international method refers to shipping_method.method_name = 'International'; percentage = DIVIDE(COUNT(orders placed by Kaleena that were shipped by that method), COUNT(orders placed by Kaleena)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T3.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Kaleena'"} {"question_id": 6047, "db_id": "books", "grading_method": "set", "question": "Who is the author of the book with the biggest page count?", "evidence": "author refers to author_name, biggest page count refers to Max(num_pages)", "SQL": "SELECT DISTINCT `a`.`author_name`\nFROM `book` AS `b`\nJOIN `book_author` AS `ba` ON `ba`.`book_id` = `b`.`book_id`\nJOIN `author` AS `a` ON `a`.`author_id` = `ba`.`author_id`\nWHERE `b`.`num_pages` = (SELECT MAX(`num_pages`) FROM `book`);"} {"question_id": 6049, "db_id": "books", "grading_method": "set", "question": "Provide the full address of Ursola Purdy.", "evidence": "full address refers to street_number, street_name, city, country_name", "SQL": "SELECT a.`street_number`,\n a.`street_name`,\n a.`city`,\n co.`country_name`\nFROM `customer` AS cu\nJOIN `customer_address` AS ca ON cu.`customer_id` = ca.`customer_id`\nJOIN `address` AS a ON a.`address_id` = ca.`address_id`\nJOIN `country` AS co ON co.`country_id` = a.`country_id`\nWHERE cu.`first_name` = 'Ursola'\n AND cu.`last_name` = 'Purdy'\n AND ca.`status_id` = 1;"} {"question_id": 6053, "db_id": "books", "grading_method": "set", "question": "Identify the cost difference between Priority and Express shipping methods.", "evidence": "\"Priority\" and \"Express\" are both method_name; cost difference = ABS(Subtract (cost where method_name = 'Express', cost where method_name 'Priority'))", "SQL": "SELECT ABS(\n (SELECT `cost` FROM `shipping_method` WHERE `method_name` = 'Priority')\n - (SELECT `cost` FROM `shipping_method` WHERE `method_name` = 'Express')\n) AS cost_difference;"} {"question_id": 6054, "db_id": "books", "grading_method": "set", "question": "How many orders have been cancelled in 2022?", "evidence": "cancelled refers to status_value = 'Cancelled'; in 2022 refers to SUBSTR(status_date, 1, 4) = '2022'", "SQL": "SELECT COUNT(DISTINCT oh.`order_id`)\nFROM `order_history` AS oh\nJOIN `order_status` AS os ON os.`status_id` = oh.`status_id`\nWHERE os.`status_value` = 'Cancelled'\n AND STRFTIME('%Y', oh.`status_date`) = '2022';"} {"question_id": 6058, "db_id": "books", "grading_method": "set", "question": "Among orders with a status update in 2022, what percentage had a Returned update during that year?", "evidence": "orders with a status update in 2022 refers to order_history rows whose status_date falls in 2022; a Returned update refers to order_status.status_value = 'Returned'; percentage = DIVIDE(COUNT(DISTINCT order_id with a Returned update that year), COUNT(DISTINCT order_id with a status update that year)) * 100", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN os.`status_value` = 'Returned' THEN oh.`order_id` END) / COUNT(DISTINCT oh.`order_id`) AS returned_pct FROM `order_history` AS oh JOIN `order_status` AS os ON os.`status_id` = oh.`status_id` WHERE STRFTIME('%Y', oh.`status_date`) = '2022'"} {"question_id": 6062, "db_id": "books", "grading_method": "set", "question": "List all books authored by Tom Clancy.", "evidence": "\"Tom Clancy\" is the author_name; books refers title", "SQL": "SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Tom Clancy'"} {"question_id": 6064, "db_id": "books", "grading_method": "set", "question": "Who is the publisher of Hitchhiker's Guide To The Galaxy: The Filming of the Douglas Adams classic?", "evidence": "\"Hitchhiker's Guide To The Galaxy: The Filming of the Douglas Adams classic\" is the title of the book; publisher refers to publisher_name", "SQL": "SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'Hitchhiker''s Guide To The Galaxy: The Filming of the Douglas Adams classic'"} {"question_id": 6066, "db_id": "books", "grading_method": "set", "question": "Write the full name of the customers whose address is at 55 Dorton Pass, Huangqiao.", "evidence": "full name refers to first_name, last_name; '55' is the street_number, 'Dorton Pass' is the street_name; 'Huangqiao' is the city", "SQL": "SELECT DISTINCT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T3.address_id = T2.address_id WHERE T3.street_number = 55 AND T3.street_name = 'Dorton Pass' AND T3.city = 'Huangqiao'"} {"question_id": 6068, "db_id": "books", "grading_method": "subset,=,10", "question": "List 10 addresses located in Poland.", "evidence": "country.country_name = 'Poland' identifies the country; address.country_id identifies an address's country. address.street_number, address.street_name, and address.city are the requested address components. The question permits ten qualifying addresses.", "SQL": "SELECT T1.street_number, T1.street_name, T1.city FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Poland'"} {"question_id": 6069, "db_id": "books", "grading_method": "set", "question": "What shipping method did Nicolette Sadler use for the order placed at 6/29/2020 7:40:07 PM?", "evidence": "ordered at 6/29/2020 7:40:07 PM refers to order_date = '2020-06-29 19:40:07'; shipping method refers to method_name", "SQL": "SELECT T3.method_name FROM cust_order AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T1.shipping_method_id WHERE T2.first_name = 'Nicolette' AND T2.last_name = 'Sadler' AND T1.order_date = '2020-06-29 19:40:07'"} {"question_id": 6071, "db_id": "books", "grading_method": "set", "question": "Which language is 'El plan infinito' written in?", "evidence": "\"El plan infinito\" is the title of the book; language refers to language_name", "SQL": "SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'El plan infinito'"} {"question_id": 6072, "db_id": "books", "grading_method": "set", "question": "What percentage of Viz Media’s books were written by Hirohiko Araki?", "evidence": "Hirohiko Araki is recorded in author.author_name as 'Hirohiko Araki'; VIZ Media is recorded in publisher.publisher_name as 'VIZ Media'.", "SQL": "SELECT\n CAST(COUNT(DISTINCT CASE\n WHEN a.author_name = 'Hirohiko Araki' THEN b.book_id END) AS REAL) * 100.0 /\n COUNT(DISTINCT b.book_id) AS percentage_hirohiko_in_viz\nFROM book b\nJOIN publisher p ON p.publisher_id = b.publisher_id\nLEFT JOIN book_author ba ON ba.book_id = b.book_id\nLEFT JOIN author a ON a.author_id = ba.author_id\nWHERE p.publisher_name = 'VIZ Media';"} {"question_id": 6073, "db_id": "books", "grading_method": "set", "question": "What is the average number of book pages written by Zilpha Keatley Snyder?", "evidence": "\"Zilpha Keatley Snyder\" is the author_name; average number of book pages refers to AVG(num_pages)", "SQL": "SELECT AVG(T3.num_pages) FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id INNER JOIN book AS T3 ON T3.book_id = T1.book_id WHERE T2.author_name = 'Zilpha Keatley Snyder'"} {"question_id": 6076, "db_id": "books", "grading_method": "set", "question": "How many books were written by author A.J. Ayer?", "evidence": "\"A.J. Ayer\" is the author_name;", "SQL": "SELECT COUNT(*) FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id WHERE T2.author_name = 'A.J. Ayer'"} {"question_id": 6077, "db_id": "books", "grading_method": "set", "question": "Name the title of books written by author A.J.Ayer.", "evidence": "\"A.J. Ayer\" is the author_name;", "SQL": "SELECT T3.title FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id INNER JOIN book AS T3 ON T3.book_id = T1.book_id WHERE T2.author_name = 'A.J. Ayer'"} {"question_id": 6078, "db_id": "books", "grading_method": "set", "question": "The book name \"The Season: A Candid Look at Broadway\" was published by which publisher?", "evidence": "\"The Season: A Candid Look at Broadway\" is the  title of the book; publisher refers to publisher_name", "SQL": "SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Season: A Candid Look at Broadway'"} {"question_id": 6080, "db_id": "books", "grading_method": "set", "question": "Name the title of the book with the most number of pages that was published from 1990 to 2000 by publisher Free Press.", "evidence": "books with the most number of pages refers to Max(num_pages); published from 1990 to 2000 refers to SUBSTR(publication_date, 1, 4) BETWEEN '1990' AND '2000'; 'Free Press' is the publisher_name", "SQL": "SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Free Press' AND STRFTIME('%Y', T1.publication_date) BETWEEN '1990' AND '2000' ORDER BY T1.num_pages DESC LIMIT 1"} {"question_id": 6082, "db_id": "books", "grading_method": "set", "question": "What is the current address of customer Kandy?", "evidence": "current address refers to address_status = 1; address refers to street_number, street_name, city", "SQL": "SELECT a.street_number,\n a.street_name,\n a.city\nFROM customer AS c\nJOIN customer_address AS ca ON ca.customer_id = c.customer_id\nJOIN address AS a ON a.address_id = ca.address_id\nWHERE c.first_name = 'Kandy'\n AND ca.status_id = 1"} {"question_id": 6083, "db_id": "books", "grading_method": "set", "question": "How many books were ordered by customer Kandy Adamec?", "evidence": "", "SQL": "SELECT COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Kandy' AND T3.last_name = 'Adamec'"} {"question_id": 6085, "db_id": "books", "grading_method": "set", "question": "Which country does the customer with the email \"rturbitt2@geocities.jp\" from?", "evidence": "\"rturbitt2@geocities.jp\" is the email of customer; country refers to country_name", "SQL": "SELECT T4.`country_name`\nFROM `customer` AS T1\nJOIN `customer_address` AS T2 ON T1.`customer_id` = T2.`customer_id`\nJOIN `address` AS T3 ON T3.`address_id` = T2.`address_id`\nJOIN `country` AS T4 ON T4.`country_id` = T3.`country_id`\nWHERE T1.`email` = 'rturbitt2@geocities.jp'\n AND T2.`status_id` = 1;"} {"question_id": 6096, "db_id": "books", "grading_method": "set", "question": "What is the number of pages of the book in the order ID 1167?", "evidence": "number of pages refers to num_pages", "SQL": "SELECT T1.num_pages FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T2.order_id = 1167"} {"question_id": 6097, "db_id": "books", "grading_method": "set", "question": "Provide the title of the books published in British-English.", "evidence": "\"British English\" is the language_name of the book", "SQL": "SELECT DISTINCT T1.title FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'British English'"} {"question_id": 6102, "db_id": "books", "grading_method": "set", "question": "Provide the email addresses of customers who purchased books priced from 3 to 5 dollars.", "evidence": "The purchase price is recorded in order_line.price; customer.email records the customer’s email address.", "SQL": "SELECT DISTINCT T3.email FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T1.price BETWEEN 3 AND 5"} {"question_id": 6108, "db_id": "books", "grading_method": "set", "question": "Among the book order lines purchased by less than 1 dollar, what is the difference between the number of books with less than 500 pages and books with greater than 500 pages?", "evidence": "book purchased by less than 1 dollar refers to price < 1; books with less than 500 pages refers to num_pages < 500; greater than 500 pages refers to num_pages > 500; Difference = Subtract (Count(book_id where num_pages < 500), Count(book_id where num_pages > 500))", "SQL": "SELECT SUM(CASE WHEN T1.num_pages < 500 THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.num_pages > 500 THEN 1 ELSE 0 END) AS dif FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T2.price < 1"} {"question_id": 6112, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many inspections were sanitarian Joshua Rosa responsible for in 2010?", "evidence": "in 2010 refers to inspection_date like '2010%'", "SQL": "SELECT COUNT(T2.inspection_id) FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE strftime('%Y', T2.inspection_date) = '2010' AND T1.first_name = 'Joshua' AND T1.last_name = 'Rosa'"} {"question_id": 6113, "db_id": "food_inspection_2", "grading_method": "set", "question": "Please list the assumed name of all the facilities inspected by Joshua Rosa.", "evidence": "assumed name refers to dba_name", "SQL": "SELECT DISTINCT T3.dba_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id INNER JOIN establishment AS T3 ON T2.license_no = T3.license_no WHERE T1.first_name = 'Joshua' AND T1.last_name = 'Rosa'"} {"question_id": 6115, "db_id": "food_inspection_2", "grading_method": "set", "question": "Please list the location coordinates of all the facilities that had an inspection on 2010/5/11.", "evidence": "location coordinates refers to latitude, longitude; on 2010/5/11 refers to inspection_date = '2010-05-11'", "SQL": "SELECT T2.latitude, T2.longitude FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.license_no WHERE T1.inspection_date = '2010-05-11'"} {"question_id": 6117, "db_id": "food_inspection_2", "grading_method": "set", "question": "Please list the full names of all the sanitarians who have inspected the facility Burbank.", "evidence": "full name refers to first_name, last_name; the facility Burbank refers to dba_name = 'Burbank'", "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 INNER JOIN establishment AS T3 ON T2.license_no = T3.license_no WHERE T3.dba_name = 'Burbank' AND T1.title = 'Sanitarian'"} {"question_id": 6118, "db_id": "food_inspection_2", "grading_method": "set", "question": "Please list the assumed name of all the facilities that failed an inspection in 2010.", "evidence": "assumed name refers to dba_name; failed an inspection refers to results = 'Fail'; in 2010 refers to inspection_date like '2010%'", "SQL": "SELECT DISTINCT T2.dba_name FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.license_no WHERE T1.results = 'Fail' AND strftime('%Y', T1.inspection_date) = '2010'"} {"question_id": 6122, "db_id": "food_inspection_2", "grading_method": "set", "question": "Among the facilities that had undergone at least one inspection in 2010, how many of them have the most serious food safety issues?", "evidence": "in 2010 refers to inspection_date like '2010%'; the most serious food safety issues refers to risk_level = 3", "SQL": "SELECT COUNT(DISTINCT T2.license_no) FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y', T1.inspection_date) = '2010' AND T2.risk_level = 3"} {"question_id": 6136, "db_id": "food_inspection_2", "grading_method": "set", "question": "State the salary of the employee who did the most inspections.", "evidence": "the most inspections refers to max(count(employee_id))", "SQL": "WITH sub as (SELECT T.employee_id, COUNT(T.inspection_id) as num FROM inspection AS T GROUP BY T.employee_id ),\nmax_inspection as (\nSELECT employee_id from sub where num = (SELECT max(num) from sub)\n)\nSELECT T1.salary FROM employee AS T1 INNER JOIN max_inspection AS T2 ON T1.employee_id = T2.employee_id"} {"question_id": 6137, "db_id": "food_inspection_2", "grading_method": "set", "question": "What was the average number of inspections for risk-level-3 taverns?", "evidence": "risk-level-3 taverns refers to establishment.facility_type = 'TAVERN' with establishment.risk_level = 3; a tavern's inspections refers to COUNT(inspection_id) for its license_no; the average number of inspections refers to AVG of those per-tavern counts, one count for each such tavern", "SQL": "SELECT AVG(inspection_cnt) AS avg_inspections_per_tavern FROM ( SELECT e.`license_no`, COUNT(i.`inspection_id`) AS inspection_cnt FROM `establishment` AS e LEFT JOIN `inspection` AS i ON e.`license_no` = i.`license_no` WHERE e.`risk_level` = 3 AND e.`facility_type` = 'TAVERN' GROUP BY e.`license_no` )"} {"question_id": 6138, "db_id": "food_inspection_2", "grading_method": "set", "question": "State the inspection pass rate of Pockets Restaurant.", "evidence": "Pockets refers to dba_name = 'POCKETS'; Restaurant refers to facility_type = 'Restaurant'; pass refers to results = 'Pass'; the inspection pass rate = divide(sum(inspection_id where results = 'Pass') * 100, count(license_no)) where dba_name = 'POCKETS' and facility_type = 'Restaurant'", "SQL": "SELECT CAST(COUNT(CASE WHEN T2.results = 'Pass' THEN T2.inspection_id ELSE NULL END) AS REAL) * 100 / COUNT(T2.inspection_id) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.dba_name = 'POCKETS' AND T1.facility_type = 'Restaurant'"} {"question_id": 6140, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the assumed name of the business located at 2903 W Irving Park Rd?", "evidence": "assumed name refers to dba_name; 2903 W Irving Park Rd refers to address = '2903 W IRVING PARK RD '", "SQL": "SELECT DISTINCT dba_name FROM establishment WHERE address = '2903 W IRVING PARK RD '"} {"question_id": 6141, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the first and last name of the employee with the lowest salary?", "evidence": "full name refers to first_name, last_name; the lowest salary refers to min(salary)", "SQL": "SELECT first_name, last_name FROM employee ORDER BY salary ASC LIMIT 1"} {"question_id": 6145, "db_id": "food_inspection_2", "grading_method": "set", "question": "When was Renaldi’s Pizza first inspected?", "evidence": "Renaldi's Pizza refers to establishment.dba_name = 'RENALDI''S PIZZA'; first inspected refers to MIN(inspection.inspection_date), the minimum YYYY-MM-DD inspection_date over that establishment's inspection rows", "SQL": "SELECT MIN(T2.inspection_date) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.dba_name = 'RENALDI''S PIZZA'"} {"question_id": 6146, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the full name of the employee who was responsible for the most inspection in March 2016?", "evidence": "full name refers to first_name, last_name; the most inspection refers to max(count(employee_id)); in March 2016 refers to inspection_date like '2016-03%'", "SQL": "SELECT T3.first_name, T3.last_name FROM ( SELECT T1.employee_id, COUNT(T1.inspection_id) FROM inspection AS T1 WHERE strftime('%Y-%m', T1.inspection_date) = '2016-03' GROUP BY T1.employee_id ORDER BY COUNT(T1.inspection_id) DESC LIMIT 1 ) AS T2 INNER JOIN employee AS T3 ON T2.employee_id = T3.employee_id"} {"question_id": 6148, "db_id": "food_inspection_2", "grading_method": "set", "question": "Out of all the short form complaint inspections done by David Hodges, how many businesses passed at least once?", "evidence": "short form complaint inspection refers to inspection_type = 'Short Form Complaint'; pass refers to results = 'Pass'", "SQL": "SELECT COUNT(DISTINCT T2.license_no) FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T1.first_name = 'David' AND T1.last_name = 'Hodges' AND T2.inspection_type = 'Short Form Complaint' AND T2.results = 'Pass'"} {"question_id": 6149, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many businesses from ward 42 have at least 5 failed inspection results between 1/1/2010 to 12/31/2015?", "evidence": "ward 42 refers to ward = 42; at least 5 failed inspection results refers to count(results = 'Fail') > = 5; between 1/1/2010 to 12/31/2015 refers to inspection_date between '2010-01-01' and '2015-12-31'", "SQL": "SELECT COUNT(*)\nFROM (\n SELECT e.`license_no`\n FROM `establishment` e\n JOIN `inspection` i ON i.`license_no` = e.`license_no`\n WHERE e.`ward` = 42\n AND i.`inspection_date` BETWEEN '2010-01-01' AND '2015-12-31'\n AND i.`results` = 'Fail'\n GROUP BY e.`license_no`\n HAVING COUNT(*) >= 5\n) sub;"} {"question_id": 6151, "db_id": "food_inspection_2", "grading_method": "set", "question": "Which business establishments received the highest total fines across their inspections in 2014? List their trading names, including ties.", "evidence": "in 2014 refers to inspection.inspection_date >= '2014-01-01' AND < '2015-01-01'; total fines refers to SUM(violation.fine) over an establishment's 2014 inspections, grouped by establishment.license_no; the highest refers to the MAX of those totals; return the dba_name of every establishment tied at that maximum", "SQL": "WITH totals AS (\n SELECT e.license_no, e.dba_name, SUM(v.fine) AS total_fine\n FROM establishment AS e\n JOIN inspection AS i ON i.license_no = e.license_no\n JOIN violation AS v ON v.inspection_id = i.inspection_id\n WHERE i.inspection_date >= '2014-01-01'\n AND i.inspection_date < '2015-01-01'\n GROUP BY e.license_no, e.dba_name\n)\nSELECT DISTINCT dba_name FROM totals\nWHERE total_fine = (SELECT MAX(total_fine) FROM totals);"} {"question_id": 6153, "db_id": "food_inspection_2", "grading_method": "set", "question": "What are the comments of the inspector during the inspection of Taqueria La Fiesta on 1/25/2010?", "evidence": "comment of the inspector refers to inspector_comment; Taqueria La Fiesta refers to dba_name = 'TAQUERIA LA FIESTA'; on 1/25/2010 refers to inspection_date = '2010-01-25'", "SQL": "SELECT T3.inspector_comment FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T2.inspection_date = '2010-01-25' AND T1.dba_name = 'TAQUERIA LA FIESTA'"} {"question_id": 6154, "db_id": "food_inspection_2", "grading_method": "set", "question": "How much is the total fine given to Ron of Japan Inc in its inspection done on February 2014?", "evidence": "total fine = sum(fine); Ron of Japan Inc refers to dba_name = 'RON OF JAPAN INC'; on February 2014 refers to inspection_date like '2014-02%'", "SQL": "SELECT SUM(T3.fine) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE strftime('%Y-%m', T2.inspection_date) = '2014-02' AND T1.dba_name = 'RON OF JAPAN INC'"} {"question_id": 6156, "db_id": "food_inspection_2", "grading_method": "set", "question": "Which employees had the highest total fines across all their inspections? Give their first and last names.", "evidence": "an employee's total fines refers to SUM(violation.fine) summed across the violations linked to that employee's inspections; the highest refers to the employees whose total equals the MAX of those per-employee totals, so every employee tied at that maximum qualifies; return their first_name and last_name", "SQL": "SELECT e.`first_name`, e.`last_name` FROM employee AS e WHERE e.`employee_id` in ( SELECT i.`employee_id` FROM inspection AS i JOIN violation AS v ON v.`inspection_id` = i.`inspection_id` GROUP BY i.`employee_id` HAVING SUM(v.fine) = ( SELECT MAX(TotalFines) FROM ( SELECT i2.`employee_id`, SUM(v2.fine) AS TotalFines FROM inspection AS i2 JOIN violation AS v2 ON v2.`inspection_id` = i2.`inspection_id` GROUP BY i2.`employee_id` ) AS EmployeeFines ) );"} {"question_id": 6161, "db_id": "food_inspection_2", "grading_method": "set", "question": "Give the address of the schools that passed the inspection in March 2010.", "evidence": "school refers to facility_type = 'School'; pass refers to results = 'Pass'; in March 2010 refers to inspection_date like '2010-03%'", "SQL": "SELECT DISTINCT T1.address FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y-%m', T2.inspection_date) = '2010-03' AND T2.results = 'Pass' AND T1.facility_type = 'School'"} {"question_id": 6163, "db_id": "food_inspection_2", "grading_method": "set", "question": "List the inspection IDs for the establishment named \"PIZZA RUSTICA, INC.\"", "evidence": "The establishment is stored as establishment.dba_name = 'PIZZA RUSTICA, INC', without a trailing period.", "SQL": "SELECT DISTINCT T2.inspection_id FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.dba_name = 'PIZZA RUSTICA, INC'"} {"question_id": 6164, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many restaurants with the highest risk level still passed at least one inspection?", "evidence": "restaurant refers to facility_type = 'Restaurant'; the highest risk level refers to max(risk_level); pass the inspection refers to results = 'Pass'", "SQL": "SELECT COUNT(DISTINCT e.`license_no`)\nFROM `establishment` AS e\nJOIN `inspection` AS i ON e.`license_no` = i.`license_no`\nWHERE e.`risk_level` = (SELECT MAX(`risk_level`) FROM `establishment`)\n AND i.`results` IN ('Pass')\n AND e.`facility_type` = 'Restaurant';"} {"question_id": 6165, "db_id": "food_inspection_2", "grading_method": "set", "question": "List the names of employees involved in an inspection with the Display of Inspection Report Summary category.", "evidence": "name refers to first_name, last_name; Display of Inspection Report Summary category refers to category = 'Display of Inspection Report Summary'", "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 INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id INNER JOIN inspection_point AS T4 ON T3.point_id = T4.point_id WHERE T4.category = 'Display of Inspection Report Summary'"} {"question_id": 6167, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many restaurants with recorded risk level 1 have failed a complaint inspection?", "evidence": "restaurants refers to establishment.facility_type = 'Restaurant'; recorded risk level 1 refers to establishment.risk_level = '1'; failed a complaint inspection refers to inspection.inspection_type = 'Complaint' with inspection.results = 'Fail'; how many restaurants refers to COUNT(DISTINCT establishment), each establishment counted only one time", "SQL": "SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.risk_level = '1' AND T2.inspection_type = 'Complaint' AND T1.facility_type = 'Restaurant' AND T2.results = 'Fail'"} {"question_id": 6168, "db_id": "food_inspection_2", "grading_method": "set", "question": "Provide the fine paid and the complete address of the establishment with inspection ID 48216.", "evidence": "complete address refers to state, city, address", "SQL": "SELECT\n SUM(v.`fine`) AS total_fine,\n e.`address`,\n e.`city`,\n e.`state`\nFROM `inspection` i\nJOIN `establishment` e ON i.`license_no` = e.`license_no`\nJOIN `violation` v ON i.`inspection_id` = v.`inspection_id`\nWHERE i.`inspection_id` = 48216\nGROUP BY e.`address`, e.`city`, e.`state`, e.`zip`;"} {"question_id": 6169, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the inspection ID of the inspection with critical point level, $500 fine, and inspector comment \"CDI ON 5-17-10\"?", "evidence": "critical point level refers to point_level = 'Critical'; $500 fine refers to fine = 500; inspector comment \"CDI ON 5-17-10\" refers to inspector_comment = 'CDI ON 5-17-10'", "SQL": "SELECT T2.inspection_id FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.fine = 500 AND T1.point_level = 'Critical' AND T2.inspector_comment = 'CDI ON 5-17-10'"} {"question_id": 6173, "db_id": "food_inspection_2", "grading_method": "set", "question": "Among employees earning between $75,000 and $85,000, what is the difference between the numbers who had an inspection with a $100 fine and a $500 fine?", "evidence": "salary between $75,000 and $85,000 refers to employee.salary BETWEEN 75000 AND 85000; a fine refers to violation.fine on an inspection linked by inspection.employee_id; answer = SUBTRACT(COUNT(DISTINCT employees with at least one fine = 100), COUNT(DISTINCT employees with at least one fine = 500))", "SQL": "SELECT\n SUM(CASE WHEN fine_100 = 1 THEN 1 ELSE 0 END) -\n SUM(CASE WHEN fine_500 = 1 THEN 1 ELSE 0 END) AS diff\nFROM (\n SELECT e.`employee_id`,\n MAX(CASE WHEN v.`fine` = 100 THEN 1 ELSE 0 END) AS fine_100,\n MAX(CASE WHEN v.`fine` = 500 THEN 1 ELSE 0 END) AS fine_500\n FROM `employee` e\n JOIN `inspection` i ON e.`employee_id` = i.`employee_id`\n JOIN `violation` v ON i.`inspection_id` = v.`inspection_id`\n WHERE e.`salary` BETWEEN 75000 AND 85000\n GROUP BY e.`employee_id`\n) sub;"} {"question_id": 6175, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many inspections failed in 2014?", "evidence": "failed refers to results = 'Fail'; in 2014 refers to inspection_date like '2014%'", "SQL": "SELECT COUNT(inspection_id) FROM inspection WHERE strftime('%Y', inspection_date) = '2014' AND results = 'Fail'"} {"question_id": 6177, "db_id": "food_inspection_2", "grading_method": "set", "question": "List the point IDs and fines of the inspections done on 7th August 2010.", "evidence": "on 7th August 2010 refers to inspection_date = '2010-08-07'", "SQL": "SELECT T2.point_id, T2.fine FROM inspection AS T1 INNER JOIN violation AS T2 ON T1.inspection_id = T2.inspection_id WHERE T1.inspection_date = '2010-08-07'"} {"question_id": 6178, "db_id": "food_inspection_2", "grading_method": "set", "question": "How many inspections were done under the personnel category?", "evidence": "under the personnel category refers to category = 'Personnel'", "SQL": "SELECT COUNT(DISTINCT T1.inspection_id) FROM violation AS T1 INNER JOIN inspection_point AS T2 ON T1.point_id = T2.point_id WHERE T2.category = 'Personnel'"} {"question_id": 6182, "db_id": "food_inspection_2", "grading_method": "set", "question": "Provide the distinct categories and fines for the inspections done by Lisa Tillman in January 2014.", "evidence": "in January 2014 refers to inspection_date like '2014-01%'", "SQL": "SELECT DISTINCT T4.category, T3.fine FROM inspection AS T1 INNER JOIN employee AS T2 ON T1.employee_id = T2.employee_id INNER JOIN violation AS T3 ON T1.inspection_id = T3.inspection_id INNER JOIN inspection_point AS T4 ON T3.point_id = T4.point_id WHERE T2.first_name = 'Lisa' AND T2.last_name = 'Tillman' AND strftime('%Y-%m', T1.inspection_date) = '2014-01'"} {"question_id": 6185, "db_id": "food_inspection_2", "grading_method": "set", "question": "Who inspected Jean Samocki and what was the result?", "evidence": "employee's name refers to first_name, last_name; Jean Samocki refers to dba_name = 'JEAN SAMOCKI'", "SQL": "SELECT T3.first_name, T3.last_name, T2.results 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 T1.dba_name = 'JEAN SAMOCKI'"} {"question_id": 6207, "db_id": "food_inspection_2", "grading_method": "set", "question": "What are the full names of all the employees that inspected establishments with license 1334073?", "evidence": "full name refers to first_name, last_name; with license 1334073 refers to license_no = 1334073", "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.license_no = 1334073"} {"question_id": 6221, "db_id": "food_inspection_2", "grading_method": "set", "question": "How much salary does Jessica Anthony receive?", "evidence": "", "SQL": "SELECT salary FROM employee WHERE first_name = 'Jessica' AND last_name = 'Anthony'"} {"question_id": 6226, "db_id": "food_inspection_2", "grading_method": "set", "question": "What is the total number of establishments with the highest risk level?", "evidence": "total number of establishments with the highest risk level = count(max(risk_level))", "SQL": "SELECT COUNT(*)\nFROM establishment\nWHERE risk_level = (SELECT MAX(risk_level) FROM establishment);"} {"question_id": 6240, "db_id": "food_inspection_2", "grading_method": "set", "question": "Which Personnel inspections have the following inspector’s comment, treating multiple consecutive spaces as a single space? List their inspection IDs.\n\n“A certified food service manager must be present in all establishments at which potentially hazardous food is prepared or served. NO CERTIFIED FOOD MANAGER ON DUTY AT THIS TIME FOODS ARE COOKED AND SERVED SERIOUS CITATION ISSUED”", "evidence": "Inspector comments are recorded in violation.inspector_comment; inspection_point.category uses 'Personnel'. Repeated spaces are insignificant when matching the quoted comment.", "SQL": "WITH RECURSIVE normalized_comments(inspection_id, comment) AS (\n SELECT v.inspection_id, v.inspector_comment\n FROM violation AS v\n JOIN inspection_point AS p ON v.point_id = p.point_id\n WHERE p.category = 'Personnel'\n UNION ALL\n SELECT inspection_id, REPLACE(comment, ' ', ' ')\n FROM normalized_comments\n WHERE INSTR(comment, ' ') > 0\n)\nSELECT DISTINCT inspection_id\nFROM normalized_comments\nWHERE comment = 'A certified food service manager must be present in all establishments at which potentially hazardous food is prepared or served. NO CERTIFIED FOOD MANAGER ON DUTY AT THIS TIME FOODS ARE COOKED AND SERVED SERIOUS CITATION ISSUED';"} {"question_id": 6251, "db_id": "coinmarketcap", "grading_method": "set", "question": "List the price for Zetacoin from 13/11/1 to 13/11/7.", "evidence": "on 13/11/1 and the next 7 consecutive days refers to DATE BETWEEN '2013-11-01' AND '2013-11-07'; Zetacoin refers to name = 'Zetacoin'", "SQL": "SELECT T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Zetacoin' AND T2.date BETWEEN '2013-11-01' AND '2013-11-07'"} {"question_id": 6252, "db_id": "coinmarketcap", "grading_method": "set", "question": "For WARP records in August 2016, list the times when the highest and lowest prices were reached.", "evidence": "historical.time_high and historical.time_low record when each dated record’s highest and lowest prices occurred, as HH:MM:SS. historical.date uses YYYY-MM-DD.", "SQL": "SELECT T2.time_high, T2.time_low FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'WARP' AND STRFTIME('%Y-%m', T2.date) = '2016-08'"} {"question_id": 6260, "db_id": "coinmarketcap", "grading_method": "set", "question": "Which coins had the largest one-hour percentage price decline, and on what dates?", "evidence": "historical.percent_change_1h is the percentage price change from one hour earlier; negative values indicate declines.", "SQL": "SELECT T1.name, T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.percent_change_1h = ( SELECT MIN(percent_change_1h) FROM historical )"} {"question_id": 6263, "db_id": "coinmarketcap", "grading_method": "set", "question": "Which cryptocurrency ranked first on CoinMarketCap on 2013/4/28?", "evidence": "Coin name is coins.name. Historical CoinMarketCap rank is historical.cmc_rank; first place is 1. Historical date is historical.date, and 2013/4/28 is stored as '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.cmc_rank = 1"} {"question_id": 6264, "db_id": "coinmarketcap", "grading_method": "set", "question": "How much dollars was a Bitcoin worth on 2013/4/28 according to the coin market?", "evidence": "worth refers to price; on 2013/4/28 refers to date = '2013-04-28'", "SQL": "SELECT T2.`price`\nFROM `coins` AS T1\nJOIN `historical` AS T2 ON T1.`id` = T2.`coin_id`\nWHERE T1.`name` = 'Bitcoin'\n AND T2.`date` = '2013-04-28';"} {"question_id": 6266, "db_id": "coinmarketcap", "grading_method": "set", "question": "What was the price of Bitcoin when it closed at the end of the day on 2013/4/29?", "evidence": "price when it closed refers to close; on 2013/4/29 refers to date = '2013-04-29'", "SQL": "SELECT T2.close FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T1.name = 'Bitcoin'"} {"question_id": 6273, "db_id": "coinmarketcap", "grading_method": "set", "question": "On 2013/4/28, which had more coins in circulation, Bitcoin or Litecoin?", "evidence": "on 2013/4/28 refers to historical.date = '2013-04-28'; the two compared coins refer to coins.name IN ('Bitcoin', 'Litecoin'); more coins in circulation refers to the greater historical.circulating_supply on that date; return the coins.name with the greater circulating_supply", "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 T1.name IN ('Bitcoin', 'Litecoin') ORDER BY T2.circulating_supply DESC LIMIT 1"} {"question_id": 6275, "db_id": "coinmarketcap", "grading_method": "set", "question": "What was the average price of a Bitcoin in the year 2013?", "evidence": "average price refers SUM(price)/COUNT(named = 'Bitcoin'); in the year 2013 refers to year(date) = 2013", "SQL": "SELECT AVG(T2.price) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE STRFTIME('%Y', T2.date) = '2013' AND T1.name = 'Bitcoin'"} {"question_id": 6277, "db_id": "coinmarketcap", "grading_method": "set", "question": "Please list the names of coins that have disappeared.", "evidence": "A coin’s status is coins.status; disappeared coins are stored with status 'extinct'. Coin name is coins.name.", "SQL": "SELECT name FROM coins WHERE status = 'extinct'"} {"question_id": 6284, "db_id": "coinmarketcap", "grading_method": "set", "question": "Please name the coin that ranked first among the coins traded on April 29, 2013.", "evidence": "ranked first refers to cmc_rank = 1; on April 29, 2013 refers to date = '2013-04-29'", "SQL": "SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T2.cmc_rank = 1"} {"question_id": 6286, "db_id": "coinmarketcap", "grading_method": "set", "question": "What is the name of the coin that has traded the highest total value in the past 24 hours on any day in history?", "evidence": "trades the most total value in the past 24 hours refers to max(volume_24h)", "SQL": "SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.volume_24h = ( SELECT MAX(volume_24h) FROM historical )"} {"question_id": 6291, "db_id": "coinmarketcap", "grading_method": "set", "question": "List the names of the top five coins traded on January 1, 2014.", "evidence": "the top five coins refers to cmc_rank< = 5; on January 1, 2014 refers to date = '2014-01-01'", "SQL": "SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2014-01-01' AND T2.cmc_rank <= 5"} {"question_id": 6294, "db_id": "coinmarketcap", "grading_method": "set", "question": "What was the total value of Dogecoin traded in June 2021?", "evidence": "in June 2021 refers to year(date) = 2021 AND month(date) = 6", "SQL": "SELECT SUM(volume_24h) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Dogecoin' AND STRFTIME('%Y-%m', T2.date) = '2021-06'"} {"question_id": 6296, "db_id": "coinmarketcap", "grading_method": "set", "question": "Which coins showed a one-hour price increase on May 29, 2013? List their names.", "evidence": "historical.percent_change_1h is the percentage change from one hour earlier. historical.date uses YYYY-MM-DD.", "SQL": "SELECT T1.NAME FROM coins AS T1 INNER JOIN historical AS T2 ON T1.ID = T2.coin_id WHERE T2.DATE = '2013-05-29' AND T2.percent_change_1h > 0"} {"question_id": 6315, "db_id": "retail_world", "grading_method": "set", "question": "Please list the names of all the products ordered in order no. 10248.", "evidence": "names of the products refers to ProductName; order no. refers to OrderID;", "SQL": "SELECT DISTINCT `P`.`ProductName`\nFROM `Products` AS `P`\nJOIN `OrderDetails` AS `OD` ON `P`.`ProductID` = `OD`.`ProductID`\nWHERE `OD`.`OrderID` = 10248;"} {"question_id": 6334, "db_id": "retail_world", "grading_method": "set", "question": "Provide the number of orders that were handled by Michael Suyama.", "evidence": "", "SQL": "SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama'"} {"question_id": 6341, "db_id": "retail_world", "grading_method": "set", "question": "Tell the name of the shipper company for the order No.10385.", "evidence": "name of the shipper company refers to ShipName; order No. refers to OrderID;", "SQL": "SELECT s.`ShipperName`\nFROM `Orders` AS o\nJOIN `Shippers` AS s ON o.`ShipperID` = s.`ShipperID`\nWHERE o.`OrderID` = 10385;"} {"question_id": 6359, "db_id": "retail_world", "grading_method": "set", "question": "How many suppliers are there in the United States of America?", "evidence": "United States of America refers to Country = 'USA'", "SQL": "SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'USA'"} {"question_id": 6364, "db_id": "retail_world", "grading_method": "set", "question": "Which shippers handled the most orders for customers in the USA? Give all tied shipper names.", "evidence": "customers in the USA refers to Customers.Country = 'USA'; a shipper refers to Shippers.ShipperName joined via Orders.ShipperID; handled the most orders refers to the greatest COUNT(*) of those orders per ShipperName; return every ShipperName tied at that maximum", "SQL": "SELECT S.`ShipperName` FROM `Orders` O JOIN `Customers` C ON O.`CustomerID` = C.`CustomerID` JOIN `Shippers` S ON O.`ShipperID` = S.`ShipperID` WHERE C.`Country` = 'USA' GROUP BY S.`ShipperName` HAVING COUNT(*) = ( SELECT MAX(TotalOrders) FROM ( SELECT S2.`ShipperName`, COUNT(*) AS TotalOrders FROM `Orders` O2 JOIN `Customers` C2 ON O2.`CustomerID` = C2.`CustomerID` JOIN `Shippers` S2 ON O2.`ShipperID` = S2.`ShipperID` WHERE C2.`Country` = 'USA' GROUP BY S2.`ShipperName` ) AS ShipperOrderCounts );"} {"question_id": 6365, "db_id": "retail_world", "grading_method": "set", "question": "How many products were supplied by Pavlova, Ltd.?", "evidence": "Pavlova, Ltd. refers to SupplierName = 'Pavlova, Ltd.'", "SQL": "SELECT COUNT(*)\nFROM `Products` AS P\nJOIN `Suppliers` AS S ON P.`SupplierID` = S.`SupplierID`\nWHERE S.`SupplierName` = 'Pavlova, Ltd.';"} {"question_id": 6371, "db_id": "retail_world", "grading_method": "set", "question": "Which supplier supplies the most distinct products?", "evidence": "a supplier's products refers to the Products rows carrying that Suppliers.SupplierID, one row per product; supplies the most distinct products refers to the supplier whose COUNT of those products equals the maximum over all suppliers, keeping ties; return Suppliers.SupplierName", "SQL": "SELECT S.`SupplierName`\nFROM `Suppliers` AS S\nJOIN `Products` AS P ON S.`SupplierID` = P.`SupplierID`\nGROUP BY S.`SupplierID`\nHAVING COUNT(*) = (\n SELECT MAX(cnt)\n FROM (SELECT COUNT(*) AS cnt\n FROM `Products`\n GROUP BY `SupplierID`)\n);"} {"question_id": 6385, "db_id": "retail_world", "grading_method": "set", "question": "Find and list the name, contact name, and address of customers from Madrid.", "evidence": "from Madrid refers to City = 'Madrid'", "SQL": "SELECT `CustomerName` ,\n `ContactName`, Address\nFROM `Customers`\nWHERE `City` = 'Madrid';"} {"question_id": 6393, "db_id": "retail_world", "grading_method": "set", "question": "List the top five most costly products in 1997.", "evidence": "most costly refers to max(unit price); in 1997 refers to OrderDate > = '1997-01-01 00:00:00' AND OrderDate < '1998-01-01 00:00:00'", "SQL": "SELECT DISTINCT `p`.`ProductName`\nFROM `Products` AS `p`\nJOIN `OrderDetails` AS `od` ON `od`.`ProductID` = `p`.`ProductID`\nJOIN `Orders` AS `o` ON `o`.`OrderID` = `od`.`OrderID`\nWHERE `o`.`OrderDate` >= '1997-01-01' AND `o`.`OrderDate` < '1998-01-01'\nORDER BY `p`.`Price` DESC\nLIMIT 5;"} {"question_id": 6403, "db_id": "retail_world", "grading_method": "set", "question": "What is the highest total price paid for an order?", "evidence": "an order's total price refers to SUM(MULTIPLY(Products.Price, OrderDetails.Quantity)) over the OrderDetails records sharing that OrderID, each priced by its own product's Products.Price; the highest total price paid for an order refers to the MAX of those per-order totals", "SQL": "SELECT MAX(order_total) AS highest_total\nFROM (\n SELECT od.`OrderID`, SUM(p.`Price` * od.`Quantity`) AS order_total\n FROM `OrderDetails` od\n JOIN `Products` p ON od.`ProductID` = p.`ProductID`\n GROUP BY od.`OrderID`\n) t;"} {"question_id": 6413, "db_id": "retail_world", "grading_method": "set", "question": "What product is the least shipped to the postal code 28023?", "evidence": "the least shipped product refers ProductName where MIN(SUM(Quantity));", "SQL": "SELECT p.`ProductName`\nFROM `Customers` c\nJOIN `Orders` o ON c.`CustomerID` = o.`CustomerID`\nJOIN `OrderDetails` od ON o.`OrderID` = od.`OrderID`\nJOIN `Products` p ON od.`ProductID` = p.`ProductID`\nWHERE c.`PostalCode` = '28023'\nGROUP BY p.`ProductID`\nORDER BY SUM(od.`Quantity`) ASC\nLIMIT 1;"} {"question_id": 6428, "db_id": "retail_world", "grading_method": "subset,=,3", "question": "Please list any three order numbers that have been shipped using Speedy Express.", "evidence": "Speedy Express is the name of the shipping company; three order numbers refer to OrderID LIMIT 3;", "SQL": "SELECT O.`OrderID` FROM `Orders` AS O JOIN `Shippers` AS S ON O.`ShipperID` = S.`ShipperID` WHERE S.`ShipperName` = 'Speedy Express'"} {"question_id": 6451, "db_id": "retail_world", "grading_method": "set", "question": "List all the products that were shipped to Grenzacherweg 237.", "evidence": "products shipped to Grenzacherweg 237 refer to ProductName where Customers.Address = 'Grenzacherweg 237';", "SQL": "SELECT DISTINCT p.`ProductName`\nFROM `Orders` o\nJOIN `Customers` c ON o.`CustomerID` = c.`CustomerID`\nJOIN `OrderDetails` od ON o.`OrderID` = od.`OrderID`\nJOIN `Products` p ON od.`ProductID` = p.`ProductID`\nWHERE c.`Address` = 'Grenzacherweg 237';"} {"question_id": 6465, "db_id": "retail_world", "grading_method": "set", "question": "What are the product names of Exotic Liquid?", "evidence": "\"Exotic Liquids\" is the SupplierName", "SQL": "SELECT `ProductName` FROM `Products` AS p JOIN `Suppliers` AS s ON p.`SupplierID` = s.`SupplierID` WHERE s.`SupplierName` = 'Exotic Liquid'"} {"question_id": 6472, "db_id": "retail_world", "grading_method": "set", "question": "What are the supplier contact names for products packaged as 10 boxes x 12 pieces?", "evidence": "Products.Unit stores packaging descriptions such as '10 boxes x 12 pieces'. Suppliers.ContactName is the contact person, not the company name.", "SQL": "SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Unit = '10 boxes x 12 pieces'"} {"question_id": 6475, "db_id": "retail_world", "grading_method": "set", "question": "List the IDs of the five products with the highest quantities ordered, in descending order.", "evidence": "quantities ordered for a product refers to SUM(OrderDetails.Quantity) grouped by OrderDetails.ProductID; the five with the highest refers to ordering those totals in descending order and taking 5; list only the ProductID values in that order", "SQL": "SELECT `ProductID` FROM `OrderDetails` GROUP BY `ProductID` ORDER BY SUM(`Quantity`) DESC LIMIT 5"} {"question_id": 6482, "db_id": "retail_world", "grading_method": "set", "question": "How many distinct seafood products have an order line with a quantity greater than 50?", "evidence": "OrderDetails.Quantity is the quantity on an individual order line.", "SQL": "SELECT COUNT(DISTINCT p.`ProductID`) FROM `OrderDetails` od JOIN `Products` p ON p.`ProductID` = od.`ProductID` JOIN `Categories` c ON c.`CategoryID` = p.`CategoryID` WHERE c.`CategoryName` = 'Seafood' AND od.`Quantity` > 50"} {"question_id": 6483, "db_id": "retail_world", "grading_method": "set", "question": "List the products whose supplier is 'Pavlova, Ltd.' Please include the product name and ID.", "evidence": "\"Pavlova, Ltd.\" is the SupplierName; products refers to ProductName", "SQL": "SELECT p.ProductName, p.`ProductID`\nFROM `Products` AS p\nJOIN `Suppliers` AS s ON p.`SupplierID` = s.`SupplierID`\nWHERE s.`SupplierName` = 'Pavlova, Ltd.';"} {"question_id": 6503, "db_id": "retail_world", "grading_method": "set", "question": "List the first and last names of all employees.", "evidence": "First and last names are recorded in FirstName and LastName, respectively.", "SQL": "SELECT FirstName, LastName FROM Employees"} {"question_id": 6516, "db_id": "retail_world", "grading_method": "set", "question": "In August of 1996, how many orders were placed by the customer with the highest amount of orders?", "evidence": "August of 1996 refers to OrderDate LIKE '1996-08%'; highest amount of orders refers to MAX(COUNT(OrderID))", "SQL": "SELECT COUNT(OrderID) FROM Orders WHERE OrderDate LIKE '1996-08%' GROUP BY CustomerID ORDER BY COUNT(OrderID) DESC LIMIT 1"} {"question_id": 6521, "db_id": "retail_world", "grading_method": "set", "question": "How many condiments were sold in 1997?", "evidence": "\"Condiments\" is the CategoryName; in 1997 refers to year(OrderDate) = 1997;", "SQL": "SELECT SUM(od.`Quantity`) AS total_condiments_sold FROM `OrderDetails` od JOIN `Orders` o ON od.`OrderID` = o.`OrderID` JOIN `Products` p ON od.`ProductID` = p.`ProductID` JOIN `Categories` c ON p.`CategoryID` = c.`CategoryID` WHERE c.`CategoryName` = 'Condiments' AND strftime('%Y', o.`OrderDate`) = '1997'"} {"question_id": 6530, "db_id": "retail_world", "grading_method": "set", "question": "What was the total amount of sales handled by Nancy Davolio in December 1996?", "evidence": "Nancy Davolio refers to Employees.FirstName = 'Nancy' AND Employees.LastName = 'Davolio'; in December 1996 refers to an OrderDate in December 1996; total amount of sales refers to SUM(MULTIPLY(Products.Price, OrderDetails.Quantity)) over the OrderDetails of her Orders", "SQL": "SELECT SUM(p.`Price` * od.`Quantity`) AS total_sales\nFROM `Employees` e\nJOIN `Orders` o ON e.`EmployeeID` = o.`EmployeeID`\nJOIN `OrderDetails` od ON o.`OrderID` = od.`OrderID`\nJOIN `Products` p ON od.`ProductID` = p.`ProductID`\nWHERE e.`FirstName` = 'Nancy'\n AND e.`LastName` = 'Davolio'\n AND strftime('%Y', o.`OrderDate`) = '1996'\n AND strftime('%m', o.`OrderDate`) = '12';"} {"question_id": 6541, "db_id": "retail_world", "grading_method": "set", "question": "List the customer names and addresses located in London.", "evidence": "Customers.CustomerName records customer names; Customers.City uses 'London'.", "SQL": "SELECT `CustomerName`, `Address`\nFROM `Customers`\nWHERE `City` = 'London';"} {"question_id": 6543, "db_id": "retail_world", "grading_method": "set", "question": "List all the customer names and cities located in Canada.", "evidence": "located in Canada refers to Country = 'Canada'", "SQL": "SELECT `CustomerName`, `City` FROM `Customers` WHERE `Country` = 'Canada'"} {"question_id": 6547, "db_id": "retail_world", "grading_method": "set", "question": "Provide the contact person name and supplied products by \"Escargots Nouveaux\".", "evidence": "\"Escargots Nouveaux\" refers to SupplierName = 'Escargots Nouveaux';", "SQL": "SELECT s.`ContactName`, p.`ProductName`\nFROM `Suppliers` s\nJOIN `Products` p ON p.`SupplierID` = s.`SupplierID`\nWHERE s.`SupplierName` = 'Escargots Nouveaux';"} {"question_id": 6562, "db_id": "retail_world", "grading_method": "set", "question": "What is the total value of the products in order 10359?", "evidence": "the total value of the products in order 10359 refers to SUM(MULTIPLY(Products.Price, the ordered quantities)) over the products in that order, Products.Price being the unit price", "SQL": "SELECT SUM(p.`Price` * od.`Quantity`) AS total_payment\nFROM `OrderDetails` od\nJOIN `Products` p ON p.`ProductID` = od.`ProductID`\nWHERE od.`OrderID` = 10359;"} {"question_id": 6576, "db_id": "retail_world", "grading_method": "set", "question": "Name products and their quantity in the sales order that was processed by Nancy Davolio.", "evidence": "name products refers to ProductName; 'Nancy Davolio' is the full name of an employee; full name refers to FirstName, LastName;", "SQL": "SELECT p.`ProductName`, od.`Quantity` FROM `Employees` AS e JOIN `Orders` AS o ON e.`EmployeeID` = o.`EmployeeID` JOIN `Customers` AS c ON o.`CustomerID` = c.`CustomerID` JOIN `OrderDetails` AS od ON o.`OrderID` = od.`OrderID` JOIN `Products` AS p ON od.`ProductID` = p.`ProductID` WHERE e.`FirstName` = 'Nancy' AND e.`LastName` = 'Davolio'"} {"question_id": 6577, "db_id": "retail_world", "grading_method": "set", "question": "How many orders has Around the Horn placed, and what is the average order value?", "evidence": "Order value uses ordered quantities at the unit prices in Products.Price.", "SQL": "WITH order_totals AS (\n SELECT o.OrderID,\n CASE WHEN COUNT(od.OrderDetailID) = 0 THEN 0.0\n ELSE SUM(od.Quantity * p.Price)\n END AS order_value\n FROM Orders AS o\n INNER JOIN Customers AS c ON o.CustomerID = c.CustomerID\n LEFT JOIN OrderDetails AS od ON o.OrderID = od.OrderID\n LEFT JOIN Products AS p ON od.ProductID = p.ProductID\n WHERE c.CustomerName = 'Around the Horn'\n GROUP BY o.OrderID\n)\nSELECT COUNT(*) AS total_orders,\n AVG(order_value) AS average_order_value\nFROM order_totals;"} {"question_id": 6578, "db_id": "retail_world", "grading_method": "set", "question": "How many boxes of 'Pavlova' did Northwind sell?", "evidence": "'Pavlova' is a ProductName", "SQL": "SELECT SUM(`Quantity`) AS boxes_sold FROM `OrderDetails` od JOIN `Products` p ON p.`ProductID` = od.`ProductID` WHERE p.`ProductName` = 'Pavlova'"} {"question_id": 6588, "db_id": "retail_world", "grading_method": "set", "question": "How many customers are there in the city of London?", "evidence": "customers refers to CustomerName;", "SQL": "SELECT COUNT(*)\nFROM `Customers`\nWHERE `City` = 'London';"} {"question_id": 6613, "db_id": "retail_world", "grading_method": "set", "question": "Name the products where the suppliers come from Finland.", "evidence": "'Finland' is a Country; product refers to ProductName; suppliers refers to SupplierID", "SQL": "SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Finland'"} {"question_id": 6618, "db_id": "retail_world", "grading_method": "set", "question": "List the cities where the product 'Mishi Kobe Niku' were shipped to.", "evidence": "cities refers to Customers.City; 'Mishi Kobe Niku' is a ProductName", "SQL": "SELECT DISTINCT C.`City`\nFROM `OrderDetails` AS OD\nJOIN `Orders` AS O ON OD.`OrderID` = O.`OrderID`\nJOIN `Customers` AS C ON O.`CustomerID` = C.`CustomerID`\nJOIN `Products` AS P ON OD.`ProductID` = P.`ProductID`\nWHERE P.`ProductName` = 'Mishi Kobe Niku';"} {"question_id": 6629, "db_id": "retail_world", "grading_method": "set", "question": "What is the most common product ordered by a customer from Germany?", "evidence": "most common product refers to max(count(ProductID)); customer from Germany refers to Country = 'Germany'", "SQL": "SELECT p.`ProductName`\nFROM `Customers` c\nJOIN `Orders` o ON c.`CustomerID` = o.`CustomerID`\nJOIN `OrderDetails` od ON o.`OrderID` = od.`OrderID`\nJOIN `Products` p ON od.`ProductID` = p.`ProductID`\nWHERE c.`Country` = 'Germany'\nGROUP BY p.`ProductID`, p.`ProductName`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 6640, "db_id": "retail_world", "grading_method": "set", "question": "State the name of employee that manages the order from Victuailles en stock?", "evidence": "name of employee refers to FirstName, LastName; from Victuailles en stock refers to CustomerName = 'Victuailles en stock'", "SQL": "SELECT DISTINCT E.FirstName,\n E.LastName\nFROM Employees AS E\nJOIN Orders AS O ON E.EmployeeID = O.EmployeeID\nJOIN Customers AS C ON O.CustomerID = C.CustomerID\nWHERE C.CustomerName = 'Victuailles en stock';"} {"question_id": 6650, "db_id": "retail_world", "grading_method": "set", "question": "List down the supplier names which supplied products for the order on 14th August, 1996.", "evidence": "products refers to Order_Details.ProductID; on 14th August, 1996 refers to OrderDate = '8/14/1996'", "SQL": "SELECT DISTINCT S.`SupplierName` FROM `Orders` AS O JOIN `OrderDetails` AS OD ON O.`OrderID` = OD.`OrderID` JOIN `Products` AS P ON OD.`ProductID` = P.`ProductID` JOIN `Suppliers` AS S ON P.`SupplierID` = S.`SupplierID` WHERE date(O.`OrderDate`) = '1996-08-14'"} {"question_id": 6659, "db_id": "retail_world", "grading_method": "set", "question": "What are the first and last names of the employee who handled order 10270?", "evidence": "First and last names are recorded in FirstName and LastName, respectively.", "SQL": "SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10270"} {"question_id": 6661, "db_id": "retail_world", "grading_method": "set", "question": "In which country is the customer who placed order 10276 located?", "evidence": "Orders.OrderID identifies order 10276 and Orders.CustomerID links it to Customers.CustomerID. Customers.Country records the customer’s country.", "SQL": "SELECT C.`Country`\nFROM `Orders` O\nJOIN `Customers` C ON O.`CustomerID` = C.`CustomerID`\nWHERE O.`OrderID` = 10276;"} {"question_id": 6668, "db_id": "retail_world", "grading_method": "set", "question": "How many orders have been shipped through United Package?", "evidence": "United Package refers to ShipperName = 'United Package'", "SQL": "SELECT COUNT(*)\nFROM `Orders` AS o\nJOIN `Shippers` AS s ON o.`ShipperID` = s.`ShipperID`\nWHERE s.`ShipperName` = 'United Package';"} {"question_id": 6673, "db_id": "retails", "grading_method": "set", "question": "What is the comment of the order with the highest total price?", "evidence": "the highest total price refers to MAX(o_totalprice); comment of the order refers to o_comment;", "SQL": "SELECT o_comment FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders )"} {"question_id": 6696, "db_id": "retails", "grading_method": "set", "question": "For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id.", "evidence": "returned item refers to l_returnflag = 'R'; supplier id refers to l_suppkey; order with the total price of 218195.43 refers to o_totalprice = 218195.43;", "SQL": "SELECT T2.l_suppkey FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_totalprice = 218195.43 AND T2.l_returnflag = 'R'"} {"question_id": 6697, "db_id": "retails", "grading_method": "set", "question": "For the “Not Specified” order handled by Clerk#000000936 on 1995/3/13, what was the charge for the part shipped by truck?", "evidence": "'Not Specified' refers to orders.o_orderpriority = '4-NOT SPECIFIED'; handled by Clerk#000000936 on 1995/3/13 refers to o_clerk = 'Clerk#000000936' AND o_orderdate = '1995-03-13'; shipped by truck refers to lineitem.l_shipmode = 'TRUCK'; charge = SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) over those lineitem rows", "SQL": "SELECT SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS charge\nFROM orders\nJOIN lineitem ON o_orderkey = l_orderkey\nWHERE o_clerk = 'Clerk#000000936'\n AND o_orderdate = '1995-03-13'\n AND o_orderpriority = '4-NOT SPECIFIED'\n AND l_shipmode = 'TRUCK';"} {"question_id": 6704, "db_id": "retails", "grading_method": "set", "question": "What is the name of the customer with the highest amount of debt?", "evidence": "debt refers to a negative customer.c_acctbal, with more negative balances meaning larger debt; the customer with the highest amount of debt refers to the customer whose c_acctbal equals MIN(c_acctbal); return c_name", "SQL": "SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )"} {"question_id": 6708, "db_id": "retails", "grading_method": "set", "question": "How many customers are in the automobile market segment?", "evidence": "automobile market segment refers to c_mktsegment = 'AUTOMOBILE';", "SQL": "SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'AUTOMOBILE'"} {"question_id": 6710, "db_id": "retails", "grading_method": "set", "question": "List all shipment dates recorded for the order or orders with the highest total price.", "evidence": "shipment date refers to lineitem.l_shipdate; total price refers to orders.o_totalprice;", "SQL": "SELECT `l_shipdate`\nFROM `lineitem`\nWHERE `l_orderkey` in (\n SELECT `o_orderkey`\n FROM `orders`\n WHERE o_totalprice = (SELECT max(o_totalprice) from orders)\n);"} {"question_id": 6725, "db_id": "retails", "grading_method": "set", "question": "What was the order date of items with the highest total price?", "evidence": "the highest total price refers to MAX(o_totalprice);", "SQL": "SELECT o_orderdate FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders )"} {"question_id": 6727, "db_id": "retails", "grading_method": "set", "question": "How many supplier listings show a part with fewer than 10 units in stock?", "evidence": "A supplier listing represents one part stocked by one supplier. The available quantity is recorded in ps_availqty.", "SQL": "SELECT COUNT(*) FROM partsupp WHERE ps_availqty < 10"} {"question_id": 6728, "db_id": "retails", "grading_method": "set", "question": "What percentage of all parts were manufactured by Manufacturer#3?", "evidence": "manufactured by Manufacturer#3 refers to p_mfgr = 'Manufacturer#3'; percentage = DIVIDE(SUM(CASE WHEN p_mfgr = 'Manufacturer#3' THEN 1 ELSE 0 END), COUNT(*) over all part rows) * 100", "SQL": "SELECT CAST(SUM(IIF(p_mfgr = 'Manufacturer#3', 1, 0)) AS REAL) * 100 / COUNT(p_partkey) FROM part"} {"question_id": 6729, "db_id": "retails", "grading_method": "subset,=,5", "question": "List any five part names in Medium Plated Brass.", "evidence": "part.p_type uses 'MEDIUM PLATED BRASS'; part.p_name records the part name.", "SQL": "SELECT p_name FROM part WHERE p_type = 'MEDIUM PLATED BRASS'"} {"question_id": 6732, "db_id": "retails", "grading_method": "set", "question": "Among the customers from Morocco, how many customers were in debt?", "evidence": "customers refer to c_custkey; Morocco is the name of the nation which refers to n_name = 'MOROCCO'; in debt refers to c_acctbal < 0;", "SQL": "SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal < 0 AND T2.n_name = 'MOROCCO'"} {"question_id": 6751, "db_id": "retails", "grading_method": "set", "question": "Name the countries that belong in the region with comment description \"furiously express accounts wake sly\".", "evidence": "r_comment = 'furiously express accounts wake sly';", "SQL": "SELECT T1.n_name FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_comment = 'furiously express accounts wake sly'"} {"question_id": 6755, "db_id": "retails", "grading_method": "set", "question": "How many distinct products with a retail price above 1,000 have been shipped by ship?", "evidence": "part.p_partkey identifies a product; part.p_retailprice is its retail price. lineitem.l_shipmode = 'SHIP' denotes shipment by ship.", "SQL": "SELECT COUNT(DISTINCT `p`.`p_partkey`) FROM `part` AS `p` JOIN `lineitem` AS `l` ON `l`.`l_partkey` = `p`.`p_partkey` WHERE `p`.`p_retailprice` > 1000 AND `l`.`l_shipmode` = 'SHIP'"} {"question_id": 6756, "db_id": "retails", "grading_method": "set", "question": "What is the name and marketing segment of the customer with the total order price of 199180.63?", "evidence": "name of the customer refers to c_name; total order price of 199180.63 refers o_totalprice = 199180.63; marketing segment refers to c_mktsegment;", "SQL": "SELECT T2.c_name, T2.c_mktsegment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice = 199180.63"} {"question_id": 6757, "db_id": "retails", "grading_method": "set", "question": "Provide the nation and region of the customer with the address of wH55UnX7 VI?", "evidence": "nation refers to n_name; region refers to r_name; address of wH55UnX7 VI refers to c_address = 'wH55UnX7 VI';", "SQL": "SELECT T1.n_name, T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_address = 'wH55UnX7 VI'"} {"question_id": 6761, "db_id": "retails", "grading_method": "set", "question": "Give the name and phone number of the customers who have more than 9000 account balance.", "evidence": "the name of the customer refers to c_name; phone number of the customer refers to c_phone; have more than 9000 account balance refers to c_acctbal > 9000;", "SQL": "SELECT c_name, c_phone FROM customer WHERE c_acctbal > 9000"} {"question_id": 6766, "db_id": "retails", "grading_method": "list", "question": "Find the supply key of the top ten suppliers with the most account balance, and list the supply key along with the account balance in descending order of account balance.", "evidence": "supply key refers to s_suppkey; the most amount account balance refers to MAX(s_acctbal);", "SQL": "SELECT s_suppkey, s_acctbal FROM supplier ORDER BY s_acctbal DESC LIMIT 10"} {"question_id": 6779, "db_id": "retails", "grading_method": "set", "question": "What is the difference between the average monthly number of low-priority orders shipped by truck in 1995 and in 1996? Round your answer to 1 decimal place.", "evidence": "low-priority orders shipped by truck refers to orders.o_orderpriority = '5-LOW' and lineitem.l_shipmode = 'TRUCK'; a year's average monthly number refers to DIVIDE(COUNT(DISTINCT such orders with lineitem.l_shipdate in that year), 12); the difference refers to SUBTRACT(the 1995 number, the 1996 number); round the final answer to 1 decimal place", "SQL": "SELECT ROUND((COUNT(DISTINCT CASE WHEN STRFTIME('%Y', T2.`l_shipdate`)='1995' THEN T1.`o_orderkey` END)/12.0) - (COUNT(DISTINCT CASE WHEN STRFTIME('%Y', T2.`l_shipdate`)='1996' THEN T1.`o_orderkey` END)/12.0), 1) FROM `orders` AS T1 JOIN `lineitem` AS T2 ON T1.`o_orderkey` = T2.`l_orderkey` WHERE T1.`o_orderpriority`='5-LOW' AND T2.`l_shipmode`='TRUCK'"} {"question_id": 6788, "db_id": "retails", "grading_method": "set", "question": "Which segment does the customer who made the most orders in April 1994 belong to?", "evidence": "customer.c_mktsegment records the market segment; orders.o_orderdate records the order date in YYYY-MM-DD form.", "SQL": "WITH cust_counts AS (\n SELECT o_custkey, COUNT(*) AS num\n FROM orders\n WHERE o_orderdate LIKE '1994-04-%'\n GROUP BY o_custkey\n), max_num AS (\n SELECT MAX(num) AS max_num FROM cust_counts\n)\nSELECT DISTINCT c.c_mktsegment\nFROM cust_counts cc\nJOIN max_num mn ON cc.num = mn.max_num\nJOIN customer c ON c.c_custkey = cc.o_custkey;"} {"question_id": 6802, "db_id": "retails", "grading_method": "set", "question": "Which ship mode has more \"deliver in person\" instructions, RAIL or MAIL?", "evidence": "ship mode refers to l_shipmode; \"deliver in person\" instruction refers to l_shipinstruct = 'DELIVER IN PERSON'", "SQL": "SELECT CASE\n WHEN SUM(CASE WHEN `l_shipmode` = 'RAIL' THEN 1 ELSE 0 END) >\n SUM(CASE WHEN `l_shipmode` = 'MAIL' THEN 1 ELSE 0 END)\n THEN 'RAIL'\n ELSE 'MAIL'\n END AS result\nFROM `lineitem`\nWHERE `l_shipinstruct` = 'DELIVER IN PERSON';"} {"question_id": 6813, "db_id": "retails", "grading_method": "set", "question": "Which region has the lowest number of countries?", "evidence": "region refers to has r_name; the lowest number of countries refers to min(count(n_name))", "SQL": "SELECT T.r_name FROM ( SELECT T1.r_name, COUNT(T2.n_name) AS num FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey GROUP BY T1.r_name ) AS T ORDER BY T.num LIMIT 1"} {"question_id": 6819, "db_id": "retails", "grading_method": "set", "question": "Which customer is the most in debt?", "evidence": "customer refers to c_name; the most in debt refers to min(c_acctbal)", "SQL": "SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )"} {"question_id": 6831, "db_id": "retails", "grading_method": "set", "question": "What is the region with the most customers?", "evidence": "region refers to r_name; the most customers refers to max(count(c_custkey))", "SQL": "SELECT T.r_name FROM ( SELECT T3.r_name, COUNT(T2.c_custkey) AS num FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey GROUP BY T3.r_name ) AS T ORDER BY T.num DESC LIMIT 1"} {"question_id": 6844, "db_id": "retails", "grading_method": "set", "question": "How many customers belong to the household segment in Germany?", "evidence": "household segment refers to c_mktsegment = 'household'; Germany refers to n_name = 'Germany'", "SQL": "SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'GERMANY'"} {"question_id": 6845, "db_id": "retails", "grading_method": "set", "question": "List the phone numbers of customers whose order priority is urgent.", "evidence": "phone number refers to c_phone; order priority is urgent refers to o_orderpriority = '1-URGENT'", "SQL": "SELECT DISTINCT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderpriority = '1-URGENT'"} {"question_id": 6846, "db_id": "retails", "grading_method": "set", "question": "Name the customer whose order contains a line item with the highest discount.", "evidence": "customer name refers to c_name; the highest discount refers to max(l_discount)", "SQL": "SELECT DISTINCT c.`c_name`\nFROM `orders` o\nJOIN `lineitem` l ON o.`o_orderkey` = l.`l_orderkey`\nJOIN `customer` c ON o.`o_custkey` = c.`c_custkey`\nWHERE l.`l_discount` = (SELECT MAX(`l_discount`) FROM `lineitem`);"} {"question_id": 6855, "db_id": "retails", "grading_method": "set", "question": "Calculate the percentage of countries that belong to the American region.", "evidence": "the American region refers to r_name = 'America'; percentage = divide(count(n_name where r_name = 'America'), count(n_name)) * 100%", "SQL": "SELECT CAST(SUM(IIF(T1.r_name LIKE 'America', 1, 0)) AS REAL) * 100 / COUNT(T2.n_name) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey"} {"question_id": 6862, "db_id": "retails", "grading_method": "set", "question": "What is the name of the product with the highest retail price?", "evidence": "name of the product refers to p_name; the highest retail price refers to p_retailprice", "SQL": "SELECT p_name FROM part WHERE p_retailprice = ( SELECT MAX(p_retailprice) FROM part )"} {"question_id": 6866, "db_id": "retails", "grading_method": "set", "question": "How many suppliers have their accounts in debt?", "evidence": "account in debt refers to s_acctbal < 0", "SQL": "SELECT COUNT(s_suppkey) FROM supplier WHERE s_acctbal < 0"} {"question_id": 6883, "db_id": "retails", "grading_method": "set", "question": "Among all the suppliers providing the part \"hot spring dodger dim light\", how many of them are in Europe?", "evidence": "part \"hot spring dodger dim light\" refers to p_name = hot spring dodger dim light; Europe refers to r_name = 'EUROPE'", "SQL": "SELECT COUNT(DISTINCT s.s_suppkey)\nFROM part p\nJOIN partsupp ps ON ps.ps_partkey = p.p_partkey\nJOIN supplier s ON s.s_suppkey = ps.ps_suppkey\nJOIN nation n ON n.n_nationkey = s.s_nationkey\nJOIN region r ON r.r_regionkey = n.n_regionkey\nWHERE p.p_name = 'hot spring dodger dim light'\n AND r.r_name = 'EUROPE';"} {"question_id": 6887, "db_id": "retails", "grading_method": "set", "question": "On which date was the part \"burnished seashell gainsboro navajo chocolate\" in order no.1 shipped?", "evidence": "date refers to l_shipdate; part \"burnished seashell gainsboro navajo chocolate\" refers to p_name = 'burnished seashell gainsboro navajo chocolate'; order no.1 refers to l_orderkey = 1", "SQL": "SELECT T1.l_shipdate FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T1.l_orderkey = 1 AND T2.p_name = 'burnished seashell gainsboro navajo chocolate'"} {"question_id": 6889, "db_id": "retails", "grading_method": "set", "question": "Which part was ordered in a greater quantity in order 1: \"burnished seashell gainsboro navajo chocolate\" or \"salmon white grey tan navy\"?", "evidence": "order 1 refers to lineitem.l_orderkey = 1; the two candidates refer to part.p_name IN ('salmon white grey tan navy', 'burnished seashell gainsboro navajo chocolate'); quantity ordered refers to SUM(l_quantity) per part; return the p_name of the one with the greater total", "SQL": "SELECT T.p_name FROM ( SELECT T2.p_name, SUM(T1.l_quantity) AS num FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name IN ('salmon white grey tan navy', 'burnished seashell gainsboro navajo chocolate') AND T1.`l_orderkey` = 1 GROUP BY T1.l_partkey ) AS T ORDER BY T.num DESC LIMIT 1"} {"question_id": 6892, "db_id": "retails", "grading_method": "set", "question": "What is the average supply cost for the part \"hot spring dodger dim light\"?", "evidence": "average supply cost refers to avg(ps_supplycost); part \"hot spring dodger dim light\" refers to p_name = 'hot spring dodger dim light'", "SQL": "SELECT AVG(T1.ps_supplycost) FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey WHERE T3.p_name = 'hot spring dodger dim light'"} {"question_id": 6894, "db_id": "retails", "grading_method": "set", "question": "What is the profit for part no.98768 in order no.1?", "evidence": "part no.98768 refers to l_partkey = 98768; order no.1 refers to l_orderkey = 1; profit = subtract(multiply(l_extendedprice, subtract(1, l_discount)), multiply(ps_supplycost, l_quantity))", "SQL": "SELECT (l_extendedprice * (1 - l_discount) ) - (ps_supplycost * l_quantity) AS profit\nFROM `lineitem` \nJOIN `partsupp` ON `lineitem`.`l_partkey` = `partsupp`.`ps_partkey`\n AND `lineitem`.`l_suppkey` = `partsupp`.`ps_suppkey`\nWHERE `l_orderkey` = 1 AND `l_partkey` = 98768;"} {"question_id": 6896, "db_id": "retails", "grading_method": "set", "question": "Which market segment does the customer with the largest debt belong to?", "evidence": "the largest debt refers to the minimum account balance, MIN(c_acctbal); market segment refers to customer.c_mktsegment; return the c_mktsegment where c_acctbal = MIN(c_acctbal)", "SQL": "SELECT c_mktsegment FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )"} {"question_id": 6903, "db_id": "retails", "grading_method": "set", "question": "How much is the total price of all the orders shipped to customers in Argentina?", "evidence": "total price = sum(o_totalprice); Argentina refers to n_name = 'Argentina'", "SQL": "SELECT SUM(T3.o_totalprice) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey INNER JOIN orders AS T3 ON T1.c_custkey = T3.o_custkey WHERE T2.n_name = 'ARGENTINA'"} {"question_id": 6906, "db_id": "retails", "grading_method": "set", "question": "How much is the part supply cost for the medium metallic grey dodger linen?", "evidence": "part supply cost refers to ps_supplycost; medium metallic grey dodger linen refers to p_name = 'medium metallic grey dodger linen'", "SQL": "SELECT T2.ps_supplycost FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T1.p_name = 'medium metallic grey dodger linen'"} {"question_id": 6910, "db_id": "retails", "grading_method": "set", "question": "Who is the clerk in charge of handling the item with the highest amount of extended price?", "evidence": "clerk refers to o_clerk; the highest amount of extended price refers to max(l_extendedprice)", "SQL": "SELECT DISTINCT `o`.`o_clerk`\nFROM `orders` AS `o`\nJOIN `lineitem` AS `l` ON `o`.`o_orderkey` = `l`.`l_orderkey`\nWHERE `l`.`l_extendedprice` = (SELECT MAX(`l_extendedprice`) FROM `lineitem`);"} {"question_id": 6911, "db_id": "retails", "grading_method": "set", "question": "What are the total quantities of the items ordered by customer 101660 on 10/5/1995?", "evidence": "total quantity refers to sum(l_quantity); customer 101660 refers to o_custkey = 101660; on 10/5/1995 refers to o_orderdate = '1995-10-05'", "SQL": "SELECT SUM(T2.l_quantity) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderdate = '1995-10-05' AND T1.o_custkey = 101660"} {"question_id": 6925, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Among all the players that are right-shooted, how many of them weigh over 90 kg?", "evidence": "right-shooted refers to shoots = 'R'; weigh over 90 kg refers to weight_in_kg > 90;", "SQL": "SELECT COUNT(T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN weight_info AS T2 ON T1.weight = T2.weight_id WHERE T2.weight_in_kg > 90 AND T1.shoots = 'R'"} {"question_id": 6928, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What is the average height in centimeters of players whose only listed position is defense? Round your answer to 3 decimal places.", "evidence": "players whose only listed position is defense refers to PlayerInfo.position_info = 'D' alone, since slash-separated values denote multiple positions; PlayerInfo.height refers to height_info.height_id, and height_info.height_in_cm gives the height in centimeters; average = DIVIDE(SUM(height_info.height_in_cm), COUNT(those players)), then ROUND to 3 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT CAST(SUM(T2.height_in_cm) AS REAL) / COUNT(T1.ELITEID) FROM PlayerInfo AS T1 INNER JOIN height_info AS T2 ON T1.height = T2.height_id WHERE T1.position_info = 'D'\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 6931, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Among the players whose total NHL games played in their first 7 years of NHL career is no less than 500, what is the name of the player who committed the most rule violations in his entire playing history?", "evidence": "total NHL games played in their first 7 years of NHL career is no less than 500 refers to sum_7yr_GP >= 500; name of the player refers to PlayerName; committed the most rule violations refers to MAX(PIM);", "SQL": "SELECT P.`PlayerName`\nFROM `PlayerInfo` AS P\nJOIN `SeasonStatus` AS S ON P.`ELITEID` = S.`ELITEID`\nWHERE P.`sum_7yr_GP` >= 500\nGROUP BY P.`ELITEID`\nORDER BY SUM(COALESCE(S.`PIM`,0)) DESC\nLIMIT 1;"} {"question_id": 6932, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What is the height in centimeter of the tallest player born in Edmonton, Alberta, Canada?", "evidence": "height in centimeter refers to height_in_cm; tallest player refers to MAX(height_in_cm); born in Edmonton, Alberta, Canada refers to birthplace = 'Edmonton, AB, CAN';", "SQL": "SELECT T2.height_in_cm FROM PlayerInfo AS T1 INNER JOIN height_info AS T2 ON T1.height = T2.height_id WHERE T1.birthplace = 'Edmonton, AB, CAN' ORDER BY T2.height_in_cm DESC LIMIT 1"} {"question_id": 6936, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What are the names of the players who played for Acadie-Bathurst Titan during the regular season in 1998-1999?", "evidence": "names of the players refers to PlayerName; played for Acadie-Bathurst Titan refers to TEAM = 'Acadie-Bathurst Titan'; regular season refers to GAMETYPE = 'Regular Season'; in 1998-1999 refers to SEASON = '1998-1999';", "SQL": "SELECT T2.PlayerName FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '1998-1999' AND T1.GAMETYPE = 'Regular Season' AND T1.TEAM = 'Acadie-Bathurst Titan'"} {"question_id": 6947, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Identify the names and positions of the players who have committed the most rule violations across all seasons.", "evidence": "name of the player refers to PlayerName; position of the player refers to position_info; committed the most rule violations refers to MAX(SUM(PIM));", "SQL": "SELECT p.`PlayerName`, p.`position_info` FROM `PlayerInfo` p JOIN (SELECT `ELITEID`, SUM(`PIM`) AS total_pim FROM `SeasonStatus` GROUP BY `ELITEID` HAVING total_pim = ( SELECT MAX(total_pim) FROM ( SELECT `ELITEID`, SUM(`PIM`) AS total_pim FROM `SeasonStatus` GROUP BY `ELITEID` ) AS PIMTotals )) s ON p.`ELITEID` = s.`ELITEID`"} {"question_id": 6950, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What is the name of the player with the highest draft-prospects ranking among those drafted by the Toronto Maple Leafs in 2008?", "evidence": "drafted by the Toronto Maple Leafs in 2008 refers to PlayerInfo.overallby = 'Toronto Maple Leafs' AND PlayerInfo.draftyear = '2008'; the highest draft-prospects ranking refers to MIN(CSS_rank), because a smaller CSS_rank is a better rank; identify the single player holding it", "SQL": "SELECT PlayerName FROM PlayerInfo WHERE overallby = 'Toronto Maple Leafs' AND draftyear = '2008' ORDER BY CSS_rank LIMIT 1"} {"question_id": 6952, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "How many players who were drafted by the Toronto Maple Leafs have played over 300 games in their first 7 years of the NHL career?", "evidence": "drafted by the Toronto Maple Leafs refers to overallby = 'Toronto Maple Leafs'; played over 300 games in their first 7 years of the NHL career refers to sum_7yr_GP > 300;", "SQL": "SELECT COUNT(ELITEID) FROM PlayerInfo WHERE overallby = 'Toronto Maple Leafs' AND sum_7yr_GP > 300"} {"question_id": 6953, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "How tall is the player from Yale University who picked up 28 penalty minutes in the 2005-2006 season?", "evidence": "how tall refers to height_in_cm; Yale University refers to TEAM = 'Yale Univ.'; 28 penalty minutes refers to PIM = '28'; 2005-2006 season refers to SEASON = '2005-2006';", "SQL": "SELECT T3.height_in_cm FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID INNER JOIN height_info AS T3 ON T2.height = T3.height_id WHERE T1.SEASON = '2005-2006' AND T1.TEAM = 'Yale Univ.' AND T1.PIM = 28"} {"question_id": 6959, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Who has the heaviest weight?", "evidence": "who refers to PlayerName; heaviest weight refers to MAX(weight_in_kg);", "SQL": "SELECT T1.PlayerName FROM PlayerInfo AS T1 INNER JOIN weight_info AS T2 ON T1.weight = T2.weight_id WHERE T2.weight_in_kg = (SELECT max(weight_in_kg) FROM PlayerInfo AS T1 INNER JOIN weight_info AS T2 ON T1.weight = T2.weight_id)"} {"question_id": 6962, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "List out the seasons that Niklas Eckerblom played.", "evidence": "", "SQL": "SELECT DISTINCT T1.SEASON FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T2.PlayerName = 'Niklas Eckerblom'"} {"question_id": 6978, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Who has played the most game plays in the 2000-2001 season of the International league?", "evidence": "played the most game plays refers to MAX(GP); 2000-2001 season refers to SEASON = '2000-2001'; International league refers to LEAGUE = 'International';", "SQL": "SELECT P.`PlayerName`\nFROM SeasonStatus S\nJOIN PlayerInfo P ON P.`ELITEID` = S.`ELITEID`\nWHERE S.`SEASON` = '2000-2001'\n AND S.`LEAGUE` = 'International'\nGROUP BY S.`ELITEID`\nHAVING SUM(S.`GP`) = (\n SELECT MAX(total_gp)\n FROM (\n SELECT `ELITEID`, SUM(`GP`) AS total_gp\n FROM SeasonStatus\n WHERE `SEASON` = '2000-2001'\n AND `LEAGUE` = 'International'\n GROUP BY `ELITEID`\n )\n);"} {"question_id": 6990, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "How many playoffs games did Per Mars participate in?", "evidence": "playoffs refers to GAMETYPE = 'Playoffs';", "SQL": "SELECT SUM(T2.GP) FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.PlayerName = 'Per Mars' AND T2.GAMETYPE = 'Playoffs'"} {"question_id": 6992, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Which country do most players of team Plymouth Whalers come from?", "evidence": "country and nation are synonyms; country where most players come from refers to MAX(COUNT(nation WHERE TEAM = 'Plymouth Whalers')); players refers to PlayerName; team Plymouth Whalers refers to TEAM = 'Plymouth Whalers';", "SQL": "with sub as (SELECT T1.nation, COUNT(distinct T1.ELITEID) as num FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID WHERE T2.TEAM = 'Plymouth Whalers' GROUP BY T1.nation)\nselect nation from sub where num=(select max(num) from sub)"} {"question_id": 6994, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "Indicate the height of all players from team Oshawa Generals in inches.", "evidence": "SeasonStatus.TEAM records 'Oshawa Generals'. PlayerInfo.height identifies the height entry whose height_info.height_in_inch is the height in inches.", "SQL": "SELECT T3.height_in_inch FROM PlayerInfo AS T1 INNER JOIN SeasonStatus AS T2 ON T1.ELITEID = T2.ELITEID INNER JOIN height_info AS T3 ON T1.height = T3.height_id WHERE T2.TEAM = 'Oshawa Generals' GROUP BY T2.ELITEID"} {"question_id": 6997, "db_id": "ice_hockey_draft", "grading_method": "set", "question": "What is the percentage of Swedish players in playoffs games in the 1997 - 2000 season?", "evidence": "PlayerInfo.nation = 'Sweden' identifies Swedish players. SeasonStatus.ELITEID identifies the player; SEASON uses '1997-1998', '1998-1999', and '1999-2000'. GAMETYPE uses 'Playoffs' for playoff records.", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN P.`nation` = 'Sweden' THEN S.`ELITEID` END)\n / COUNT(DISTINCT S.`ELITEID`) AS percentage_sweden_playoffs_1997_2000\nFROM `SeasonStatus` S\nJOIN `PlayerInfo` P ON P.`ELITEID` = S.`ELITEID`\nWHERE S.`SEASON` IN ('1997-1998','1998-1999','1999-2000')\n AND LOWER(S.`GAMETYPE`) = 'playoffs';"} {"question_id": 6999, "db_id": "works_cycles", "grading_method": "set", "question": "What is the average standard cost of product number CA-1098?", "evidence": "Average cost = AVG(ProductCostHistory.StandardCost)", "SQL": "SELECT AVG(T2.StandardCost) FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductNumber = 'CA-1098'"} {"question_id": 7000, "db_id": "works_cycles", "grading_method": "set", "question": "For all the products, list the product name and its corresponding start date for the current standard cost.", "evidence": "The current standard cost refers to EndDate is NULL", "SQL": "SELECT T1.Name, T2.StartDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.EndDate IS NULL"} {"question_id": 7001, "db_id": "works_cycles", "grading_method": "set", "question": "Which products have a standard cost at least $80 higher than their previous standard cost? List their names.", "evidence": "Product.StandardCost is the current unit cost; ProductCostHistory.StandardCost is a historical unit cost. ProductCostHistory.StartDate and EndDate use YYYY-MM-DD HH:MM:SS with fractional seconds.", "SQL": "SELECT T1.Name FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.StandardCost - T2.StandardCost >= 80 GROUP BY T1.Name"} {"question_id": 7009, "db_id": "works_cycles", "grading_method": "set", "question": "List all high-quality product names and their selling prices.", "evidence": "Product.Class = 'H' denotes high quality; Product.ListPrice records the selling price.", "SQL": "SELECT Name, ListPrice FROM Product WHERE Class = 'H'"} {"question_id": 7010, "db_id": "works_cycles", "grading_method": "set", "question": "Which product line has the most products that are salable?", "evidence": "Saleable product refers to FinishedGoodsFlag = 1", "SQL": "SELECT ProductLine FROM Product WHERE FinishedGoodsFlag = 1 GROUP BY ProductLine ORDER BY COUNT(FinishedGoodsFlag) DESC LIMIT 1"} {"question_id": 7023, "db_id": "works_cycles", "grading_method": "set", "question": "List the names and calculate the profit for products with the highest review rating.", "evidence": "Product.ListPrice is the selling price and Product.StandardCost is the cost; profit is their difference. ProductReview.Rating records the review rating.", "SQL": "SELECT p.`Name`, p.`ListPrice` - p.`StandardCost` AS profit FROM `Product` p JOIN `ProductReview` pr ON p.`ProductID` = pr.`ProductID` WHERE pr.`Rating` = (SELECT MAX(`Rating`) FROM `ProductReview`)"} {"question_id": 7025, "db_id": "works_cycles", "grading_method": "set", "question": "Which currency pairs have the highest recorded daily average exchange rate? Give the source currency code followed by the destination currency code.", "evidence": "CurrencyRate.FromCurrencyCode and CurrencyRate.ToCurrencyCode identify the source and destination currencies. CurrencyRate.AverageRate is the recorded daily average rate.", "SQL": "SELECT FromCurrencyCode, ToCurrencyCode FROM CurrencyRate WHERE AverageRate = (SELECT MAX(AverageRate) FROM CurrencyRate);"} {"question_id": 7027, "db_id": "works_cycles", "grading_method": "set", "question": "Which of these U.S. territories recorded the highest sales last year: Northwest or Southeast?", "evidence": "SalesTerritory.SalesLastYear is the recorded previous-year sales total; CountryRegionCode = 'US' denotes U.S. territories.", "SQL": "SELECT Name FROM SalesTerritory WHERE CountryRegionCode = 'US' AND (Name = 'Northwest' OR Name = 'Southeast') ORDER BY SalesLastYear DESC LIMIT 1"} {"question_id": 7036, "db_id": "works_cycles", "grading_method": "set", "question": "Who is the Vice President of Engineering and when did he join the company? Indicate his/her full name.", "evidence": "full name = FirstName, MiddleName, LastName; HiredDate refers to the date the person joins the company;", "SQL": "SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.HireDate FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Vice President of Engineering'"} {"question_id": 7043, "db_id": "works_cycles", "grading_method": "set", "question": "What is the profit of the product with the highest list price?", "evidence": "profit = subtract(ListPrice, StandardCost); ", "SQL": "SELECT ListPrice - StandardCost FROM Product WHERE ListPrice = (SELECT max(ListPrice) FROM Product)"} {"question_id": 7045, "db_id": "works_cycles", "grading_method": "set", "question": "How many business entities have an address that uses a second address line?", "evidence": "A second address line is present when Address.AddressLine2 is neither NULL nor empty.", "SQL": "SELECT COUNT(DISTINCT ba.`BusinessEntityID`)\nFROM `BusinessEntityAddress` ba\nJOIN `Address` a ON ba.`AddressID` = a.`AddressID`\nWHERE a.`AddressLine2` IS NOT NULL AND a.`AddressLine2` <> '';"} {"question_id": 7047, "db_id": "works_cycles", "grading_method": "set", "question": "What is the longest assembly item duration?", "evidence": "longest assembly item duration = max(subtract(EndDate,StartDate))", "SQL": "SELECT JULIANDAY(EndDate) - JULIANDAY(StartDate) FROM BillOfMaterials ORDER BY JULIANDAY(EndDate) - JULIANDAY(StartDate) DESC LIMIT 1"} {"question_id": 7065, "db_id": "works_cycles", "grading_method": "set", "question": "Among the employees who are married, how many of them have a western name style?", "evidence": "married refers to MaritalStatus = 'M'; western name style refers to NameStyle = '0';", "SQL": "SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.MaritalStatus = 'M'"} {"question_id": 7066, "db_id": "works_cycles", "grading_method": "set", "question": "Among the employees who have more than 10 hours of sick leave, how many of them wish to receive e-mail promotions?", "evidence": "Contact does wish to receive e-mail promotions refers to EmailPromotion = (1,2); more than 10 hours of sick leave refer to SickLeaveHours >10;", "SQL": "SELECT COUNT(*) FROM `Employee` AS e JOIN `Person` AS p ON e.`BusinessEntityID` = p.`BusinessEntityID` WHERE e.`SickLeaveHours` > 10 AND p.`EmailPromotion` IN (1,2)"} {"question_id": 7075, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the credit card IDs of the employees who work as store contact.", "evidence": "store contact refers to PersonType = 'SC';", "SQL": "SELECT DISTINCT pc.`CreditCardID` FROM `Person` p JOIN `Employee` e ON p.`BusinessEntityID` = e.`BusinessEntityID` JOIN `PersonCreditCard` pc ON p.`BusinessEntityID` = pc.`BusinessEntityID` WHERE p.`PersonType` = 'SC'"} {"question_id": 7076, "db_id": "works_cycles", "grading_method": "set", "question": "How many vacation hours do the male employees have on average?", "evidence": "Male refers to Gender = 'M'; Average = Divide( SUM(VacationHours(Gender = 'M')),Count(BusinessEntityID(Gender = 'M')));", "SQL": "SELECT AVG(`VacationHours`) AS avg_vacation_hours\nFROM `Employee`\nWHERE `Gender` = 'M';"} {"question_id": 7079, "db_id": "works_cycles", "grading_method": "set", "question": "Among the active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?", "evidence": "CurrentFlag = 1 refers to the active status of employees; Percentage = Divide (Count (BusinessEntityID (CurrentFlag = 1 & VacationHours >20 & SickLeaveHours > 10)), Count (BusinessEntityID (CurrentFlag = 1 & SickLeaveHours>10))) * 100;", "SQL": "SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.BusinessEntityID) FROM Employee AS T2 WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10"} {"question_id": 7084, "db_id": "works_cycles", "grading_method": "set", "question": "List, by ProductID, all products whose profit is positive.", "evidence": "Profit = SUBTRACT(ListPrice, StandardCost)", "SQL": "SELECT DISTINCT ProductID FROM Product WHERE ListPrice - StandardCost >0"} {"question_id": 7090, "db_id": "works_cycles", "grading_method": "set", "question": "List business entity IDs that have a Colonial Voice card that expired in March 2005.", "evidence": "Colonial Voice card refers to CardType = 'ColonialVoice' ; expired in March 2005 refers to ExpMonth = 3, ExpYear = 2005", "SQL": "SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardType = 'ColonialVoice' AND T1.ExpMonth = 3 AND T1.ExpYear = 2005"} {"question_id": 7091, "db_id": "works_cycles", "grading_method": "set", "question": "What is the credit rating of the company whose average lead time is 16 days for a standard price of 18.9900 and whose last receipt date is August 27, 2011?", "evidence": "ProductVendor.AverageLeadTime = 16, ProductVendor.StandardPrice = 18.9900, and ProductVendor.LastReceiptDate is August 27, 2011; Vendor.CreditRating records the requested rating.", "SQL": "SELECT T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.StandardPrice = 18.9900 AND T1.AverageLeadTime = 16 AND STRFTIME('%Y-%m-%d', T1.LastReceiptDate) = '2011-08-27'"} {"question_id": 7095, "db_id": "works_cycles", "grading_method": "set", "question": "How many units of products are stored at the Subassembly location in total?", "evidence": "ProductInventory.Quantity records product units at an inventory location.", "SQL": "SELECT SUM(`Quantity`) AS TotalItems FROM `ProductInventory` WHERE `LocationID` = (SELECT `LocationID` FROM `Location` WHERE `Name` = 'Subassembly')"} {"question_id": 7111, "db_id": "works_cycles", "grading_method": "set", "question": "How many vendors supply at least one product with an average delivery lead time of 25 days?", "evidence": "ProductVendor.AverageLeadTime is days from ordering to receipt, recorded per product-vendor relationship.", "SQL": "SELECT COUNT(DISTINCT BusinessEntityID) FROM ProductVendor WHERE AverageLeadTime = 25"} {"question_id": 7123, "db_id": "works_cycles", "grading_method": "set", "question": "What is the name of the currency of Brazil?", "evidence": "", "SQL": "SELECT T1.Name FROM Currency AS T1 INNER JOIN CountryRegionCurrency AS T2 ON T1.CurrencyCode = T2.CurrencyCode INNER JOIN CountryRegion AS T3 ON T2.CountryRegionCode = T3.CountryRegionCode WHERE T3.Name = 'Brazil'"} {"question_id": 7126, "db_id": "works_cycles", "grading_method": "set", "question": "How many addresses are recorded in Bothell and Kenmore, respectively, and what state are they in? Give the two counts followed by the state name.", "evidence": "Address.StateProvinceID identifies the state or province named in StateProvince.Name.", "SQL": "SELECT \n SUM(CASE WHEN a.City='Bothell' THEN 1 ELSE 0 END) AS Bothell_cnt,\n SUM(CASE WHEN a.City='Kenmore' THEN 1 ELSE 0 END) AS Kenmore_cnt,\n sp.Name AS StateName\nFROM Address a\nJOIN StateProvince sp ON a.StateProvinceID = sp.StateProvinceID\nWHERE a.City IN ('Bothell','Kenmore')\nGROUP BY sp.Name;"} {"question_id": 7127, "db_id": "works_cycles", "grading_method": "set", "question": "Which product models have an English description about chromoly steel? List their names.", "evidence": "Descriptions are recorded in ProductDescription.Description; Culture.Name identifies the language. ProductModelProductDescriptionCulture associates a model with its description and language. The stored subject text is 'Chromoly steel'.", "SQL": "SELECT T4.name FROM ProductModelProductDescriptionCulture AS T1 INNER JOIN Culture AS T2 USING (cultureid) INNER JOIN ProductDescription AS T3 USING (productdescriptionid) JOIN ProductModel T4 on T1.ProductModelID = T4.ProductModelID WHERE T3.Description LIKE 'Chromoly steel%' AND T2.Name = 'English'"} {"question_id": 7128, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the business entity ID of sales persons with a commission percentage of 0.018 or above, along with each sales person's assigned geographical location.", "evidence": "geographical location refers to group from SalesPerson; ComissionPct refers to commission percentage where ComissionPct > = 0.018;", "SQL": "SELECT T1.BusinessEntityID, T2.'Group' FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 USING (territoryid) WHERE T1.CommissionPct >= 0.018"} {"question_id": 7135, "db_id": "works_cycles", "grading_method": "set", "question": "What is the location of business number 1?", "evidence": "Location refers to AddressLine1; business number refers to the BusinessEntityID where BusinessEntityID = 1", "SQL": "SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 USING (AddressID) WHERE T2.BusinessEntityID = 1"} {"question_id": 7137, "db_id": "works_cycles", "grading_method": "set", "question": "What percentage of product-model description rows are stored in Thai?", "evidence": "percentage = DIVIDE(Culture.Name = 'Thai', count(ALL Culture.Name))*100%", "SQL": "SELECT CAST(SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.CultureID) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID"} {"question_id": 7143, "db_id": "works_cycles", "grading_method": "set", "question": "What is the location id for Debur and Polish?", "evidence": "Debur and Polish is name of manufacturing location", "SQL": "SELECT LocationID FROM Location WHERE Name = 'Debur and Polish'"} {"question_id": 7144, "db_id": "works_cycles", "grading_method": "set", "question": "What are the Department ids under the Sales and Marketing Group?", "evidence": "Sales and Marketing is group name of a department", "SQL": "SELECT DepartmentID FROM Department WHERE GroupName = 'Sales and Marketing'"} {"question_id": 7146, "db_id": "works_cycles", "grading_method": "set", "question": "What is the Shift start time for Shift ID No.2?", "evidence": "", "SQL": "SELECT StartTime FROM Shift WHERE ShiftID = '2'"} {"question_id": 7148, "db_id": "works_cycles", "grading_method": "set", "question": "What is the minimum shipping charge for \"OVERSEAS - DELUXE\"?", "evidence": "Minimum shipping charge refers to ShipBase; OVERSEAS - DELUXE is name of shipping company", "SQL": "SELECT ShipBase FROM ShipMethod WHERE Name = 'OVERSEAS - DELUXE'"} {"question_id": 7153, "db_id": "works_cycles", "grading_method": "set", "question": "What is the product ID No.793's model name?", "evidence": "", "SQL": "SELECT T2.Name FROM Product AS T1 INNER JOIN ProductModel AS T2 ON T1.ProductModelID = T2.ProductModelID WHERE T1.ProductID = 793"} {"question_id": 7159, "db_id": "works_cycles", "grading_method": "set", "question": "What is the size of the thumbnail photo of product id No. 332 in bytes?", "evidence": "", "SQL": "SELECT length(pp.`ThumbNailPhoto`) AS PhotoSizeBytes FROM `ProductProductPhoto` ppp JOIN `ProductPhoto` pp ON pp.`ProductPhotoID` = ppp.`ProductPhotoID` WHERE ppp.`ProductID` = 332"} {"question_id": 7171, "db_id": "works_cycles", "grading_method": "set", "question": "For person id No.2054, is his/her vendor still active? Output the activeflag.", "evidence": "ActiveFlag = 1 means 'Vendor no longer used'; ActiveFlag = 2 means 'Vendor is actively used'", "SQL": "SELECT T1.ActiveFlag FROM Vendor AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonID = 2054"} {"question_id": 7182, "db_id": "works_cycles", "grading_method": "set", "question": "For each unit code EA, IN, and OZ, what is the total per-assembly quantity and the unit name?", "evidence": "BillOfMaterials.PerAssemblyQty is component quantity required for an assembly; UnitMeasure.Name names its unit code.", "SQL": "SELECT SUM(T1.PerAssemblyQty), T2.Name FROM BillOfMaterials AS T1 INNER JOIN UnitMeasure AS T2 ON T1.UnitMeasureCode = T2.UnitMeasureCode WHERE T1.UnitMeasureCode IN ('EA', 'IN', 'OZ') GROUP BY T2.Name"} {"question_id": 7183, "db_id": "works_cycles", "grading_method": "set", "question": "Which product IDs do not have any work order ID?", "evidence": "WorkOrder records product work orders; WorkOrder.ProductID identifies the product.", "SQL": "SELECT ProductID FROM Product WHERE ProductID NOT IN ( SELECT T1.ProductID FROM Product AS T1 INNER JOIN WorkOrder AS T2 ON T1.ProductID = T2.ProductID )"} {"question_id": 7192, "db_id": "works_cycles", "grading_method": "set", "question": "Which salespeople were hired before 2012? Provide their first and last names.", "evidence": "Person.PersonType = 'SP' identifies salespeople. Employee.HireDate records the hire date; Person.FirstName and Person.LastName record names.", "SQL": "SELECT\n P.`FirstName`,\n P.`LastName`\nFROM `Employee` E\nJOIN `Person` P ON P.`BusinessEntityID` = E.`BusinessEntityID`\nWHERE P.`PersonType` = 'SP'\n AND E.`HireDate` < '2012-01-01';"} {"question_id": 7194, "db_id": "works_cycles", "grading_method": "set", "question": "How many people named Alex are single and at organization level 1?", "evidence": "Employee.MaritalStatus = 'S' denotes single; Employee.OrganizationLevel records organization level. Person.FirstName uses 'Alex'.", "SQL": "SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.FirstName = 'Alex' AND T1.MaritalStatus = 'S' AND T1.OrganizationLevel = 1"} {"question_id": 7200, "db_id": "works_cycles", "grading_method": "set", "question": "List the email addresses of female single employees.", "evidence": "Employee.Gender = 'F' denotes female and Employee.MaritalStatus = 'S' denotes single.", "SQL": "SELECT T3.EmailAddress FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmailAddress AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.Gender = 'F' AND T1.MaritalStatus = 'S'"} {"question_id": 7204, "db_id": "works_cycles", "grading_method": "set", "question": "What percentage of employees who opted into email promotions are female? Round your answer to 3 decimal places.", "evidence": "Employee.Gender = 'F' denotes female employees. Person.EmailPromotion values 1 and 2 indicate willingness to receive email promotions.", "SQL": "WITH unrounded(value) AS (\nSELECT CAST(SUM(CASE WHEN e.Gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100.0 / COUNT(*) AS FemalePercent FROM Employee e JOIN Person p ON e.BusinessEntityID = p.BusinessEntityID WHERE p.EmailPromotion IN (1, 2)\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 7207, "db_id": "works_cycles", "grading_method": "set", "question": "How many credit card types are recorded, and how many are Vista?", "evidence": "CreditCard.CardType is a card-type category shared by individual cards; the stored label is 'Vista'.", "SQL": "SELECT (SELECT COUNT(DISTINCT `CardType`) FROM `CreditCard`) AS total_card_types, (SELECT COUNT(*) FROM `CreditCard` WHERE `CardType` = 'Vista') AS vista_cards"} {"question_id": 7219, "db_id": "works_cycles", "grading_method": "set", "question": "What is the total shipping cost for all purchase orders created on 12/14/2011 that use \"CARGO TRANSPORT 5\"?", "evidence": "'CARGO TRANSPORT 5' refers to ShipMethod.Name; created on 12/14/2011 refers to purchase orders whose PurchaseOrderHeader.OrderDate falls on that day; total shipping cost refers to SUM(PurchaseOrderHeader.Freight) over those purchase orders", "SQL": "SELECT SUM(poh.`Freight`) AS TotalShipmentCost\nFROM `PurchaseOrderHeader` AS poh\nJOIN `ShipMethod` AS sm ON sm.`ShipMethodID` = poh.`ShipMethodID`\nWHERE UPPER(sm.`Name`) = 'CARGO TRANSPORT 5'\n AND date(poh.`OrderDate`) = '2011-12-14';"} {"question_id": 7220, "db_id": "works_cycles", "grading_method": "set", "question": "How many sales orders did the salesperson David R. Campbell create?", "evidence": "SP is an abbreviation for Sales Person; PersonType = 'SP';", "SQL": "SELECT COUNT(*)\nFROM `SalesOrderHeader` AS soh\nJOIN `Person` AS p ON p.`BusinessEntityID` = soh.`SalesPersonID`\nWHERE p.`FirstName` = 'David'\n AND p.`MiddleName` = 'R'\n AND p.`LastName` = 'Campbell';"} {"question_id": 7224, "db_id": "works_cycles", "grading_method": "set", "question": "List the first names of the people with more than 65 sick leave hours.", "evidence": "SickLeaveHours>65;", "SQL": "SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.SickLeaveHours > 65"} {"question_id": 7228, "db_id": "works_cycles", "grading_method": "set", "question": "What is the business ID of the person who has made the most sales total year to date?", "evidence": "business ID refers to BusinessEntityID; sales total year to date refers to SalesYTD; most sales total year to date refers to MAX(SalesYTD);", "SQL": "SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesYTD DESC LIMIT 1"} {"question_id": 7235, "db_id": "works_cycles", "grading_method": "set", "question": "What is the person's business ID with a vista credit card number \"11113366963373\"?", "evidence": "business id refers to BusinessEntityID", "SQL": "SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardNumber = 11113366963373"} {"question_id": 7247, "db_id": "works_cycles", "grading_method": "set", "question": "How many married male employees were born before the year 1960?", "evidence": "married refers to MaritalStatus = 'M'; male refers to Gender = 'M'; BirthDate < = '1959-12-31';", "SQL": "SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 'M' AND STRFTIME('%Y', BirthDate) < '1960' AND Gender = 'M'"} {"question_id": 7251, "db_id": "works_cycles", "grading_method": "set", "question": "What is the net profit of the vendor with the highest standard price? If multiple vendors tie, calculate it for only one.", "evidence": "the vendor with the highest standard price refers to the single ProductVendor record with the greatest StandardPrice, taking only one when several tie; net profit = SUBTRACT(LastReceiptCost, StandardPrice) for that record", "SQL": "SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY StandardPrice DESC LIMIT 1"} {"question_id": 7259, "db_id": "works_cycles", "grading_method": "set", "question": "What is the profit per unit for each product John Smith rated highest? List the profit followed by the product name.", "evidence": "rated highest refers to the MAX value John Smith rated, taken over every product John Smith rated; profit per unit refers to SUBTRACT(Product.ListPrice, Product.StandardCost); list that profit followed by the product name, once for each product John Smith rated at that MAX value", "SQL": "WITH max_rate AS (\n SELECT MAX(`Rating`) AS max_rating\n FROM `ProductReview`\n WHERE `ReviewerName` = 'John Smith'\n)\nSELECT DISTINCT\n p.`ListPrice` - p.`StandardCost` AS profit,\n p.`Name`\nFROM `Product` p\nJOIN `ProductReview` pr ON p.`ProductID` = pr.`ProductID`\nJOIN max_rate mr ON pr.`Rating` = mr.max_rating\nWHERE pr.`ReviewerName` = 'John Smith';"} {"question_id": 7267, "db_id": "works_cycles", "grading_method": "set", "question": "Which vendors does the company buy women’s tights from? List their names.", "evidence": "Product.MakeFlag = 0 denotes purchased products. Product.Style = 'W' denotes women’s products; ProductSubcategory.Name uses 'Tights'.", "SQL": "SELECT DISTINCT T4.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN ProductSubcategory AS T3 ON T1.ProductSubcategoryID = T3.ProductSubcategoryID INNER JOIN Vendor AS T4 ON T2.BusinessEntityID = T4.BusinessEntityID WHERE T1.MakeFlag = 0 AND T1.Style = 'W' AND T3.Name = 'Tights'"} {"question_id": 7273, "db_id": "works_cycles", "grading_method": "set", "question": "What is the highest amount of difference between the ordered quantity and actual quantity received in a single purchase order and to which vendor was the purchase order made?", "evidence": "highest amount of difference between the ordered quantity and actual quantity received in a single purchase order refers to MAX(SUBTRACT(SUM(OrderQty), SUM(ReceivedQty))); which vendor refers to vendor name", "SQL": "SELECT sub.diff AS MaxDifference,\n T3.Name\nFROM (\n SELECT PurchaseOrderID,\n SUM(OrderQty) - SUM(ReceivedQty) AS diff\n FROM PurchaseOrderDetail\n GROUP BY PurchaseOrderID\n ) AS sub\nJOIN PurchaseOrderHeader AS poh ON sub.PurchaseOrderID = poh.PurchaseOrderID\nJOIN Vendor T3 ON poh.VendorID = T3.BusinessEntityID\nORDER BY sub.diff DESC\nLIMIT 1;"} {"question_id": 7286, "db_id": "works_cycles", "grading_method": "set", "question": "List the names of products with more than one review that are salable.", "evidence": "Product.FinishedGoodsFlag = 1 denotes a salable product; ProductReview records product reviews.", "SQL": "SELECT p.`Name`\nFROM `Product` p\nJOIN `ProductReview` pr ON pr.`ProductID` = p.`ProductID`\nWHERE p.`FinishedGoodsFlag` = 1\nGROUP BY p.`ProductID`, p.`Name`\nHAVING COUNT(*) > 1;"} {"question_id": 7289, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the e-mails of the reviewers who have reviewed high class products.", "evidence": "high class refers to Class = 'H';", "SQL": "SELECT DISTINCT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'H'"} {"question_id": 7296, "db_id": "works_cycles", "grading_method": "set", "question": "Which vendor has the lowest selling price for Hex Nut 5? Give the vendor’s name.", "evidence": "Hex Nut 5 refers to Product.Name = 'Hex Nut 5'; the vendor's selling price refers to ProductVendor.StandardPrice; the lowest refers to StandardPrice = MIN(StandardPrice) among the ProductVendor rows for Hex Nut 5; return that vendor's name", "SQL": "SELECT v.`Name`\nFROM `Vendor` AS v\nJOIN `ProductVendor` AS pv ON v.`BusinessEntityID` = pv.`BusinessEntityID`\nJOIN `Product` AS p ON pv.`ProductID` = p.`ProductID`\nWHERE p.`Name` = 'Hex Nut 5'\n AND pv.`StandardPrice` = (\n SELECT MIN(pv2.`StandardPrice`)\n FROM `ProductVendor` AS pv2\n JOIN `Product` AS p2 ON pv2.`ProductID` = p2.`ProductID`\n WHERE p2.`Name` = 'Hex Nut 5');"} {"question_id": 7298, "db_id": "works_cycles", "grading_method": "set", "question": "Please give all the list prices of the product LL Fork.", "evidence": "LL Fork is name of a product", "SQL": "SELECT T2.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'LL Fork'"} {"question_id": 7299, "db_id": "works_cycles", "grading_method": "set", "question": "Among the products from the mountain product line, how many of them are sold by over 2 vendors?", "evidence": "mountain product line refers to ProductLine = 'M'; sold by over 2 vendors refers to count(BusinessEntityID)>2", "SQL": "SELECT COUNT(*) FROM ( SELECT p.`ProductID` FROM `Product` p JOIN `ProductVendor` pv ON p.`ProductID` = pv.`ProductID` WHERE p.`ProductLine` = 'M' GROUP BY p.`ProductID` HAVING COUNT(DISTINCT pv.`BusinessEntityID`) > 2 ) AS sub"} {"question_id": 7303, "db_id": "works_cycles", "grading_method": "set", "question": "Which products bought from suppliers have no units left in inventory? List their names.", "evidence": "Product.MakeFlag = 0 denotes purchased products. ProductInventory.Quantity records units held at a storage location; ProductID identifies the product and LocationID identifies the location. A product with no inventory records has no recorded stock.", "SQL": "SELECT DISTINCT p.Name\nFROM Product AS p\nWHERE p.MakeFlag = 0\n AND COALESCE((SELECT SUM(i.Quantity)\n FROM ProductInventory AS i\n WHERE i.ProductID = p.ProductID), 0) = 0;"} {"question_id": 7313, "db_id": "works_cycles", "grading_method": "set", "question": "Name the oldest employees who are working on night shift. How old are the employees?", "evidence": "working on night shift refers to ShiftID = 3; oldest employee refers to min(BirthDate); age = year(now)-year(BirthDate)-(0 if birthday passed, 1 if not)", "SQL": "SELECT p.`FirstName`, p.`LastName`, CAST( (strftime('%Y','now') - strftime('%Y',e.`BirthDate`)) - (strftime('%m-%d','now') < strftime('%m-%d',e.`BirthDate`)) AS INTEGER) AS Age FROM EmployeeDepartmentHistory dh JOIN Employee e ON e.`BusinessEntityID` = dh.`BusinessEntityID` JOIN Person p ON p.`BusinessEntityID` = e.`BusinessEntityID` WHERE dh.`ShiftID` = 3 AND dh.`EndDate` IS NULL AND e.BirthDate = (SELECT MIN(e.BirthDate) FROM EmployeeDepartmentHistory dh JOIN Employee e ON e.`BusinessEntityID` = dh.`BusinessEntityID` JOIN Person p ON p.`BusinessEntityID` = e.`BusinessEntityID` WHERE dh.`ShiftID` = 3 AND dh.`EndDate` IS NULL) GROUP BY e.`BusinessEntityID`"} {"question_id": 7315, "db_id": "works_cycles", "grading_method": "set", "question": "What is the job title of the oldest employee, and in which department does that employee work?", "evidence": "the oldest employee refers to Employee.BirthDate = MIN(BirthDate) over all Employee rows; that employee's department refers to the EmployeeDepartmentHistory row with EndDate IS NULL, the ongoing assignment; return both that employee's job title and the Department name", "SQL": "SELECT e.JobTitle,\n d.Name AS Department\nFROM Employee e\nJOIN EmployeeDepartmentHistory edh\n ON e.BusinessEntityID = edh.BusinessEntityID\nJOIN Department d\n ON edh.DepartmentID = d.DepartmentID\nWHERE e.BirthDate = (SELECT MIN(BirthDate) FROM Employee)\n AND edh.EndDate IS NULL;"} {"question_id": 7316, "db_id": "works_cycles", "grading_method": "set", "question": "Using each employee’s latest hourly pay rate and current department assignment, give each department’s ID, name, and average hourly pay rate.", "evidence": "an employee's latest hourly pay rate refers to the EmployeePayHistory rate whose RateChangeDate is the MAX for that employee; a current department assignment refers to EmployeeDepartmentHistory.EndDate IS NULL; per department return its ID, its name and AVG(rate) over those latest rates", "SQL": "SELECT d.DepartmentID,\n d.Name,\n AVG(eph.Rate) AS AvgLatestRate\nFROM EmployeeDepartmentHistory edh\nJOIN Department d ON d.DepartmentID = edh.DepartmentID\nJOIN EmployeePayHistory eph ON eph.BusinessEntityID = edh.BusinessEntityID\nWHERE edh.EndDate IS NULL -- current dept (optional)\n AND eph.RateChangeDate = (\n SELECT MAX(eph2.RateChangeDate)\n FROM EmployeePayHistory eph2\n WHERE eph2.BusinessEntityID = eph.BusinessEntityID)\nGROUP BY d.DepartmentID, d.Name;"} {"question_id": 7318, "db_id": "works_cycles", "grading_method": "set", "question": "Name the vendor who has the shortest average lead time for Product ID 319.", "evidence": "", "SQL": "SELECT T1.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 319 ORDER BY T2.AverageLeadTime LIMIT 1"} {"question_id": 7320, "db_id": "works_cycles", "grading_method": "set", "question": "Which vendor provides the highest net profit for product ID 342?", "evidence": "net profit refers to SUBTRACT(ProductVendor.LastReceiptCost, ProductVendor.StandardPrice) over the ProductVendor rows of product ID 342; the vendor that provides the highest net profit refers to every Vendor name whose net profit is equal to the MAX such net profit", "SQL": "WITH sub as (\nSELECT T1.Name, T2.LastReceiptCost - T2.StandardPrice AS profit FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 342\n)\nselect Name from sub where profit = (SELECT max(profit) from sub)"} {"question_id": 7322, "db_id": "works_cycles", "grading_method": "set", "question": "For employees currently assigned to the Research and Development department, what is the average number of calendar years from their hiring year to 2014? Round your answer to 4 decimal places.", "evidence": "Department.Name = 'Research and Development' identifies the department; Department.GroupName is a broader group. Employee.HireDate records hiring date. EmployeeDepartmentHistory.EndDate is NULL for a current assignment.", "SQL": "WITH unrounded(value) AS (\nSELECT AVG(2014 - CAST(strftime('%Y', e.HireDate) AS INTEGER)) FROM Employee e WHERE EXISTS (SELECT 1 FROM EmployeeDepartmentHistory h JOIN Department d ON d.DepartmentID=h.DepartmentID WHERE h.BusinessEntityID=e.BusinessEntityID AND h.EndDate IS NULL AND d.Name='Research and Development')\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 7327, "db_id": "works_cycles", "grading_method": "set", "question": "Which territory is the sales person for store Area Bike Accessories in?", "evidence": "", "SQL": "SELECT T4.Name FROM Store AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN SalesTerritory AS T4 ON T2.TerritoryID = T4.TerritoryID WHERE T1.Name = 'Area Bike Accessories'"} {"question_id": 7328, "db_id": "works_cycles", "grading_method": "set", "question": "Which stores have a sales representative assigned to France? List each store’s name and its representative’s first and last name.", "evidence": "Store.SalesPersonID identifies the store’s assigned salesperson; SalesPerson.TerritoryID identifies their territory. France is recorded as SalesTerritory.Name = 'France'.", "SQL": "SELECT s.`Name` AS StoreName,\n p.`FirstName`,\n p.`LastName`\nFROM `SalesTerritory` t\nJOIN `SalesPerson` sp ON sp.`TerritoryID` = t.`TerritoryID`\nJOIN `Store` s ON s.`SalesPersonID` = sp.`BusinessEntityID`\nJOIN `Person` p ON p.`BusinessEntityID` = sp.`BusinessEntityID`\nWHERE t.`Name` = 'France';"} {"question_id": 7336, "db_id": "works_cycles", "grading_method": "set", "question": "Calculate the average age of current employees in each department. Provide each department name and its average age.", "evidence": "Average = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID)) by each Department ID; current employee refers to EndDate is NULL;", "SQL": "SELECT d.Name AS Department,\n AVG((STRFTIME('%Y', CURRENT_TIMESTAMP) -STRFTIME('%Y', e.BirthDate) ) ) AS avg_age\nFROM Employee e\nJOIN EmployeeDepartmentHistory edh ON e.`BusinessEntityID` = edh.`BusinessEntityID`\nJOIN Department d ON edh.`DepartmentID` = d.`DepartmentID`\nWHERE edh.`EndDate` IS NULL -- current assignment only; omit if historical wanted\nGROUP BY d.`DepartmentID`"} {"question_id": 7339, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the salesperson with the lowest total sales from last year.", "evidence": "total sales from last year refers to SalesPerson.SalesLastYear; the lowest refers to MIN(SalesLastYear); the salesperson refers to SalesPerson.BusinessEntityID; return the BusinessEntityID of every salesperson at that minimum", "SQL": "SELECT BusinessEntityID FROM SalesPerson WHERE SalesLastYear = (SELECT min(SalesLastYear) FROM SalesPerson)"} {"question_id": 7343, "db_id": "works_cycles", "grading_method": "set", "question": "What is the total difference between the actual manufacturing cost of product id 818 and the estimated manufacturing cost?", "evidence": "estimated manufacturing cost refers PlannedCost; actual manufacturing cost refers to ActualCost; difference = Substract(SUM(ActualCost(ProductID(818))),SUM(PlannedCost(ProductID(818))));", "SQL": "SELECT SUM(`ActualCost`) - SUM(`PlannedCost`) AS difference\nFROM `WorkOrderRouting`\nWHERE `ProductID` = 818;"} {"question_id": 7349, "db_id": "works_cycles", "grading_method": "set", "question": "How many vendors does Adventure Works still work with but are not preferable?", "evidence": "not preferable refers to PreferredVendorStatus = 0; still work refers to ActiveFlag = 1;", "SQL": "SELECT COUNT(BusinessEntityID) FROM Vendor WHERE PreferredVendorStatus = 0 AND ActiveFlag = 1"} {"question_id": 7354, "db_id": "works_cycles", "grading_method": "set", "question": "List the names of all bike subcategories.", "evidence": "bikes is product category", "SQL": "SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN ProductCategory AS T2 ON T1.ProductCategoryID = T2.ProductCategoryID WHERE T2.name = 'Bikes'"} {"question_id": 7356, "db_id": "works_cycles", "grading_method": "set", "question": "What goods were sold to customers in accordance with sales order number 43660?", "evidence": "goods refers to product names ", "SQL": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660"} {"question_id": 7357, "db_id": "works_cycles", "grading_method": "set", "question": "Which five products have the largest total number of units ordered? List their names.", "evidence": "units ordered on a sales-order line refers to SalesOrderDetail.OrderQty; total units ordered refers to SUM(OrderQty) grouped by the products' names, not the count of order lines; the five products with the largest total refers to the five greatest such sums; list their names", "SQL": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC LIMIT 0, 5"} {"question_id": 7358, "db_id": "works_cycles", "grading_method": "set", "question": "On which shelves is the \"Down Tube\" product stored?", "evidence": "ProductInventory.Shelf records the shelf or storage compartment.", "SQL": "SELECT T2.Shelf FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Down Tube'"} {"question_id": 7362, "db_id": "works_cycles", "grading_method": "set", "question": "For the business entity with ID 12, list the first line of each address.", "evidence": "", "SQL": "SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12"} {"question_id": 7369, "db_id": "works_cycles", "grading_method": "set", "question": "What is the second-highest distinct hourly pay rate recorded for employees paid monthly?", "evidence": "employees paid monthly refers to EmployeePayHistory.PayFrequency = 1; hourly pay rate refers to EmployeePayHistory.Rate; return the second-highest value among the DISTINCT rates of those records, ordered descending", "SQL": "SELECT DISTINCT Rate FROM EmployeePayHistory WHERE PayFrequency = 1 ORDER BY Rate DESC LIMIT 1, 1"} {"question_id": 7376, "db_id": "works_cycles", "grading_method": "set", "question": "How much profit would selling 10 units of the lightest product generate?", "evidence": "the lightest product refers to the Product with the smallest Weight in grams, a Weight with WeightUnitMeasureCode 'LB' taken as MULTIPLY(Weight, 453.59237) and a 'G' Weight as grams, over Product rows with Weight NOT NULL and WeightUnitMeasureCode 'G' or 'LB'; profit from selling 10 units = MULTIPLY(10, SUBTRACT(ListPrice, StandardCost))", "SQL": "SELECT 10 * (ListPrice - StandardCost)\nFROM Product\nWHERE Weight IS NOT NULL\n AND WeightUnitMeasureCode IN ('G', 'LB')\nORDER BY CASE WeightUnitMeasureCode\n WHEN 'G' THEN Weight\n WHEN 'LB' THEN Weight * 453.59237\nEND\nLIMIT 1"} {"question_id": 7384, "db_id": "works_cycles", "grading_method": "set", "question": "Which department has the most recorded employee assignments to the night shift?", "evidence": "the night shift refers to Shift.Name = 'Night'; employee assignments refers to rows of EmployeeDepartmentHistory; the department with the most refers to the Department.Name with the greatest COUNT of those rows", "SQL": "SELECT T3.Name\nFROM `EmployeeDepartmentHistory` AS T2\nJOIN `Shift` AS T1 ON T1.`ShiftID` = T2.`ShiftID`\nJOIN `Department` AS T3 ON T3.`DepartmentID` = T2.`DepartmentID`\nWHERE T1.`Name` = 'Night'\nGROUP BY T3.`Name`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 7389, "db_id": "works_cycles", "grading_method": "set", "question": "Which non-sales employee created the most rejected purchase orders? Give their first and last names.", "evidence": "Person.PersonType = 'EM' denotes a non-sales employee. PurchaseOrderHeader.EmployeeID identifies the creator; Status = 3 means rejected.", "SQL": "SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) DESC LIMIT 1"} {"question_id": 7399, "db_id": "works_cycles", "grading_method": "set", "question": "What is the description of the seasonal discount that had the highest discount percentage?", "evidence": "seasonal discount is a type of special offer; discount percentage refers to DiscountPct; highest discount percentage refers to MAX(DiscountPct);", "SQL": "SELECT `Description`\nFROM `SpecialOffer`\nWHERE `Type` = 'Seasonal Discount'\n AND `DiscountPct` = (\n SELECT MAX(`DiscountPct`)\n FROM `SpecialOffer`\n WHERE `Type` = 'Seasonal Discount'\n );"} {"question_id": 7403, "db_id": "works_cycles", "grading_method": "set", "question": "What is the minimum inventory quantity of Chainring Bolts?", "evidence": "minimum inventory quantity refers to SafetyStockLevel; chainring bolts is a name of product;", "SQL": "SELECT SafetyStockLevel FROM Product WHERE Name = 'Chainring Bolts'"} {"question_id": 7410, "db_id": "works_cycles", "grading_method": "set", "question": "What is the hashed password of David Bradley?", "evidence": "hashed password refers to PasswordHash;", "SQL": "SELECT T2.PasswordHash FROM Person AS T1 INNER JOIN Password AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'"} {"question_id": 7418, "db_id": "works_cycles", "grading_method": "set", "question": "How many different employees worked in Engineering at any time during 2009?", "evidence": "EmployeeDepartmentHistory.StartDate and EndDate delimit a department assignment; NULL EndDate denotes an ongoing assignment. Department.Name records the department name.", "SQL": "SELECT COUNT(DISTINCT edh.BusinessEntityID)\nFROM EmployeeDepartmentHistory AS edh\nJOIN Department AS d ON edh.DepartmentID = d.DepartmentID\nWHERE d.Name = 'Engineering'\n AND edh.StartDate <= '2009-12-31'\n AND (edh.EndDate IS NULL OR edh.EndDate >= '2009-01-01');"} {"question_id": 7422, "db_id": "works_cycles", "grading_method": "set", "question": "How many employees working in the Engineering Department in 2007 would have their credit cards expired in the same year?", "evidence": "year(StartDate) 2007; year of credit card expiration refers to ExpYear; ExpYear = 2007;", "SQL": "SELECT COUNT(DISTINCT edh.BusinessEntityID)\nFROM EmployeeDepartmentHistory AS edh\nJOIN Department AS d ON edh.DepartmentID = d.DepartmentID\nJOIN PersonCreditCard AS pc ON edh.BusinessEntityID = pc.BusinessEntityID\nJOIN CreditCard AS cc ON pc.CreditCardID = cc.CreditCardID\nWHERE d.`Name` = 'Engineering'\n AND cc.ExpYear = 2007\n AND edh.StartDate <= '2007-12-31'\n AND (edh.EndDate IS NULL OR edh.EndDate >= '2007-01-01');"} {"question_id": 7423, "db_id": "works_cycles", "grading_method": "set", "question": "Which employee changed departments the most times? List their email address.", "evidence": "a department change refers to an EmployeeDepartmentHistory row whose department is not the same as that employee's previous row in date order, changing shifts within the same department not counting; changed departments the most refers to the greatest count of such rows for an employee; return the email address of that employee", "SQL": "WITH ordered AS (\n SELECT BusinessEntityID, DepartmentID,\n LAG(DepartmentID) OVER (\n PARTITION BY BusinessEntityID\n ORDER BY StartDate\n ) AS previous_department\n FROM EmployeeDepartmentHistory\n),\nchanges AS (\n SELECT BusinessEntityID,\n SUM(CASE\n WHEN previous_department IS NOT NULL\n AND DepartmentID <> previous_department\n THEN 1 ELSE 0\n END) AS change_count\n FROM ordered\n GROUP BY BusinessEntityID\n)\nSELECT DISTINCT T1.EmailAddress\nFROM EmailAddress AS T1\nINNER JOIN changes AS T2\n ON T1.BusinessEntityID = T2.BusinessEntityID\nWHERE T2.change_count = (\n SELECT MAX(change_count) FROM changes\n);"} {"question_id": 7424, "db_id": "works_cycles", "grading_method": "set", "question": "Among all the employees who don't wish to receive promotion e-mails, how many of them belong to or once belonged to the Engineering Department?", "evidence": "Employees who don't wish to receive e-mail promotions refers to EmailPromotion = 0;", "SQL": "SELECT COUNT(DISTINCT T1.`BusinessEntityID`)\nFROM `EmployeeDepartmentHistory` AS T1\nJOIN `Person` AS T2 ON T1.`BusinessEntityID` = T2.`BusinessEntityID`\nJOIN `Department` AS T3 ON T1.`DepartmentID` = T3.`DepartmentID`\nWHERE T3.`Name` = 'Engineering'\n AND T2.`EmailPromotion` = 0;"} {"question_id": 7430, "db_id": "works_cycles", "grading_method": "set", "question": "Please list the names of products that are under the Components category that are manufactured in-house and salable.", "evidence": "product is manufactured in-house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1;", "SQL": "SELECT p.`Name`\nFROM `Product` AS p\nJOIN `ProductSubcategory` AS s ON p.`ProductSubcategoryID` = s.`ProductSubcategoryID`\nJOIN `ProductCategory` AS c ON s.`ProductCategoryID` = c.`ProductCategoryID`\nWHERE c.`Name` = 'Components'\n AND p.`MakeFlag` = 1\n AND p.`FinishedGoodsFlag` = 1;"} {"question_id": 7434, "db_id": "works_cycles", "grading_method": "set", "question": "What is the average profit of all the products from the Clothing category?", "evidence": "average profit = DIVIDE(SUM(SUBTRACT(ListPrice, StandardCost)), COUNT(ProductSubcategoryID));", "SQL": "SELECT SUM(T1.ListPrice - T1.StandardCost) / COUNT(T1.ProductID) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T3.Name = 'Clothing'"} {"question_id": 7435, "db_id": "works_cycles", "grading_method": "set", "question": "Which product cost the least in 2013?", "evidence": "cost refers to StandardCost; cost the least refers to MIN(StandardCost); which product refers to name", "SQL": "SELECT p.`Name`\nFROM `ProductCostHistory` h\nJOIN `Product` p ON p.`ProductID` = h.`ProductID`\nWHERE h.`StartDate` <= '2013-12-31'\n AND (h.`EndDate` IS NULL OR h.`EndDate` >= '2013-01-01')\n AND h.`StandardCost` = (\n SELECT min(h.StandardCost) FROM `ProductCostHistory` h\nJOIN `Product` p ON p.`ProductID` = h.`ProductID`\nWHERE h.`StartDate` <= '2013-12-31'\n AND (h.`EndDate` IS NULL OR h.`EndDate` >= '2013-01-01')\n )"} {"question_id": 7444, "db_id": "works_cycles", "grading_method": "set", "question": "What is the name of the product stored in location 1 compartment L container 6?", "evidence": "compartment refers to Shelf;", "SQL": "SELECT T2.Name FROM ProductInventory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.LocationID = 1 AND T1.Shelf = 'L' AND T1.Bin = 6"} {"question_id": 7451, "db_id": "works_cycles", "grading_method": "set", "question": "How many units of product ID 476 are stored in Metal Storage?", "evidence": "ProductInventory.Quantity records units in stock; Location.Name identifies Metal Storage.", "SQL": "SELECT T2.Quantity FROM Location AS T1 INNER JOIN ProductInventory AS T2 ON T1.LocationID = T2.LocationID WHERE T2.ProductID = 476 AND T1.Name = 'Metal Storage'"} {"question_id": 7455, "db_id": "works_cycles", "grading_method": "set", "question": "How many days elapsed between the start and end of work order ID 425?", "evidence": "work order ID 425 refers to WorkOrder.WorkOrderID = 425; days elapsed = SUBTRACT(JULIANDAY(WorkOrder.EndDate), JULIANDAY(WorkOrder.StartDate))", "SQL": "SELECT JULIANDAY(`EndDate`) - JULIANDAY(`StartDate`) AS days_to_finish\nFROM `WorkOrder`\nWHERE `WorkOrderID` = 425;"} {"question_id": 7458, "db_id": "works_cycles", "grading_method": "set", "question": "What is the organization level for Human Resources Manager?", "evidence": "Human Resources Manager is a job title", "SQL": "SELECT OrganizationLevel FROM Employee WHERE JobTitle = 'Human Resources Manager'"} {"question_id": 7460, "db_id": "works_cycles", "grading_method": "set", "question": "What are the cost and product number of the product with ID 888?", "evidence": "Product.StandardCost records cost; Product.ProductNumber records the product number.", "SQL": "SELECT T2.StandardCost, T2.ProductNumber FROM Product AS T2 WHERE T2.ProductID = 888"} {"question_id": 7462, "db_id": "works_cycles", "grading_method": "set", "question": "List the location IDs, compartments, and containers for the Lock Ring.", "evidence": "ProductInventory.Shelf records the compartment and ProductInventory.Bin records the container. Product.Name uses 'Lock Ring'.", "SQL": "SELECT T2.LocationID, T2.Shelf, T2.Bin FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Lock Ring'"} {"question_id": 7464, "db_id": "works_cycles", "grading_method": "set", "question": "List the IDs of work orders with \"Handling damage\" as the scrap reason.", "evidence": "ScrapReason.Name uses 'Handling damage'.", "SQL": "SELECT T2.WorkOrderID FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Handling damage'"} {"question_id": 7468, "db_id": "works_cycles", "grading_method": "set", "question": "What is the name of the product the work order \"2540\" was making?", "evidence": "", "SQL": "SELECT T2.Name FROM WorkOrder AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.WorkOrderID = 2540"} {"question_id": 7477, "db_id": "image_and_language", "grading_method": "set", "question": "How many self-relations are there between the object samples in image no.5?", "evidence": "self-relations refers to OBJ1_SAMPLE_ID = OBJ2_SAMPLE_ID; image no.5 refers to IMG_ID = 5", "SQL": "SELECT SUM(CASE WHEN IMG_ID = 5 THEN 1 ELSE 0 END) FROM IMG_REL WHERE OBJ1_SAMPLE_ID = OBJ2_SAMPLE_ID"} {"question_id": 7480, "db_id": "image_and_language", "grading_method": "set", "question": "How many images have at least one object sample in the class of \"man\"?", "evidence": "have at least one object sample in the class of \"man\" refers to count(IMG_ID where OBJ_CLASS = 'man') > = 1", "SQL": "SELECT COUNT(T.IMG_ID) FROM ( SELECT T2.IMG_ID FROM OBJ_CLASSES AS T1 INNER JOIN IMG_OBJ AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.OBJ_CLASS = 'man' GROUP BY T2.IMG_ID ) T"} {"question_id": 7483, "db_id": "image_and_language", "grading_method": "set", "question": "How many pairs of object samples in image no.1 have the relation of \"parked on\"?", "evidence": "pairs of object samples refers to OBJ1_SAMPLE_ID and OBJ2_SAMPLE_ID; image no.1 refers to IMG_ID = 1; relation of \"parked on\" refers to PRED_CLASS = 'parked on'", "SQL": "SELECT SUM(CASE WHEN T1.PRED_CLASS = 'parked on' THEN 1 ELSE 0 END) FROM PRED_CLASSES AS T1 INNER JOIN IMG_REL AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T2.IMG_ID = 1 AND T2.OBJ1_SAMPLE_ID != OBJ2_SAMPLE_ID"} {"question_id": 7492, "db_id": "image_and_language", "grading_method": "set", "question": "How many object classes are there in the database?", "evidence": "object classes refers to OBJ_CLASS", "SQL": "SELECT COUNT(OBJ_CLASS_ID) FROM OBJ_CLASSES"} {"question_id": 7495, "db_id": "image_and_language", "grading_method": "set", "question": "How many white objects are there in image no.2347915?", "evidence": "white objects refers to ATT_CLASS = 'white'; image no.2347915 refers to IMG_ID = 2347915", "SQL": "SELECT SUM(CASE WHEN T2.ATT_CLASS = 'white' THEN 1 ELSE 0 END) FROM IMG_OBJ_ATT AS T1 INNER JOIN ATT_CLASSES AS T2 ON T1.ATT_CLASS_ID = T2.ATT_CLASS_ID WHERE T1.IMG_ID = 2347915"} {"question_id": 7497, "db_id": "image_and_language", "grading_method": "set", "question": "What is the relationship between object sample no.12 and no.8 of image no.2345511?", "evidence": "relationship refers to PRED_CLASS; object sample no.12 and no.8 of image no.2345511 refers to IMG_ID = 2345511 AND OBJ1_SAMPLE_ID = 12 AND OBJ2_SAMPLE_ID = 8", "SQL": "SELECT T1.PRED_CLASS FROM PRED_CLASSES AS T1 INNER JOIN IMG_REL AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T2.IMG_ID = 2345511 AND T2.OBJ1_SAMPLE_ID = 12 AND T2.OBJ2_SAMPLE_ID = 8"} {"question_id": 7508, "db_id": "image_and_language", "grading_method": "set", "question": "List all the ids of the images that have a self-relation relationship.", "evidence": "ids of the images refers to IMG_ID; self-relations refers to OBJ1_SAMPLE_ID = OBJ2_SAMPLE_ID", "SQL": "SELECT DISTINCT IMG_ID FROM IMG_REL WHERE OBJ1_SAMPLE_ID = OBJ2_SAMPLE_ID"} {"question_id": 7523, "db_id": "image_and_language", "grading_method": "set", "question": "How many images show an “on” relationship between two different objects?", "evidence": "OBJ1_SAMPLE_ID and OBJ2_SAMPLE_ID identify the two objects in a relation. PRED_CLASS = 'on' denotes an “on” relationship.", "SQL": "SELECT COUNT(DISTINCT T1.IMG_ID) FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.OBJ1_SAMPLE_ID != T1.OBJ2_SAMPLE_ID AND T2.PRED_CLASS = 'on';"} {"question_id": 7525, "db_id": "image_and_language", "grading_method": "set", "question": "Provide the dimensions of the bounding box that contains the keyboard that was spotted in image no. 3.", "evidence": "dimensions of the bounding box refers to (W, H); keyboard refers to OBJ_CLASS = 'keyboard'; image no. 3 refers to IMG_ID = 3", "SQL": "SELECT T1.W, T1.H FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 3 AND T2.OBJ_CLASS = 'keyboard'"} {"question_id": 7527, "db_id": "image_and_language", "grading_method": "set", "question": "Define the onion's bounding box on image no. 285930.", "evidence": "bounding box refers to (X, Y, W, H); onion refers to OBJ_CLASS = 'onion'; image no.285930 refers to IMG_ID = 285930", "SQL": "SELECT T1.X, T1.Y, T1.W, T1.H FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 285930 AND T2.OBJ_CLASS = 'onion'"} {"question_id": 7528, "db_id": "image_and_language", "grading_method": "set", "question": "What objects can be identified on the image no. 72 and within the bounding box represented as (341, 27, 42, 51)?", "evidence": " image no. 72 refers to IMG_ID = 72; What objects refers to OBJ_CLASS; bounding box represented as (341, 27, 42, 51) refers to X = 341 and Y = 27 and W = 42 and H = 51", "SQL": "SELECT DISTINCT OC.`OBJ_CLASS`\nFROM `IMG_OBJ` IO\nJOIN `OBJ_CLASSES` OC ON IO.`OBJ_CLASS_ID` = OC.`OBJ_CLASS_ID`\nWHERE IO.`IMG_ID` = 72\n AND IO.`X` = 341 AND IO.`Y` = 27\n AND IO.`W` = 42 AND IO.`H` = 51;"} {"question_id": 7530, "db_id": "image_and_language", "grading_method": "set", "question": "What attributes are used to describe the wall on image no. 27.", "evidence": "What attributes refers to ATT_CLASS; wall on image no. 27 refers to OBJ_CLASS = 'wall' and IMG_ID = 27", "SQL": "SELECT T4.ATT_CLASS \nFROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID \nINNER JOIN IMG_OBJ_ATT AS T3 ON T1.IMG_ID = T3.IMG_ID AND T3.OBJ_SAMPLE_ID = T1.OBJ_SAMPLE_ID INNER JOIN ATT_CLASSES AS T4 ON T3.ATT_CLASS_ID = T4.ATT_CLASS_ID \nWHERE T2.OBJ_CLASS = 'wall' AND T1.IMG_ID = 27 GROUP BY T4.ATT_CLASS"} {"question_id": 7534, "db_id": "image_and_language", "grading_method": "set", "question": "What attributes are recorded for the van in image 1?", "evidence": "IMG_OBJ.IMG_ID identifies the image; OBJ_CLASSES.OBJ_CLASS = 'van' identifies vans. ATT_CLASSES.ATT_CLASS contains attribute labels associated with object samples through IMG_OBJ_ATT.", "SQL": "SELECT DISTINCT ac.`ATT_CLASS` FROM `IMG_OBJ` AS io JOIN `OBJ_CLASSES` AS oc ON oc.`OBJ_CLASS_ID` = io.`OBJ_CLASS_ID` JOIN `IMG_OBJ_ATT` AS ia ON ia.`IMG_ID` = io.`IMG_ID` AND ia.`OBJ_SAMPLE_ID` = io.`OBJ_SAMPLE_ID` JOIN `ATT_CLASSES` AS ac ON ac.`ATT_CLASS_ID` = ia.`ATT_CLASS_ID` WHERE oc.`OBJ_CLASS` = 'van' AND io.`IMG_ID` = 1"} {"question_id": 7536, "db_id": "image_and_language", "grading_method": "set", "question": "What is the relationship between object sample no. 25 and object sample no. 2 on image no. 1?", "evidence": "relationship refers to PRED_CLASS; object sample no. 25 and object sample no. 2 refers to (OBJ1_SAMPLE_ID = 25 and OBJ2_SAMPLE_ID = 2) or (OBJ1_SAMPLE_ID = 2 and OBJ2_SAMPLE_ID = 25); image no. 1 refers to IMG_ID = 1", "SQL": "SELECT DISTINCT P.`PRED_CLASS`\nFROM `IMG_REL` AS R\nJOIN `PRED_CLASSES` AS P ON P.`PRED_CLASS_ID` = R.`PRED_CLASS_ID`\nWHERE R.`IMG_ID` = 1\n AND ( (R.`OBJ1_SAMPLE_ID` = 25 AND R.`OBJ2_SAMPLE_ID` = 2)\n OR (R.`OBJ1_SAMPLE_ID` = 2 AND R.`OBJ2_SAMPLE_ID` = 25) );"} {"question_id": 7544, "db_id": "image_and_language", "grading_method": "set", "question": "List the object classes for objects with bounding box (422, 63, 77, 363).", "evidence": "Bounding boxes use (IMG_OBJ.X, IMG_OBJ.Y, IMG_OBJ.W, IMG_OBJ.H): position followed by width and height. OBJ_CLASSES.OBJ_CLASS is the class label.", "SQL": "SELECT T2.OBJ_CLASS FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.X = 422 AND T1.Y = 63 AND T1.W = 77 AND T1.H = 363"} {"question_id": 7545, "db_id": "image_and_language", "grading_method": "set", "question": "What is the caption for the prediction class id 12?", "evidence": "caption for the prediction class id 12 refers to PRED_CLASS where PRED_CLASS_ID = 12;", "SQL": "SELECT PRED_CLASS FROM PRED_CLASSES WHERE PRED_CLASS_ID = 12"} {"question_id": 7547, "db_id": "image_and_language", "grading_method": "set", "question": "How many object samples in image no.908 are in the class of tip?", "evidence": "object samples in the class of \"tip\" refer to OBJ_CLASS_ID where OBJ_CLASS = 'tip'; image no.908 refers to IMG_ID = 908;", "SQL": "SELECT SUM(CASE WHEN T2.OBJ_CLASS = 'tip' THEN 1 ELSE 0 END) FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 908"} {"question_id": 7551, "db_id": "image_and_language", "grading_method": "set", "question": "Which object class ids belong to the onion category?", "evidence": "onion category refers to OBJ_CLASS = 'onion';", "SQL": "SELECT OBJ_CLASS_ID FROM OBJ_CLASSES WHERE OBJ_CLASS = 'onion'"} {"question_id": 7557, "db_id": "image_and_language", "grading_method": "set", "question": "How many samples of animal objects are there in image no.660?", "evidence": "samples of animal objects refer to OBJ_SAMPLE_ID where OBJ_CLASS = 'animal'; image no.660 refers to IMG_ID = 660;", "SQL": "SELECT COUNT(T1.IMG_ID) FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T2.OBJ_CLASS = 'animal' AND T1.IMG_ID = 660"} {"question_id": 7561, "db_id": "image_and_language", "grading_method": "set", "question": "Which images have more than 20 object samples?", "evidence": "images have more than 20 object samples refer to IMG_ID where COUNT(OBJ_SAMPLE_ID) > 20;", "SQL": "SELECT IMG_ID FROM IMG_OBJ GROUP BY IMG_ID HAVING COUNT(IMG_ID) > 20"} {"question_id": 7568, "db_id": "image_and_language", "grading_method": "set", "question": "List all the object classes in image 10.", "evidence": "object classes refer to OBJ_CLASS; image 10 refers to IMG_ID = 10;", "SQL": "SELECT DISTINCT T2.OBJ_CLASS FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 10"} {"question_id": 7574, "db_id": "image_and_language", "grading_method": "set", "question": "State the width and height of the object with the class of 'van' in image 1.", "evidence": "The bounding box's W and H abbreviations stand for the object's width and height respectively; class of 'van' in image 1 refers to OBJ_CLASS = 'van' where IMG_ID = 1;", "SQL": "SELECT T1.W, T1.H FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 1 AND T2.OBJ_CLASS = 'van'"} {"question_id": 7579, "db_id": "image_and_language", "grading_method": "set", "question": "How many images have less than 15 object samples?", "evidence": "images refer to IMG_ID; less than 15 object samples refer to COUNT(OBJ_SAMPLE_ID) < 15;", "SQL": "SELECT COUNT(*) FROM ( SELECT `IMG_ID` FROM `IMG_OBJ` GROUP BY `IMG_ID` HAVING COUNT(`OBJ_SAMPLE_ID`) < 15 ) AS few_objects"} {"question_id": 7580, "db_id": "image_and_language", "grading_method": "set", "question": "How many images have exactly ten different attribute classes?", "evidence": "exactly ten different attribute classes refers to COUNT(DISTINCT IMG_OBJ_ATT.ATT_CLASS_ID) = 10 for one IMG_OBJ_ATT.IMG_ID; how many images refers to the COUNT of IMG_ID groups meeting that condition", "SQL": "SELECT COUNT(*) FROM ( SELECT `IMG_ID` FROM `IMG_OBJ_ATT` GROUP BY `IMG_ID` HAVING COUNT(DISTINCT `ATT_CLASS_ID`) = 10 ) AS t"} {"question_id": 7587, "db_id": "image_and_language", "grading_method": "set", "question": "List the IDs of all images with the attribute class horse.", "evidence": "Attribute labels are recorded in ATT_CLASSES.ATT_CLASS; IMG_OBJ_ATT associates attribute classes with image objects.", "SQL": "SELECT DISTINCT T2.IMG_ID FROM ATT_CLASSES AS T1 INNER JOIN IMG_OBJ_ATT AS T2 ON T1.ATT_CLASS_ID = T2.ATT_CLASS_ID WHERE T1.ATT_CLASS = 'horse'"} {"question_id": 7605, "db_id": "image_and_language", "grading_method": "set", "question": "What is the predicate class of image ID 68?", "evidence": "predicate class of image ID 68 refers to PRED_CLASS where IMG_ID = 68;", "SQL": "SELECT T2.PRED_CLASS FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.IMG_ID = 68"} {"question_id": 7628, "db_id": "hockey", "grading_method": "set", "question": "Which goalies had season totals of exactly one shutout for every 20 goals conceded? List their first names, last names, and seasons.", "evidence": "season totals refers to SUM(SHO) and SUM(GA) per Goalies.playerID and year (several records in a season are summed), keeping seasons with SUM(GA) > 0; one shutout per 20 goals conceded refers to MULTIPLY(SUM(SHO), 20) = SUM(GA); return Master.firstName, Master.lastName and year, ordered by year, lastName, firstName", "SQL": "WITH season_totals AS (\n SELECT playerID,\n year,\n SUM(CAST(SHO AS INTEGER)) AS tot_SHO,\n SUM(CAST(GA AS INTEGER)) AS tot_GA\n FROM Goalies\n GROUP BY playerID, year\n HAVING tot_GA > 0\n AND 20 * tot_SHO = tot_GA -- exactly 5 %\n)\nSELECT M.firstName,\n M.lastName,\n S.year\nFROM season_totals S\nJOIN Master M ON M.playerID = S.playerID\nORDER BY S.year, M.lastName, M.firstName;"} {"question_id": 7644, "db_id": "hockey", "grading_method": "set", "question": "What is the first name of player aebisda01, and what was his average regular-season playing time per game as a goaltender, in minutes?", "evidence": "player aebisda01 refers to the Master row for aebisda01 and his Goalies rows; average regular-season playing time per game refers to DIVIDE(SUM(Min), SUM(GP)) over those Goalies rows, in minutes; return both Master.firstName and that average", "SQL": "SELECT\n M.`firstName`,\n SUM(CAST(G.`Min` AS REAL)) / SUM(CAST(G.`GP` AS REAL)) AS avg_minutes\nFROM `Master` AS M\nJOIN `Goalies` AS G ON M.`playerID` = G.`playerID`\nWHERE M.`playerID` = 'aebisda01'\nGROUP BY M.`playerID`, M.`firstName`;"} {"question_id": 7647, "db_id": "hockey", "grading_method": "set", "question": "Among players with an award record in 1983, how many were listed as goalies in an award record that year?", "evidence": "AwardsPlayers.pos = 'G' identifies a goalie in an award record; AwardsPlayers.year records award year.", "SQL": "SELECT COUNT(DISTINCT `playerID`) FROM `AwardsPlayers` WHERE `year` = 1983 AND `pos` = 'G'"} {"question_id": 7656, "db_id": "hockey", "grading_method": "set", "question": "Please list the Nicknames of the players who got in the Hall of Fame in 2007.", "evidence": "nicknames refers to nameNick", "SQL": "SELECT DISTINCT M.`nameNick`\nFROM `Master` AS M\nJOIN `HOF` AS H ON M.`hofID` = H.`hofID`\nWHERE H.`year` = 2007\n AND H.`category` = 'Player'\n AND M.`nameNick` IS NOT NULL;"} {"question_id": 7659, "db_id": "hockey", "grading_method": "set", "question": "Among the coaches whose team has over 30 wins in a year, how many of them are born in the USA?", "evidence": "over 30 wins refers to w>30; born in the USA refers to birthCountry = 'USA'", "SQL": "SELECT COUNT(DISTINCT T2.`coachID`) FROM `Master` AS T1 JOIN `Coaches` AS T2 ON T1.`coachID` = T2.`coachID` WHERE T2.`w` > 30 AND T1.`birthCountry` = 'USA'"} {"question_id": 7663, "db_id": "hockey", "grading_method": "set", "question": "Among the coaches who have received an award after the year 1940, how many of them have already died?", "evidence": "after the year 1940 refers to year>1940; have already died refers to deathYear IS NOT NULL", "SQL": "SELECT COUNT(DISTINCT m.coachID) FROM Master AS m JOIN AwardsCoaches AS ac ON m.coachID = ac.coachID WHERE m.deathYear IS NOT NULL AND ac.year > 1940"} {"question_id": 7667, "db_id": "hockey", "grading_method": "set", "question": "Among the players who became coaches, how many of them have gotten in the Hall of Fame?", "evidence": "players who became coaches refers to playerID IS NOT NULL AND coachID IS NOT NULL", "SQL": "SELECT COUNT(T1.playerID) FROM Master AS T1 INNER JOIN HOF AS T2 ON T1.hofID = T2.hofID WHERE T1.playerID IS NOT NULL AND T1.coachID IS NOT NULL"} {"question_id": 7671, "db_id": "hockey", "grading_method": "set", "question": "How many award-winning players died in Massachusetts?", "evidence": "Master.deathState = 'MA' denotes Massachusetts; AwardsPlayers records award recipients.", "SQL": "SELECT COUNT(DISTINCT T1.playerID) FROM Master AS T1 INNER JOIN AwardsPlayers AS T2 ON T1.playerID = T2.playerID WHERE T1.deathState = 'MA'"} {"question_id": 7697, "db_id": "hockey", "grading_method": "set", "question": "Which teams had the highest total postseason empty-net goals across their goalie records in 2010? Give their names.", "evidence": "in 2010 refers to Goalies.year = 2010; a team's total refers to SUM(CAST(PostENG AS INT)) over its goalie records that year, with a missing PostENG counted as 0; return the Teams.name (matched on tmID with year = 2010) of every team whose total equals the maximum", "SQL": "WITH team_eng AS (\n SELECT tmID,\n SUM(CASE WHEN PostENG IS NOT NULL THEN CAST(PostENG AS INT) ELSE 0 END) AS total_eng\n FROM Goalies\n WHERE year = 2010\n GROUP BY tmID\n),\nmax_val AS (\n SELECT MAX(total_eng) AS max_eng FROM team_eng\n)\nSELECT T.name\nFROM team_eng te\nJOIN max_val mv ON te.total_eng = mv.max_eng\nJOIN Teams T ON T.tmID = te.tmID AND T.year = 2010;"} {"question_id": 7698, "db_id": "hockey", "grading_method": "set", "question": "For the team which had the most postseason shutouts in 1995, how many points did they have that year?", "evidence": "points refer to Pts; the most postseason shutouts refers to max(PostSHO)", "SQL": "WITH team_post AS (\n SELECT `tmID`,\n SUM(CAST(COALESCE(`PostSHO`, '0') AS INTEGER)) AS post_sho\n FROM `Goalies`\n WHERE `year` = 1995\n GROUP BY `tmID`\n),\nmax_team AS (\n SELECT `tmID`\n FROM team_post\n WHERE post_sho = (SELECT MAX(post_sho) FROM team_post)\n)\nSELECT `Pts`\nFROM `Teams`\nWHERE `year` = 1995\n AND `tmID` IN (SELECT `tmID` FROM max_team);"} {"question_id": 7710, "db_id": "hockey", "grading_method": "set", "question": "Which is the catching hand for the goaltender who had the most shutouts in 1996?", "evidence": "the most shutouts refers to max(SUM(SHO)); catching hand for the goaltender refers to shootCatch;", "SQL": "SELECT M.`shootCatch`\nFROM Master AS M\nJOIN (\n SELECT `playerID`, SUM(CAST(`SHO` AS INT)) AS total_sho\n FROM Goalies\n WHERE `year` = 1996\n GROUP BY `playerID`\n ORDER BY total_sho DESC\n LIMIT 1\n) AS g ON M.`playerID` = g.`playerID`;"} {"question_id": 7713, "db_id": "hockey", "grading_method": "set", "question": "What are the weights of all the players who had the most Power Play Goals in the 21st century?", "evidence": "21st century refers to year >2000; Power play goals refers to PPG", "SQL": "WITH player_totals AS ( SELECT s.playerID, SUM(s.PPG) AS totalPPG FROM Scoring s WHERE s.year > 2000 GROUP BY s.playerID ), max_val AS ( SELECT MAX(totalPPG) AS maxPPG FROM player_totals ) SELECT DISTINCT m.weight FROM player_totals p JOIN max_val mx ON p.totalPPG = mx.maxPPG JOIN Master m ON m.playerID = p.playerID"} {"question_id": 7717, "db_id": "hockey", "grading_method": "set", "question": "List the first and last names of the coaches of the teams with the most bench-minor penalty minutes in 2003.", "evidence": "coaches refers to firstName and lastName; 2003 refers to Teams.year = 2003; bench-minor penalty minutes refers to the numeric value of Teams.BenchMinor; select the teams with the highest value in 2003 and return all of their coaches for that year;", "SQL": "SELECT DISTINCT T3.firstName, T3.lastName FROM Teams AS T1 INNER JOIN Coaches AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year INNER JOIN Master AS T3 ON T2.coachID = T3.coachID WHERE T1.year = 2003 AND CAST(T1.BenchMinor AS REAL) = (SELECT MAX(CAST(BenchMinor AS REAL)) FROM Teams WHERE year = 2003)"} {"question_id": 7746, "db_id": "hockey", "grading_method": "set", "question": "In 1997, how many losses did the coach who temporarily coached Tampa Bay Lightning have? Include the coach ID.", "evidence": "Interim coaching is recorded as Coaches.notes = 'interim'; Coaches.l records losses. Team names are recorded in Teams.name.", "SQL": "SELECT SUM(T1.l), T1.coachID FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.notes = 'interim' AND T1.year = '1997' AND T2.name = 'Tampa Bay Lightning' GROUP BY T1.coachID"} {"question_id": 7747, "db_id": "hockey", "grading_method": "set", "question": "Among players who recorded at least seven short-handed assists during a stint with one team, who recorded the most assists in that stint? List their team’s final standing, the year, and the team name.", "evidence": "Scoring records a player’s statistics for a stint with a team in a season; Scoring.stint identifies the stint. Scoring.SHA records short-handed assists, and Scoring.A records assists. Teams.rank records the team’s final standing; Teams.year and Teams.name record the year and team name.", "SQL": "SELECT TM.`rank`, TM.`year`, TM.`name` FROM `Scoring` AS S JOIN `Teams` AS TM ON S.`year` = TM.`year` AND S.`tmID` = TM.`tmID` WHERE CAST(S.`SHA` AS integer) >= 7 AND CAST(S.`A` AS integer) = (SELECT MAX(CAST(S2.`A` AS integer)) FROM `Scoring` AS S2 JOIN `Teams` AS TM2 ON S2.`year` = TM2.`year` AND S2.`tmID` = TM2.`tmID` WHERE CAST(S2.`SHA` AS integer) >= 7);"} {"question_id": 7754, "db_id": "hockey", "grading_method": "set", "question": "Among the teams that had more wins than loses in the year 2006, how many of them have over 100 points?", "evidence": "more wins than loses refers to W > L; over 100 points refers to Pts > 100", "SQL": "SELECT COUNT(tmID) FROM Teams WHERE year = 2006 AND W > L AND Pts > 100"} {"question_id": 7756, "db_id": "hockey", "grading_method": "set", "question": "Please list the three teams with the most penalty minutes in 2006.", "evidence": "in 2006 refers to Teams.year = 2006; a team's penalty minutes refers to SUM(Teams.PIM) over that team's 2006 rows; return the Teams.name of the three teams with the greatest such SUM, ORDER BY SUM(PIM) DESC LIMIT 3", "SQL": "SELECT name FROM Teams WHERE year = 2006 GROUP BY tmID, name ORDER BY SUM(PIM) DESC LIMIT 3"} {"question_id": 7759, "db_id": "hockey", "grading_method": "set", "question": "Please list the teams that have played in 1922's Stanley Cup finals.", "evidence": "teams refer to name; year = 1922; Stanley Cup finals refer to round='SCF'", "SQL": "SELECT DISTINCT T.name\nFROM (\n SELECT tmIDWinner AS tmID\n FROM SeriesPost\n WHERE year = 1922 AND round = 'SCF'\n UNION ALL\n SELECT tmIDLoser AS tmID\n FROM SeriesPost\n WHERE year = 1922 AND round = 'SCF'\n ) AS F\nJOIN Teams AS T\n ON T.year = 1922 AND T.tmID = F.tmID;"} {"question_id": 7762, "db_id": "hockey", "grading_method": "set", "question": "Which teams have won the most Stanley Cup Final games?", "evidence": "Stanley Cup Final games refers to SeriesPost rows with round = 'SCF'; in such a row a team's game wins are W when it is the tmIDWinner and L when it is the tmIDLoser; a team's Stanley Cup Final wins = SUM of both over all 'SCF' rows; the most refers to the greatest such total; return the DISTINCT Teams.name of every team that reaches it", "SQL": "with win_sub as (\nselect tmid, SUM(win) as win_num\nFROM (select tmIDWinner as tmID, W as win\nfrom SeriesPost\nwhere round='SCF'\nUNION ALL\nselect tmIDLoser as tmID, L as win\nfrom SeriesPost\nwhere round='SCF'\n)\nGROUP BY tmID\n)\nselect DISTINCT t.name\nFROM win_sub w INNER JOIN Teams t ON w.tmID = t.tmID\nWHERE win_num = (SELECT max(win_num) from win_sub)"} {"question_id": 7780, "db_id": "hockey", "grading_method": "set", "question": "What was the Buffalo Sabres’ winning rate in the 2000 season, expressed as a fraction of games won?", "evidence": "Buffalo Sabres refers to Teams.name = 'Buffalo Sabres'; the 2000 season refers to Teams.year = 2000; winning rate = DIVIDE(Teams.W, Teams.G) as a real fraction of games won, not multiplied by 100", "SQL": "SELECT CAST(`W` AS REAL) / `G` AS winning_rate\nFROM `Teams`\nWHERE `name` = 'Buffalo Sabres' AND `year` = 2000;"} {"question_id": 7791, "db_id": "hockey", "grading_method": "set", "question": "Which was the dominant hand for the goaltender who played 32 games for QUN in 1973? Give the full name.", "evidence": "the dominant hand refers to shootCatch; year = 1973; tmID = 'QUN'; played 32 games refers to GP = 32; full name refers to firstName, lastName", "SQL": "SELECT T2.shootCatch, T2.firstName, T2.lastName FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID AND T1.year = 1973 WHERE T1.tmID = 'QUN' AND T1.GP = 32"} {"question_id": 7793, "db_id": "hockey", "grading_method": "set", "question": "For the goalkeeper that became a coach and is not a Hall of Famer, who played for BOS in 1972?", "evidence": "BOS refers to tmID = 'BOS'; year = 1972; became a coach and is not a Hall of Famer means coachID is not NULL and hofID is NULL; who refers to firstName, lastName", "SQL": "SELECT T2.firstName, T2.lastName\n FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID \n WHERE T1.year = 1972 AND T1.tmID = 'BOS' AND T2.coachID IS NOT NULL AND T2.hofID IS NULL"} {"question_id": 7804, "db_id": "hockey", "grading_method": "set", "question": "Give the first and last names of players born in Finland.", "evidence": "Master.birthCountry records country of birth.", "SQL": "SELECT DISTINCT firstName, lastName FROM Master WHERE birthCountry = 'Finland'"} {"question_id": 7811, "db_id": "hockey", "grading_method": "set", "question": "What is the total number of regular-season games played by players born in the USA?", "evidence": "Games played refers to Scoring.GP, which records regular-season appearances in the scoring statistics.", "SQL": "SELECT SUM(`GP`) AS total_games FROM `Scoring` AS s JOIN `Master` AS m ON s.`playerID` = m.`playerID` WHERE m.`birthCountry` = 'USA'"} {"question_id": 7821, "db_id": "world", "grading_method": "set", "question": "Calculate the average population per city in Karnataka district.", "evidence": "average population = AVG(Population);", "SQL": "SELECT AVG(`Population`) FROM `City` WHERE `District` = 'Karnataka'"} {"question_id": 7823, "db_id": "world", "grading_method": "set", "question": "How many countries use Portuguese?", "evidence": "Portuguese refers to `Language` = 'Portuguese';", "SQL": "SELECT SUM(CASE WHEN Language = 'Portuguese' THEN 1 ELSE 0 END) FROM CountryLanguage"} {"question_id": 7831, "db_id": "world", "grading_method": "set", "question": "Among the languages used in Baltic Countries, provide the languages which are used by over 80%.", "evidence": "Baltic Countries refers to Region = 'Baltic Countries'; languages which are used by over 80% refers to Percentage > 80;", "SQL": "SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Region = 'Baltic Countries' AND T2.Percentage > 80"} {"question_id": 7838, "db_id": "world", "grading_method": "set", "question": "Which continent is the country with the smallest surface area in?", "evidence": "", "SQL": "SELECT Continent FROM Country ORDER BY SurfaceArea LIMIT 1"} {"question_id": 7845, "db_id": "world", "grading_method": "set", "question": "What are the official languages used in Belgium?", "evidence": "official languages refers to IsOfficial = 'T'; Belgium is a name of country;", "SQL": "SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Belgium' AND T2.IsOfficial = 'T'"} {"question_id": 7846, "db_id": "world", "grading_method": "set", "question": "Give the cities and district names in the country whose local name is Hajastan.", "evidence": "Country.LocalName = 'Hajastan' identifies the country; City.CountryCode joins its cities, and City.Name and City.District record the requested fields.", "SQL": "SELECT T2.Name, T2.District FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.LocalName = 'Hajastan'"} {"question_id": 7847, "db_id": "world", "grading_method": "set", "question": "How many languages are used in Cyprus?", "evidence": "Cyprus is a name of Country;", "SQL": "SELECT SUM(CASE WHEN T1.Name = 'Cyprus' THEN 1 ELSE 0 END) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode"} {"question_id": 7848, "db_id": "world", "grading_method": "set", "question": "Provide the language used by the people of Belize.", "evidence": "Belize is a name of country;", "SQL": "SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Belize'"} {"question_id": 7855, "db_id": "world", "grading_method": "set", "question": "Which country in Asia has the largest gross national product (GNP)?", "evidence": "Country.GNP records gross national product.", "SQL": "SELECT Name FROM Country WHERE Continent = 'Asia' ORDER BY GNP DESC LIMIT 1"} {"question_id": 7867, "db_id": "world", "grading_method": "set", "question": "List all cities in the country with the highest life expectancy.", "evidence": "the highest life expectancy refers to Country.LifeExpectancy = MAX(LifeExpectancy) over the Country rows; list the City.Name of every city in that country", "SQL": "SELECT c.`Name`\nFROM `City` AS c\nJOIN `Country` AS co ON c.`CountryCode` = co.`Code`\nWHERE co.`LifeExpectancy` = (\n SELECT MAX(`LifeExpectancy`) FROM `Country`\n);"} {"question_id": 7870, "db_id": "world", "grading_method": "set", "question": "Name all the countries in the continent of Asia that use English as their unofficial language.", "evidence": "use English as unofficial language refers to Language = 'English' WHERE IsOfficial = 'F';", "SQL": "SELECT T1.Name FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Continent = 'Asia' AND T2.IsOfficial = 'F' AND T2.`Language` = 'English' GROUP BY T1.Name"} {"question_id": 7872, "db_id": "world", "grading_method": "set", "question": "Calculate what percentage of all countries’ surface area belongs to countries that use Chinese as one of their languages.", "evidence": "countries that use Chinese refers to the DISTINCT Country rows with a CountryLanguage Language = 'Chinese'; percentage = DIVIDE(SUM(SurfaceArea) of those countries, SUM(SurfaceArea) of all Country rows) * 100", "SQL": "SELECT 100.0 * SUM(`SurfaceArea`)\n / (SELECT SUM(`SurfaceArea`) FROM `Country`)\nFROM `Country`\nWHERE `Code` IN (\n SELECT `CountryCode`\n FROM `CountryLanguage`\n WHERE `Language` = 'Chinese');"} {"question_id": 7877, "db_id": "world", "grading_method": "set", "question": "List down the official language of the countries which declared independence after 1990. Output the country name and its official language", "evidence": "official lanaguage refers to IsOfficial = 'T'; declared independence after 1990 refers to IndepYear > 1990;", "SQL": "SELECT T1.Name, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.IndepYear > 1990 AND T2.IsOfficial = 'T'"} {"question_id": 7881, "db_id": "world", "grading_method": "set", "question": "What is the life expectancy in the country with the largest city by population?", "evidence": "the largest city by population refers to the city whose Population = MAX(Population) over every city; life expectancy refers to Country.LifeExpectancy of that city's country, a national expectancy at birth rather than a city-specific statistic", "SQL": "SELECT T2.LifeExpectancy FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Population = (SELECT MAX(Population) FROM City);"} {"question_id": 7884, "db_id": "world", "grading_method": "set", "question": "Which country has the most crowded city? If multiple countries has the same most crowded city, report the country that has the smallest surface area.", "evidence": "smallest surface area refers to MIN(smallest surface area); most crowded city refers to MAX(Population);", "SQL": "SELECT T2.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T1.Population DESC, T2.SurfaceArea DESC LIMIT 1"} {"question_id": 7886, "db_id": "world", "grading_method": "set", "question": "Which cities are in the country whose local name is \"´Uman\"? List their names.", "evidence": "The stored local name is '´Uman', beginning with the acute-accent character ´.", "SQL": "SELECT T1.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.LocalName = '´Uman'"} {"question_id": 7888, "db_id": "world", "grading_method": "set", "question": "What is the GNP growth rate by the country of Shanghai?", "evidence": "GNP growth rate = MULTUPLY(DIVIDE(SUBTRACT(GNP, GNPOld), GNPOld), 100); Shanghai is a name of city;", "SQL": "SELECT CAST((T1.GNP - T1.GNPOld) AS REAL) * 100 / T1.GNPOld FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.Name = 'Shanghai'"} {"question_id": 7890, "db_id": "world", "grading_method": "set", "question": "What city has the highest population?", "evidence": "highest population refers to MAX(Population);", "SQL": "SELECT `Name`\nFROM `City`\nWHERE `Population` = (SELECT MAX(`Population`) FROM `City`);"} {"question_id": 7903, "db_id": "world", "grading_method": "set", "question": "What is the surface area and GNP of the country where Namibe district belongs?", "evidence": "", "SQL": "SELECT T2.SurfaceArea, T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Namibe'"} {"question_id": 7906, "db_id": "world", "grading_method": "set", "question": "List down the country names of countries that have a GNP lower than 1000 and have Dutch as their language.", "evidence": "GNP lower than 1000 refers to GNP < 1000; Dutch as their language refers to `Language` = 'Dutch';", "SQL": "SELECT T2.Name FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.GNP < 1000 AND T1.Language = 'Dutch'"} {"question_id": 7911, "db_id": "world", "grading_method": "set", "question": "How many cities are there in the country with the surface area of 652090?", "evidence": "", "SQL": "SELECT COUNT(T1.Name) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.SurfaceArea = 652090 GROUP BY T2.Name"} {"question_id": 7914, "db_id": "world", "grading_method": "set", "question": "Provide the language used in the country ruled by Pierre Buyoya.", "evidence": "ruled by Pierre Buyoya refers to HeadOfState = 'Pierre Buyoya';", "SQL": "SELECT T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.HeadOfState = 'Pierre Buyoya'"} {"question_id": 7922, "db_id": "music_platform_2", "grading_method": "set", "question": "Name all the categories for the podcast titled 'I Heart My Life Show'.", "evidence": "podcasts.title = 'I Heart My Life Show' identifies the podcast; categories.category records its categories.", "SQL": "SELECT T1.category FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.title = 'I Heart My Life Show'"} {"question_id": 7923, "db_id": "music_platform_2", "grading_method": "set", "question": "List all podcast titles and their iTunes URLs in the “society-culture” category.", "evidence": "podcasts.itunes_url records the iTunes URL; categories.category uses 'society-culture'.", "SQL": "SELECT T2.title, T2.itunes_url FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T1.category = 'society-culture'"} {"question_id": 7931, "db_id": "music_platform_2", "grading_method": "set", "question": "Name the podcast title, rating and review content created by '76A4C24B6038145'.", "evidence": "\"76A4C24B6038145\" is author_id; review content refers to content", "SQL": "SELECT T1.title, T2.rating, T2.content FROM podcasts AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.author_id = '76A4C24B6038145'"} {"question_id": 7935, "db_id": "music_platform_2", "grading_method": "set", "question": "Which category does the podcast titled 'SciFi Tech Talk' belong to?", "evidence": "podcast titled 'SciFi Tech Talk' refers to title = 'SciFi Tech Talk'", "SQL": "SELECT T1.category FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.title = 'SciFi Tech Talk'"} {"question_id": 7942, "db_id": "music_platform_2", "grading_method": "set", "question": "Of the arts-books and arts-design categories, which one has more podcasts and what is the numerical difference between them?", "evidence": "arts-books' and 'arts-design' are category; numerical difference = Subtract(Count(podcast_id(category = 'arts-books')), Count(podcast_id(category = 'arts-design'))); one has much more podcast refers to Max(Count(podcast_id))", "SQL": "WITH counts AS (\n SELECT `category`, COUNT(*) AS cnt\n FROM `categories`\n WHERE `category` IN ('arts-books', 'arts-design')\n GROUP BY `category`\n)\nSELECT\n (SELECT `category` FROM counts ORDER BY cnt DESC LIMIT 1) AS `has more podcasts`,\n ABS(\n (SELECT cnt FROM counts WHERE `category` = 'arts-books') -\n (SELECT cnt FROM counts WHERE `category` = 'arts-design')\n ) AS `difference`;"} {"question_id": 7947, "db_id": "music_platform_2", "grading_method": "set", "question": "What is the percentage of reviews added each year of the total reviews added? Please provide the year along with the percentage.", "evidence": "review added each year refers to runs_at like '2021%' and runs_at like '2022%'; percentage for 2021 = Divide (Sum(reviews_added(runs_at like '2021%')), Sum(reviews_added)) * 100; percentage of 2022 = Divide (Sum(reviews_added(runs_at like '2022%')), Sum(reviews_added)) * 100", "SQL": "SELECT substr(`run_at`,1,4) AS year,\n SUM(`reviews_added`) * 100.0 /\n (SELECT SUM(`reviews_added`) FROM runs ) AS percentage\nFROM runs\nGROUP BY year;"} {"question_id": 7948, "db_id": "music_platform_2", "grading_method": "set", "question": "List the titles of all podcasts in the fiction category.", "evidence": "categories.category uses 'fiction'; podcasts.title records podcast titles.", "SQL": "SELECT T2.title FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T1.category = 'fiction'"} {"question_id": 7949, "db_id": "music_platform_2", "grading_method": "set", "question": "What is the category of the podcast entitled Sitcomadon?", "evidence": "entitled refers to title; 'Sitcomadon' is the title of podcast", "SQL": "SELECT DISTINCT T1.category FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.title = 'Sitcomadon'"} {"question_id": 7960, "db_id": "music_platform_2", "grading_method": "set", "question": "Write the names of the podcasts in the music category that have a rating greater than 3.", "evidence": "music category refers to category = 'music'; rating greater than 3 refers to rating > 3; name of the podcast refers to title", "SQL": "SELECT DISTINCT p.title FROM `podcasts` AS p JOIN `categories` AS c ON c.podcast_id = p.podcast_id JOIN `reviews` AS r ON r.podcast_id = p.podcast_id WHERE c.category = 'music' AND r.rating > 3"} {"question_id": 7965, "db_id": "music_platform_2", "grading_method": "set", "question": "Which reviews have the longest content?", "evidence": "a review refers to reviews.content; the longest content refers to LENGTH(content) = MAX(LENGTH(content)) over all reviews, measured in characters; return the content of every review tied at that maximum length", "SQL": "SELECT `content` FROM `reviews` WHERE LENGTH(`content`) = (SELECT MAX(LENGTH(content)) FROM reviews)"} {"question_id": 7976, "db_id": "music_platform_2", "grading_method": "set", "question": "How many reviews does \"Planet Money\" have?", "evidence": "\"Planet Money\" is the title of podcast", "SQL": "SELECT COUNT(T2.podcast_id) FROM podcasts AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE T1.title = 'Planet Money'"} {"question_id": 8021, "db_id": "university", "grading_method": "set", "question": "In which country is the most populated university in 2014 located?", "evidence": "the most populated university in 2014 refers to the university_year row for 2014 with the greatest num_students; return the country_name of the country where that university is located", "SQL": "SELECT c.`country_name`\nFROM `university_year` AS uy\nJOIN `university` AS u ON uy.`university_id` = u.`id`\nJOIN `country` AS c ON u.`country_id` = c.`id`\nWHERE uy.`year` = 2014\nORDER BY uy.`num_students` DESC\nLIMIT 1;"} {"question_id": 8026, "db_id": "university", "grading_method": "set", "question": "Among universities that had at least one score below 80 in 2015, what is their percentage of international students in 2015?", "evidence": "score below 80 refers to score < 80; in 2015 refers to year 2015; percentage of international students refers to DIVIDE(SUM(MULTIPLY(num_students, pct_international_students)), SUM(num_students))", "SQL": "WITH low_score AS (\n SELECT DISTINCT `university_id`\n FROM `university_ranking_year`\n WHERE `year` = 2015\n AND `score` < 80\n)\nSELECT CAST(SUM(`num_students` * `pct_international_students`) as REAL)\n / SUM(`num_students`) AS pct_international_students\nFROM `university_year`\nWHERE `year` = 2015\n AND `university_id` IN (SELECT `university_id` FROM low_score);"} {"question_id": 8029, "db_id": "university", "grading_method": "set", "question": "What is the student staff ratio at the university with the greatest student staff ratio of all time?", "evidence": "greatest student staff ratio of all time refers to max(student_staff_ratio)", "SQL": "SELECT MAX(student_staff_ratio) FROM university_year"} {"question_id": 8033, "db_id": "university", "grading_method": "set", "question": "Which university had the highest total times score in 2012?", "evidence": "had the highest total times refers to MAX(score) and criteria_name = 'Total Times', in 2012 refers to year = 2012; which university refers to university_name;", "SQL": "with sub as (SELECT u.`university_name`, ur.`score`\nFROM `university_ranking_year` ur\nJOIN `ranking_criteria` rc ON ur.`ranking_criteria_id` = rc.`id`\nJOIN `university` u ON ur.`university_id` = u.`id`\nWHERE ur.`year` = 2012 AND rc.`criteria_name` = 'Total Times')\nselect university_name from sub where score = (select max(score) from sub)"} {"question_id": 8035, "db_id": "university", "grading_method": "set", "question": "Indicate the university's name with the highest ranking score in Teaching.", "evidence": "university's name refers to university_name; highest ranking score refers to MAX(score); in Teaching refers to criteria_name = 'Teaching'", "SQL": "SELECT T1.university_name \nFROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN ranking_criteria AS T3 ON T3.id = T2.ranking_criteria_id \nWHERE T3.criteria_name = 'Teaching' and T2.score = (SELECT max(T2.score)\nFROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN ranking_criteria AS T3 ON T3.id = T2.ranking_criteria_id \nWHERE T3.criteria_name = 'Teaching' )"} {"question_id": 8036, "db_id": "university", "grading_method": "set", "question": "What is the percentage of Harvard university's international students in 2011?", "evidence": "Harvard university's refers to university_name = 'Harvard University'; in 2011 refers to year = 2011; percentage of Harvard university's international students refers to pct_international_students", "SQL": "SELECT T1.pct_international_students FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T2.university_name = 'Harvard University'"} {"question_id": 8040, "db_id": "university", "grading_method": "set", "question": "Name the most famous university in Argentina based on the total ranking score.", "evidence": "in Argentina refers to country_name = 'Argentina';  most famous refers to MAX(SUM(score))", "SQL": "SELECT T1.university_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'Argentina' GROUP BY T1.university_name HAVING SUM(T2.Score) = (SELECT SUM(T2.Score) FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'Argentina' GROUP BY T1.university_name ORDER BY SUM(T2.Score) DESC LIMIT 1);"} {"question_id": 8052, "db_id": "university", "grading_method": "set", "question": "How many universities received scores below 50 for ranking criterion ID 6 in 2011?", "evidence": "university_ranking_year.ranking_criteria_id identifies the ranking criterion; score records its score for the recorded year.", "SQL": "SELECT COUNT(DISTINCT university_id) FROM university_ranking_year WHERE ranking_criteria_id = 6 AND year = 2011 AND score < 50"} {"question_id": 8054, "db_id": "university", "grading_method": "set", "question": "List the universities in Denmark.", "evidence": "in Denmark refers to country_name = 'Denmark'; name of university refers to university_name;", "SQL": "SELECT T1.university_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Denmark'"} {"question_id": 8063, "db_id": "university", "grading_method": "set", "question": "How many percent of universities got a score above 80 under International criteria in 2016? Among them, name the university which got the highest score.", "evidence": "got a score above 80 refers to score > 80; under International criteria refers to criteria_name = 'International'; in 2016 refers to year = 2016; highest score refers to MAX(score)", "SQL": "SELECT CAST(SUM(CASE WHEN T2.score > 80 THEN 1 ELSE 0 END) AS REAL) / COUNT(*) * 100, ( 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 = 'International' AND T2.year = 2016 AND T2.score > 80 ORDER BY T2.score DESC LIMIT 1 ) AS max 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 = 'International' AND T2.year = 2016"} {"question_id": 8064, "db_id": "university", "grading_method": "set", "question": "Provide the ranking criteria and scores in 2005 that were received by Harvard University.", "evidence": "Harvard University refers to university_name = 'Harvard University'; in 2005 refers to year = 2005; ranking criteria refers to criteria_name;", "SQL": "SELECT T1.criteria_name, T2.score 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 T3.university_name = 'Harvard University' AND T2.year = 2005"} {"question_id": 8066, "db_id": "university", "grading_method": "set", "question": "Name the university which had the highest number of international students in 2015 and the country where it is located..", "evidence": "highest number of international students refers to MAX(DIVIDE(MULTIPLY(num_students, pct_international_students), 100)); in 2015 refers to year = 2015; name of university refers to university_name;", "SQL": "SELECT u.`university_name`,\n c.`country_name`\nFROM `university` u\nJOIN `university_year` y ON y.`university_id` = u.`id`\nJOIN `country` c ON c.`id` = u.`country_id`\nWHERE y.`year` = 2015\nORDER BY (y.`num_students` * y.`pct_international_students` / 100.0) DESC\nLIMIT 1;"} {"question_id": 8068, "db_id": "university", "grading_method": "set", "question": "What is the ID of the university with the most students in 2011?", "evidence": "in 2011 refers to year 2011; with the most students refers to MAX(num_students); ID of the university refers to university_id", "SQL": "SELECT university_id FROM university_year WHERE year = 2011 ORDER BY num_students DESC LIMIT 1"} {"question_id": 8069, "db_id": "university", "grading_method": "set", "question": "Please list the IDs of the universities with a student staff ratio of over 15 in 2011.", "evidence": "in 2011 refers to year 2011; student staff ratio of over 15 refers to student_staff_ratio > 15; ID of the university refers to university_id", "SQL": "SELECT university_id FROM university_year WHERE year = 2011 AND student_staff_ratio > 15"} {"question_id": 8073, "db_id": "university", "grading_method": "set", "question": "How many students did Harvard University have in 2011?", "evidence": "in 2011 refers to year 2011; Harvard University refers to university_name = 'Harvard University';", "SQL": "SELECT T1.num_students FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Harvard University' AND T1.year = 2011"} {"question_id": 8079, "db_id": "university", "grading_method": "set", "question": "Please list the names of the universities with a score in teaching of over 90 in 2011.", "evidence": "in 2011 refers to year 2011; in teaching refers to  criteria_name = 'Teaching'; score in teaching of over 90 refers to score > 90; name of university refers to 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 = 'Teaching' AND T2.year = 2011 AND T2.score > 90"} {"question_id": 8081, "db_id": "university", "grading_method": "set", "question": "Please list the names of all the ranking criteria of Harvard University in 2011.", "evidence": "in 2011 refers to year 2011; Harvard University refers to university_name = 'Harvard University'; names of all the ranking criteria refers to criteria_name", "SQL": "SELECT T1.criteria_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 T3.university_name = 'Harvard University' AND T2.year = 2011"} {"question_id": 8087, "db_id": "university", "grading_method": "set", "question": "Give the id of \"Center for World University Rankings\".", "evidence": "\"Center for World University Rankings\" refers to system_name = 'Center for World University Rankings';", "SQL": "SELECT id FROM ranking_system WHERE system_name = 'Center for World University Rankings'"} {"question_id": 8090, "db_id": "university", "grading_method": "set", "question": "Show the id of University of Orléans.", "evidence": "University of Orléans refers to university_name = 'University of Orléans';", "SQL": "SELECT id FROM university WHERE university_name = 'University of Orléans'"} {"question_id": 8091, "db_id": "university", "grading_method": "set", "question": "For the university id 268, show its number of students in 2013.", "evidence": "number of students refers to num_students; in 2013 refers to year = 2013", "SQL": "SELECT num_students FROM university_year WHERE university_id = 268 AND year = 2013"} {"question_id": 8097, "db_id": "university", "grading_method": "set", "question": "For Chosun University, what was its score on \"Influence Rank\" in 2015?", "evidence": "Chosun University refers to university_name = 'Chosun University'; in 2015 refers to year = 2015; on \"Influence Rank\" refers to criteria_name = 'Influence Rank';", "SQL": "SELECT T2.score 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 T3.university_name = 'Chosun University' AND T1.criteria_name = 'Influence Rank' AND T2.year = 2015"} {"question_id": 8104, "db_id": "university", "grading_method": "set", "question": "Show the name of the university with the lowest number of students in 2015.", "evidence": "lowest number of students refers to MIN(num_students); in 2015 refers to year = 2015; name of university refers to university_name;", "SQL": "SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 ORDER BY T1.num_students ASC LIMIT 1"} {"question_id": 8108, "db_id": "university", "grading_method": "set", "question": "List every criterion score of university ID 68 in 2015? Return the ranking criteria id and the score.", "evidence": "in 2015 refers to year = 2015", "SQL": "SELECT `ranking_criteria_id`, `score`\nFROM `university_ranking_year`\nWHERE `university_id` = 68 AND `year` = 2015;"} {"question_id": 8113, "db_id": "university", "grading_method": "set", "question": "For university ID 40, what is the estimated total female enrollment across 2011, 2012, and 2013? Round your answer to 2 decimal places.", "evidence": "university ID 40 refers to the university_year rows for university 40; across 2011, 2012 and 2013 refers to year BETWEEN 2011 AND 2013; estimated total female enrollment = ROUND(SUM(DIVIDE(MULTIPLY(num_students, pct_female_students), 100)), 2)", "SQL": "WITH unrounded(value) AS (\nSELECT SUM(CAST(num_students * pct_female_students AS REAL) / 100) FROM university_year WHERE year BETWEEN 2011 AND 2013 AND university_id = 40\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 8119, "db_id": "university", "grading_method": "set", "question": "What is the total number of ranking criteria under the ranking system called Shanghai Ranking?", "evidence": "ranking system called Shanghai Ranking refers to system_name = 'Shanghai Ranking';", "SQL": "SELECT COUNT(*) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Shanghai Ranking'"} {"question_id": 8122, "db_id": "university", "grading_method": "set", "question": "List down all universities that have at least one score below 50", "evidence": "scored below 50 refers to score < 50; all universities refers to university_name;", "SQL": "SELECT DISTINCT T2.university_name FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.score < 50"} {"question_id": 8123, "db_id": "university", "grading_method": "set", "question": "How many universities are located in Japan?", "evidence": "located in Japan refers to country_name = 'Japan';", "SQL": "SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Japan'"} {"question_id": 8124, "db_id": "university", "grading_method": "set", "question": "Provide the name of the university with the highest number of male students in a single year.", "evidence": "male students in a university's year refers to MULTIPLY(university_year.num_students, 1 - DIVIDE(university_year.pct_female_students, 100.0)); the highest number of male students in a single year refers to the greatest such value over the university_year records; provide the university_name of that university", "SQL": "SELECT u.`university_name`\nFROM `university_year` y JOIN `university` u ON y.`university_id` = u.`id`\nORDER BY (y.`num_students` * (1 - y.`pct_female_students` / 100.0)) DESC\nLIMIT 1;"} {"question_id": 8133, "db_id": "university", "grading_method": "set", "question": "How many universities scored 40 in teaching criteria?", "evidence": "scored 40 refers to score = 40; in teaching refers to criteria_name = 'Teaching'", "SQL": "SELECT COUNT(DISTINCT T2.university_id) FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id WHERE T2.score = 40 AND T1.criteria_name = 'Teaching' AND T2.score = 40"} {"question_id": 8138, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many units of item no.9 were sold in store no.1 in total in January, 2012?", "evidence": "store no. 1 refers to store_nbr = 1; item no. 9 refers to item_nbr = 9; in January refers to SUBSTR(date, 1, 4) = '2012' and SUBSTR(date, 6, 2) = '01'", "SQL": "SELECT SUM(units) FROM sales_in_weather WHERE SUBSTR(`date`, 6, 2) = '01' AND SUBSTR(`date`, 1, 4) = '2012' AND item_nbr = 9 AND store_nbr = 1"} {"question_id": 8140, "db_id": "sales_in_weather", "grading_method": "set", "question": "What was the temperature range of station no.1 on 2012/1/1?", "evidence": "on 2012/1/1 refers to date = '2012-01-01'; temperature range refers to Subtract (tmax, tmin); station no.1 refers to station_nbr = 1", "SQL": "SELECT tmax - tmin AS temrange FROM weather WHERE station_nbr = 1 AND `date` = '2012-01-01'"} {"question_id": 8150, "db_id": "sales_in_weather", "grading_method": "set", "question": "Please list the dates on which the sale of item no.5 in store no.3 exceeded 100 and the average wind speed exceeded 10.", "evidence": "item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; exceed 100 refers to units > 100; average wind speed exceeded 10 refers to avgspeed > 10", "SQL": "SELECT DISTINCT s.`date`\nFROM `sales_in_weather` AS s\nJOIN `relation` AS r ON r.`store_nbr` = s.`store_nbr`\nJOIN `weather` AS w ON w.`station_nbr` = r.`station_nbr`\n AND w.`date` = s.`date`\nWHERE s.`store_nbr` = 3\n AND s.`item_nbr` = 5\n AND s.`units` > 100\n AND w.`avgspeed` > 10;"} {"question_id": 8156, "db_id": "sales_in_weather", "grading_method": "set", "question": "What is the percentage of the units of item no.5 sold among all units of items sold in store no.3 on the day when store no.3 has the highest max temperature in 2012? List the date and the corresponding percentage.", "evidence": "item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; highest max temperature refers to Max(tmax); in 2012 refers to SUBSTR(date, 1, 4) = '2012';  Percentage = Divide (Sum(units where item_nbr = 5), Sum(units)) * 100", "SQL": "WITH hottest_days AS (\n SELECT w.`date`\n FROM relation r\n JOIN weather w ON w.`station_nbr` = r.`station_nbr`\n WHERE r.`store_nbr` = 3\n AND substr(w.`date`,1,4) = '2012'\n AND w.`tmax` = (\n SELECT MAX(w2.`tmax`)\n FROM relation r2\n JOIN weather w2 ON w2.`station_nbr` = r2.`station_nbr`\n WHERE r2.`store_nbr` = 3\n AND substr(w2.`date`,1,4) = '2012')\n)\nSELECT date, CAST(SUM(CASE WHEN item_nbr = 5 THEN units ELSE 0 END) AS REAL) * 100.0 / SUM(units) AS percentage_item5\nFROM sales_in_weather\nWHERE `store_nbr` = 3\n AND `date` IN (SELECT `date` FROM hottest_days)\n group by date"} {"question_id": 8157, "db_id": "sales_in_weather", "grading_method": "set", "question": "Give the id of the bestsellers of store no.1 on 2012/1/1.", "evidence": "store no. 1 refers to store_nbr = 1; on 2012/1/1 refers to date = '2012-01-01'; best seller refers to Max(units); ID refers to item_nbr", "SQL": "SELECT `item_nbr`\nFROM `sales_in_weather`\nWHERE `date` = '2012-01-01'\n AND `store_nbr` = 1\n AND `units` = (\n SELECT MAX(`units`)\n FROM `sales_in_weather`\n WHERE `date` = '2012-01-01'\n AND `store_nbr` = 1\n );"} {"question_id": 8169, "db_id": "sales_in_weather", "grading_method": "set", "question": "Provide the sunrise time recorded by the home weather station of store no.30 on 2014/2/21.", "evidence": "store no. 30 refers to store_nbr = 30; on 2014/2/21 refers to date = '2014-02-21'", "SQL": "SELECT T1.sunrise FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2014-02-21' AND store_nbr = 30"} {"question_id": 8178, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many stores are in weather station 12?", "evidence": "weather station 12 refers to station_nbr = 12; number of stores refers to Count(store_nbr)", "SQL": "SELECT COUNT(store_nbr) FROM relation WHERE station_nbr = 12"} {"question_id": 8181, "db_id": "sales_in_weather", "grading_method": "set", "question": "Which weather station serves the highest number of stores?", "evidence": "a station's number of stores refers to COUNT(relation.store_nbr) for that station_nbr; return the single relation.station_nbr with the greatest such count", "SQL": "SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(store_nbr) DESC LIMIT 1"} {"question_id": 8184, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many stores belong to the most windy station?", "evidence": "most windy station refers to Max(avgspeed)", "SQL": "SELECT COUNT(store_nbr) FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY avgspeed DESC LIMIT 1 )"} {"question_id": 8186, "db_id": "sales_in_weather", "grading_method": "set", "question": "What is the most purchased products during the rainy days in June 2013 in stores belong to weather station 9?", "evidence": "most purchased product refers to Max(SUM(units)); during the rainy day refers to codesum = RA; in June 2013 refers to SUBSTR(date, 1, 7) = '2013-06'; weather station 9 refers to station_nbr = 9; product refers to item_nbr", "SQL": "SELECT T1.item_nbr\nFROM sales_in_weather AS T1\nJOIN relation AS T2 ON T1.store_nbr = T2.store_nbr\nJOIN weather AS T3 ON T3.station_nbr = T2.station_nbr\n AND T3.date = T1.date\nWHERE T3.station_nbr = 9\n AND T3.date BETWEEN '2013-06-01' AND '2013-06-30'\n AND T3.codesum LIKE 'RA'\nGROUP BY T1.item_nbr\nORDER BY SUM(T1.units) DESC\nLIMIT 1;"} {"question_id": 8187, "db_id": "sales_in_weather", "grading_method": "set", "question": "Which store sold the highest quantity of item number 5 overall?", "evidence": "item number 5 refers to item_nbr = 5; sold highest quantity refers to Max(Sum(units));", "SQL": "with sub as (SELECT store_nbr, SUM(units) as num FROM sales_in_weather WHERE item_nbr = 5 GROUP BY store_nbr)\nselect store_nbr from sub where num = (select max(num) from sub)"} {"question_id": 8203, "db_id": "sales_in_weather", "grading_method": "set", "question": "What is the lowest minimum temperature recorded in store 16 on January 2012?", "evidence": "lowest minimum temperature refers to Min(tmin); store 16 refers to store_nbr = 16; on January 2012 refers to Substring (date, 1, 7) = '2012-01'", "SQL": "SELECT MIN(tmin) FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 16 AND T1.`date` LIKE '%2012-01%'"} {"question_id": 8206, "db_id": "sales_in_weather", "grading_method": "set", "question": "List the weather station number for store 17 and the item numbers it has sold.", "evidence": "relation.station_nbr identifies the store’s weather station. sales_in_weather.item_nbr identifies an item; units records its daily units sold.", "SQL": "SELECT DISTINCT r.station_nbr,\n s.item_nbr\nFROM `relation` r\nJOIN `sales_in_weather` s\n ON r.`store_nbr` = s.`store_nbr`\nWHERE r.`store_nbr` = 17\n AND s.`units` > 0;"} {"question_id": 8208, "db_id": "sales_in_weather", "grading_method": "set", "question": "What is the sea level and average speed for store number 3 and store number 4 on 19 September 2012? List the store number along with the sea level and average speed.", "evidence": "store number 3 refers to store_nbr = 3; average speed refers to avgspeed; store number 4 refers to store_nbr = 4", "SQL": "SELECT T2.store_nbr, T1.sealevel, T1.avgspeed FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE (T2.store_nbr = 3 OR T2.store_nbr = 4) AND T1.`date` = '2012-09-19'"} {"question_id": 8212, "db_id": "sales_in_weather", "grading_method": "set", "question": "What was the average temperature difference between store number 18 and 19 on 16 September 2012?", "evidence": "store number 18 refers to store_nbr = 18; store number 19 refers to store_nbr = 19; on 16 September 2012 refers to date = '2012-09-16'; average temperature difference = Subtract(tavg where store_nbr = 18, tavg where store_nbr = 19)", "SQL": "SELECT SUM(CASE WHEN T1.store_nbr = 18 THEN T2.tavg ELSE 0 END) - SUM(CASE WHEN T1.store_nbr = 19 THEN T2.tavg ELSE 0 END) FROM relation AS T1 INNER JOIN weather AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.`date` = '2012-09-16'"} {"question_id": 8213, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many units are being sold for item 1 when the average temperature is 83?", "evidence": "item 1 refers to item_nbr = 1; when the average temperature is 83 refers to tavg = 83", "SQL": "SELECT SUM(s.`units`) FROM `sales_in_weather` s JOIN `relation` r ON s.`store_nbr` = r.`store_nbr` JOIN `weather` w ON w.`station_nbr` = r.`station_nbr` AND w.`date` = s.`date` WHERE s.`item_nbr` = 1 AND w.`tavg` = 83"} {"question_id": 8215, "db_id": "sales_in_weather", "grading_method": "set", "question": "How many units of item 10 were sold on days when the average temperature at the store’s weather station was below the overall average recorded temperature?", "evidence": "item 10 refers to item_nbr = 10; match each store to its weather station through relation, and weather to the sale on that station_nbr and the same date; below the overall average recorded temperature refers to that day's tavg < AVG(tavg) over all weather rows, ignoring missing tavg; how many units refers to SUM(units)", "SQL": "SELECT SUM(T5.units) FROM weather AS T4 INNER JOIN sales_in_weather AS T5 ON T4.`date` = T5.`date` INNER JOIN relation AS T6 ON T5.store_nbr = T6.store_nbr AND T4.station_nbr = T6.station_nbr WHERE T5.item_nbr = 10 AND T4.tavg < ( SELECT AVG(T1.tavg) FROM weather AS T1 )"} {"question_id": 8218, "db_id": "mondial_geo", "grading_method": "set", "question": "Which countries have more than 90% of their population in the African ethnic group? Give the full country names.", "evidence": "ethnicGroup.Percentage records a group’s percentage of the country’s population; ethnicGroup.Name uses 'African'.", "SQL": "SELECT T2.Name FROM ethnicGroup AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T1.Name = 'African' AND T1.Percentage > 90"} {"question_id": 8232, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the annual population growth, in people, for the country with the lowest infant mortality rate?", "evidence": "population.Population_Growth is an annual percentage rate; country.Population is in people. population.Infant_Mortality is measured per thousand.", "SQL": "SELECT T2.Population_Growth * T1.Population /100\nFROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country \nWHERE T2.Infant_Mortality IS NOT NULL ORDER BY T2.Infant_Mortality ASC LIMIT 1"} {"question_id": 8245, "db_id": "mondial_geo", "grading_method": "set", "question": "Which country has the highest GDP?", "evidence": "", "SQL": "SELECT T1.Name FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country ORDER BY T2.GDP DESC LIMIT 1"} {"question_id": 8248, "db_id": "mondial_geo", "grading_method": "set", "question": "Which country has the lowest inflation rate?", "evidence": "", "SQL": "SELECT T1.Name FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T2.Inflation IS NOT NULL ORDER BY T2.Inflation ASC LIMIT 1"} {"question_id": 8264, "db_id": "mondial_geo", "grading_method": "set", "question": "Among the countries whose GDP is over 1000000, how many of them have a population growth rate of over 1%?", "evidence": "population growth rate of over 1% means population_growth > 1", "SQL": "SELECT COUNT(T1.Country) FROM economy AS T1 INNER JOIN population AS T2 ON T1.Country = T2.Country WHERE T1.GDP > 1000000 AND T2.Population_Growth > 1"} {"question_id": 8267, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the average population growth rate of countries where more than 3 languages are used?", "evidence": "", "SQL": "SELECT AVG(pg) FROM ( SELECT T3.Population_Growth pg FROM country AS T1 INNER JOIN language AS T2 ON T1.Code = T2.Country INNER JOIN population AS T3 ON T3.Country = T2.Country WHERE T2.Country IN (SELECT Country FROM language GROUP BY Country HAVING COUNT(Country) > 3 ) GROUP BY T3.Country )"} {"question_id": 8273, "db_id": "mondial_geo", "grading_method": "set", "question": "Which two countries share the longest border? Give both countries’ full names.", "evidence": "borders.Length records border length. borders.Country1 and borders.Country2 link to country.Code, and country.Name provides both full country names.", "SQL": "SELECT c1.`Name` AS Country1,\n c2.`Name` AS Country2\nFROM `borders` b\nJOIN `country` c1 ON b.`Country1` = c1.`Code`\nJOIN `country` c2 ON b.`Country2` = c2.`Code`\nORDER BY b.`Length` DESC\nLIMIT 1;"} {"question_id": 8282, "db_id": "mondial_geo", "grading_method": "set", "question": "Which city in Japan has the most people?", "evidence": "most people refers to largest population", "SQL": "SELECT T2.Name FROM country AS T1 INNER JOIN city AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Japan' ORDER BY T2.Population DESC LIMIT 1"} {"question_id": 8288, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the capital of the country with the largest percentage of Malay people?", "evidence": "Malay is an ethnic group recorded in ethnicGroup.Name, and ethnicGroup.Percentage records its share of a country’s population. country.Capital records the capital.", "SQL": "SELECT T1.Capital FROM country AS T1 INNER JOIN ethnicGroup AS T2 ON T1.Code = T2.Country WHERE T2.Name = 'Malay' ORDER BY T2.Percentage DESC LIMIT 1"} {"question_id": 8298, "db_id": "mondial_geo", "grading_method": "set", "question": "How many mountains are there in the country with the greatest population?", "evidence": "", "SQL": "SELECT COUNT(*)\nFROM `geo_mountain`\nWHERE `Country` = (\n SELECT `Code`\n FROM `country`\n ORDER BY `Population` DESC\n LIMIT 1\n);"} {"question_id": 8302, "db_id": "mondial_geo", "grading_method": "set", "question": "Please list the deserts in countries whose population is over 100,000 and whose country area is under 500,000.", "evidence": "", "SQL": "SELECT DISTINCT gd.`Desert`\nFROM `country` AS c\nJOIN `geo_desert` AS gd\n ON gd.`Country` = c.`Code`\nWHERE c.`Population` > 100000 \n AND c.`Area` < 500000; "} {"question_id": 8313, "db_id": "mondial_geo", "grading_method": "set", "question": "Please list the names of countries on the European continent that have population growth above 1%.", "evidence": "population.Population_Growth records population growth as a percentage; encompasses.Continent uses 'Europe'.", "SQL": "SELECT DISTINCT c.Name\nFROM country c\nJOIN encompasses e ON c.Code = e.Country\nJOIN population p ON p.Country = c.Code\nWHERE e.Continent = 'Europe' AND p.Population_Growth > 1;"} {"question_id": 8314, "db_id": "mondial_geo", "grading_method": "set", "question": "How many countries on the European continent have an infant mortality rate over 100 per thousand?", "evidence": "population.Infant_Mortality records infant deaths per thousand; encompasses.Continent uses 'Europe'.", "SQL": "SELECT COUNT(DISTINCT c.Code) FROM `country` AS c JOIN `encompasses` AS e ON c.Code = e.Country JOIN `population` AS p ON p.Country = c.Code WHERE e.Continent = 'Europe' AND p.Infant_Mortality > 100"} {"question_id": 8316, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the average percentage of agriculture of GDP in countries on the African Continent?", "evidence": "", "SQL": "SELECT AVG(T4.Agriculture) FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T3.Code = T2.Country INNER JOIN economy AS T4 ON T4.Country = T3.Code WHERE T1.Name = 'Africa'"} {"question_id": 8324, "db_id": "mondial_geo", "grading_method": "set", "question": "In which province is city Glenrothes located? What is the capital of the province?", "evidence": "", "SQL": "SELECT T2.Province, T1.Capital FROM province AS T1 INNER JOIN city AS T2 ON T1.Name = T2.Province AND T1.Country = T2.Country WHERE T2.Name = 'Glenrothes'"} {"question_id": 8325, "db_id": "mondial_geo", "grading_method": "set", "question": "List all cities and their populations in provinces with populations over 1,000,000.", "evidence": "A province is identified by both its name and country in city and province.", "SQL": "SELECT T1.Name, T1.Population FROM city AS T1 INNER JOIN province AS T2 ON T2.Name = T1.Province AND T1.`Country` = T2.`Country` WHERE T2.Population > 1000000"} {"question_id": 8328, "db_id": "mondial_geo", "grading_method": "set", "question": "Calculate Edmonton’s population as a percentage of the population of its province.", "evidence": "Edmonton refers to city.Name = 'Edmonton'; Edmonton's population as a percentage of the population of its province refers to DIVIDE(city.Population, province.Population) * 100", "SQL": "SELECT CAST(T1.Population AS REAL) * 100 / T2.Population FROM city AS T1 INNER JOIN province AS T2 ON T1.Province = T2.Name AND T1.country = T2.country WHERE T1.Name = 'Edmonton'"} {"question_id": 8329, "db_id": "mondial_geo", "grading_method": "set", "question": "Which rivers flow into the Black Sea?", "evidence": "river.Sea records the sea a river flows into, including 'Black Sea'.", "SQL": "SELECT Name FROM river WHERE Sea = 'Black Sea'"} {"question_id": 8336, "db_id": "mondial_geo", "grading_method": "set", "question": "List the cities and their provinces located on rivers that flow into the Atlantic Ocean.", "evidence": "located.River records the river a city lies on. river.Sea records its outlet, including the value 'Atlantic Ocean'.", "SQL": "SELECT T1.Name, T1.Province FROM city AS T1 INNER JOIN located AS T2 ON T1.Name = T2.City AND T1.`Province` = T2.`Province` INNER JOIN river AS T3 ON T3.Name = T2.River WHERE T3.Sea = 'Atlantic Ocean'"} {"question_id": 8347, "db_id": "mondial_geo", "grading_method": "set", "question": "Which rivers is Belgrade located on? Give their names and lengths.", "evidence": "located.River records the river a city lies on.", "SQL": "SELECT T1.Name, T1.Length FROM river AS T1 INNER JOIN located AS T2 ON T1.Name = T2.River INNER JOIN city AS T3 ON T3.Name = T2.City WHERE T3.Name = 'Belgrade'"} {"question_id": 8348, "db_id": "mondial_geo", "grading_method": "set", "question": "Which nations have a 100% Spanish-speaking population?", "evidence": "", "SQL": "SELECT c.`Name`\nFROM `language` l\nJOIN `country` c ON l.`Country` = c.`Code`\nWHERE l.`Name` = 'Spanish' AND l.`Percentage` = 100;"} {"question_id": 8356, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the estimated number of Serbian speakers in Montenegro? Round your answer to 4 decimal places.", "evidence": "language.Percentage is the percentage of a country’s population speaking the language; country.Population is in people.", "SQL": "WITH unrounded(value) AS (\nSELECT T1.Percentage * T2.Population /100 FROM language AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T1.Name = 'Serbian' AND T2.Name = 'Montenegro'\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 8361, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the name of the nation that has the greatest infant mortality rate among those that attained independence in 1960?", "evidence": "", "SQL": "SELECT c.`Name`\nFROM `politics` p\nJOIN `population` pop ON p.`Country` = pop.`Country`\nJOIN `country` c ON p.`Country` = c.`Code`\nWHERE STRFTIME('%Y', p.`Independence`) = '1960'\nORDER BY pop.`Infant_Mortality` DESC\nLIMIT 1;"} {"question_id": 8363, "db_id": "mondial_geo", "grading_method": "set", "question": "Which Arabic-speaking country has the smallest population?", "evidence": "Arabic-speaking country = country that speaks 100% Arabic", "SQL": "SELECT c.Name\nFROM country AS c\nJOIN language AS l ON c.Code = l.Country\nWHERE l.Name = 'Arabic' AND l.Percentage = 100\nORDER BY c.Population\nLIMIT 1;"} {"question_id": 8364, "db_id": "mondial_geo", "grading_method": "set", "question": "What provinces encompass the world's biggest desert in terms of overall area?", "evidence": "", "SQL": "SELECT Province FROM geo_desert WHERE Desert = ( SELECT Name FROM desert ORDER BY Area DESC LIMIT 1 )"} {"question_id": 8368, "db_id": "mondial_geo", "grading_method": "set", "question": "What are the names of the seas surrounding the island with the largest area?", "evidence": "islandIn records the seas in which an island lies.", "SQL": "SELECT T2.Name FROM islandIn AS T1 INNER JOIN sea AS T2 ON T2.Name = T1.Sea WHERE T1.Island = ( SELECT Name FROM island ORDER BY Area DESC LIMIT 1 )"} {"question_id": 8370, "db_id": "mondial_geo", "grading_method": "set", "question": "How many people live in the capital city of the nation that attained independence on 8/15/1947?", "evidence": "politics.Independence records the independence date; August 15, 1947 is represented as '1947-08-15'. country.Capital identifies the capital and city.Population records its population.", "SQL": "SELECT T3.Population FROM politics AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code INNER JOIN city AS T3 ON T3.Name = T2.Capital WHERE T1.Independence = '1947-08-15'"} {"question_id": 8394, "db_id": "mondial_geo", "grading_method": "set", "question": "Which religions have the majority of the people in Japan?", "evidence": "Japan is a country", "SQL": "SELECT T2.Name FROM country AS T1 INNER JOIN religion AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Japan' AND T2.Percentage = (SELECT MAX(Percentage) FROM religion AS T3 WHERE T3.Country = T1.Code);"} {"question_id": 8402, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the GDP per capita in Switzerland?", "evidence": "GDP per capita = GDP / Population", "SQL": "SELECT T2.GDP / T1.Population FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Switzerland'"} {"question_id": 8416, "db_id": "mondial_geo", "grading_method": "set", "question": "Which river with its mouth in the Donau River and a length greater than 500 km is located in Slovenia?", "evidence": "", "SQL": "SELECT T2.River FROM country AS T1 INNER JOIN geo_river AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Slovenia' AND T2.River IN ( SELECT NAME FROM river WHERE Length > 500 AND River = 'Donau' )"} {"question_id": 8417, "db_id": "mondial_geo", "grading_method": "set", "question": "In which city is the sea whose depth is 3969 meters less than that of the Bay of Bengal?", "evidence": "", "SQL": "SELECT T2.City FROM sea AS T1 INNER JOIN located AS T2 ON T1.Name = T2.Sea INNER JOIN city AS T3 ON T3.Name = T2.City WHERE ( SELECT Depth FROM sea WHERE Name LIKE 'Bay of Bengal' ) - T1.Depth = 3969"} {"question_id": 8421, "db_id": "mondial_geo", "grading_method": "set", "question": "Of all the lakes in Bolivia, which is the deepest?", "evidence": "Bolivia is the country", "SQL": "SELECT T1.Name FROM lake AS T1 INNER JOIN geo_lake AS T2 ON T1.Name = T2.Lake INNER JOIN province AS T3 ON T3.Name = T2.Province INNER JOIN country AS T4 ON T4.Code = T3.Country WHERE T4.Name = 'Bolivia' ORDER BY T1.Depth DESC LIMIT 1"} {"question_id": 8430, "db_id": "mondial_geo", "grading_method": "set", "question": "Which nation has the smallest population, and what is the name of its capital?", "evidence": "", "SQL": "SELECT Name, Capital FROM country ORDER BY Population ASC LIMIT 1"} {"question_id": 8442, "db_id": "mondial_geo", "grading_method": "set", "question": "How many businesses were founded after 1960 in a nation that is still not independent?", "evidence": "Established means founded; Country means nation; Organization means businesses; is still not independent refers to independence is NULL", "SQL": "SELECT COUNT(T3.Name) FROM country AS T1 INNER JOIN politics AS T2 ON T1.Code = T2.Country INNER JOIN organization AS T3 ON T3.Country = T2.Country WHERE T2.Independence is NULL AND CAST(STRFTIME('%Y', T3.`Established`) AS INTEGER) > 1960"} {"question_id": 8445, "db_id": "mondial_geo", "grading_method": "set", "question": "What nations are considered British Overseas Territories?", "evidence": "British Overseas Territories is one government form; Nation refers to country name", "SQL": "SELECT name FROM country WHERE CODE IN ( SELECT country FROM politics WHERE government = 'British Overseas Territories' )"} {"question_id": 8448, "db_id": "mondial_geo", "grading_method": "set", "question": "Which US state or federal district has the most organization headquarters?", "evidence": "organization.Province records the headquarters’ state or federal district; organization.Country = 'USA' identifies US headquarters.", "SQL": "SELECT `Province` FROM `organization` WHERE `Country` = 'USA' GROUP BY `Province` HAVING COUNT(Province) = (SELECT MAX(Counted) FROM (SELECT COUNT(Province) AS Counted FROM `organization` WHERE `Country` = 'USA' GROUP BY `Province`));"} {"question_id": 8451, "db_id": "mondial_geo", "grading_method": "set", "question": "Which country falls under the category of an associated member? Please provide the full names of the country and the organization.", "evidence": "associated member refers to type='associated member'", "SQL": "SELECT DISTINCT c.Name, o.`Name`\nFROM `isMember` AS im\nJOIN `organization` AS o ON im.`Organization` = o.`Abbreviation`\nJOIN country c on im.Country = c.code\nWHERE im.`Type` = 'associate member';"} {"question_id": 8454, "db_id": "mondial_geo", "grading_method": "set", "question": "Which seas are directly connected to the Baltic Sea, and what is the Baltic Sea’s maximum depth?", "evidence": "Sea connections are recorded in mergesWith. The Baltic Sea may appear in either Sea1 or Sea2; the other column gives the connected sea. The Baltic Sea’s maximum depth refers to sea.Depth where Name = 'Baltic Sea'.", "SQL": "SELECT DISTINCT CASE WHEN T2.Sea1 = T1.Name THEN T2.Sea2 ELSE T2.Sea1 END AS ConnectedSea, T1.Depth FROM sea AS T1 INNER JOIN mergesWith AS T2 ON T1.Name = T2.Sea1 OR T1.Name = T2.Sea2 WHERE T1.Name = 'Baltic Sea'"} {"question_id": 8455, "db_id": "mondial_geo", "grading_method": "set", "question": "Which constitutional monarchies saw the greatest growth in the number of organizations after 1907?", "evidence": "politics.Government uses 'constitutional monarchy'. organization.Country is the headquarters country; organization.Abbreviation identifies an organization. organization.Established is its establishment date, stored as YYYY-MM-DD.", "SQL": "SELECT T1.Name FROM country AS T1 INNER JOIN organization AS T2 ON T1.Code = T2.Country INNER JOIN politics AS T3 ON T3.Country = T2.Country WHERE STRFTIME('%Y', T2.Established) > '1907' AND T3.Government = 'constitutional monarchy' GROUP BY T1.Name ORDER BY COUNT(DISTINCT T2.Name) DESC LIMIT 1"} {"question_id": 8460, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the full name of ABEDA and when was it established?", "evidence": "ABEDA is the abbreviation of an organization", "SQL": "SELECT Name, Established FROM organization WHERE Abbreviation = 'ABEDA'"} {"question_id": 8474, "db_id": "mondial_geo", "grading_method": "set", "question": "Name all countries with 'Category III' membership in 'IFAD' organization. Please also provide the capital of the country.", "evidence": "", "SQL": "SELECT Name, Capital FROM country WHERE Code IN ( SELECT Country FROM isMember WHERE type = 'Category III' AND Organization = 'IFAD' )"} {"question_id": 8477, "db_id": "mondial_geo", "grading_method": "set", "question": "What percentage of organizations headquartered in the USA are headquartered in Washington?", "evidence": "headquartered in the USA refers to organization.Country = 'USA'; in Washington refers to organization.City = 'Washington'; percentage = DIVIDE(COUNT(those USA organizations with City = 'Washington'), COUNT(City over those USA organizations)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T2.City = 'Washington' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.City) FROM country AS T1 INNER JOIN organization AS T2 ON T1.Code = T2.Country WHERE T2.Country = 'USA'"} {"question_id": 8486, "db_id": "mondial_geo", "grading_method": "set", "question": "List the capital names of all countries with a parliamentary democracy government.", "evidence": "politics.Government uses 'parliamentary democracy'.", "SQL": "SELECT T1.Capital FROM country AS T1 INNER JOIN politics AS T2 ON T1.Code = T2.Country WHERE T2.Government = 'parliamentary democracy'"} {"question_id": 8489, "db_id": "mondial_geo", "grading_method": "set", "question": "When did the United States of America gain independence?", "evidence": "The United States of America is recorded as country.Name = 'United States'. politics.Independence uses YYYY-MM-DD.", "SQL": "SELECT T1.Independence FROM politics AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T2.Name = 'United States'"} {"question_id": 8491, "db_id": "mondial_geo", "grading_method": "set", "question": "What is the name of the most recently founded organization in Saudi Arabia?", "evidence": "Saudi Arabia is a country", "SQL": "SELECT T1.Name FROM organization AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T2.Name = 'Saudi Arabia' ORDER BY T1.Established DESC LIMIT 1"} {"question_id": 8494, "db_id": "mondial_geo", "grading_method": "set", "question": "What river has the 17th-longest overall length? Specify its length.", "evidence": "river.Name and river.Length record the river name and length.", "SQL": "SELECT Name, Length FROM river ORDER BY Length DESC LIMIT 16, 1"} {"question_id": 8506, "db_id": "mondial_geo", "grading_method": "set", "question": "What percentage of countries became independent during the year 1960?", "evidence": "became independent during the year 1960 refers to an Independence date in 1960; percentage = DIVIDE(SUM(CASE WHEN Independence is in 1960 THEN 1 ELSE 0 END), COUNT(Country)) * 100 over politics", "SQL": "SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', Independence) = '1960' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(Country) FROM politics"} {"question_id": 8507, "db_id": "mondial_geo", "grading_method": "set", "question": "List all deserts whose absolute latitudes are between 30 and 40.", "evidence": "", "SQL": "SELECT `Name` FROM `desert` WHERE ABS(`Latitude`) BETWEEN 30 AND 40;"} {"question_id": 8508, "db_id": "mondial_geo", "grading_method": "set", "question": "Indicate the coordinates of all deserts that span more than one country.", "evidence": "desert.Latitude and desert.Longitude record coordinates; geo_desert.Country records countries containing a desert.", "SQL": "SELECT d.Latitude, d.Longitude\nFROM desert d JOIN geo_desert g ON d.Name = g.Desert\nGROUP BY d.Name, d.Latitude, d.Longitude\nHAVING COUNT(DISTINCT g.Country) > 1;"} {"question_id": 8511, "db_id": "software_company", "grading_method": "set", "question": "Among all the customers, how many of them are teenagers?", "evidence": "teenager is a person aged between 13 and 19 years;", "SQL": "SELECT COUNT(ID) FROM Customers WHERE age >= 13 AND age <= 19"} {"question_id": 8517, "db_id": "software_company", "grading_method": "set", "question": "Please list the occupations of customers over 40 who sent a true response to the marketing department’s incentive mailing.", "evidence": "Mailings1_2.RESPONSE and mailings3.RESPONSE use 'true' for a positive response. Customers.OCCUPATION records occupation.", "SQL": "WITH AllMailings AS (SELECT * FROM Mailings1_2 UNION SELECT * FROM mailings3) SELECT DISTINCT T1.OCCUPATION FROM Customers AS T1 INNER JOIN AllMailings AS T2 ON T1.ID = T2.REFID WHERE T1.age > 40 AND T2.RESPONSE = 'true'"} {"question_id": 8518, "db_id": "software_company", "grading_method": "set", "question": "Among the male customers, how many of them come from a place with over 30,000 inhabitants?", "evidence": "SEX = 'Male', over 30,000 inhabitants refer to NHABITANTS_K > 30; place refers to GEOID;", "SQL": "SELECT COUNT(T1.GEOID) FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID WHERE T1.SEX = 'Male' AND T2.INHABITANTS_K > 30"} {"question_id": 8523, "db_id": "software_company", "grading_method": "set", "question": "How many divorced male customers responded positively to an incentive mailing from the marketing department?", "evidence": "Mailings1_2.RESPONSE and mailings3.RESPONSE use 'true' for positive responses; REFID identifies the responding customer. Divorced male customers have Customers.SEX = 'Male' and Customers.MARITAL_STATUS = 'Divorced'.", "SQL": "WITH AllMailings AS (\n SELECT * FROM Mailings1_2\n UNION\n SELECT * FROM mailings3\n)\nSELECT COUNT(DISTINCT T1.ID)\nFROM Customers AS T1\nINNER JOIN AllMailings AS T2\n ON T1.ID = T2.REFID\nWHERE T1.SEX = 'Male'\n AND T1.MARITAL_STATUS = 'Divorced'\n AND T2.RESPONSE = 'true';"} {"question_id": 8525, "db_id": "software_company", "grading_method": "set", "question": "What is the population, in thousands, of the place where most customers are from?", "evidence": "the most customers are from refers to GEOID where MAX(COUNT(ID)); number of inhabitants in thousands refers to INHABITANTS_K;", "SQL": "with sub as ( SELECT `GEOID`, COUNT(*) as num\n FROM `Customers`\n GROUP BY `GEOID`\n )\nSELECT D.`INHABITANTS_K`\nFROM `Demog` D\nJOIN sub S on D.GEOID = S.GEOID\nWHERE num = (select max(num) from sub)"} {"question_id": 8527, "db_id": "software_company", "grading_method": "set", "question": "Among the first 60,000 customers, how many teenagers sent a true response to the marketing department’s incentive mailing?", "evidence": "The first 60,000 customers are represented in Mailings1_2; RESPONSE = 'true' denotes a positive response. Teenagers are aged 13 through 19.", "SQL": "SELECT COUNT(T1.ID) FROM Customers AS T1 INNER JOIN Mailings1_2 AS T2 ON T1.ID = T2.REFID WHERE T1.age >= 13 AND T1.age <= 19 AND T2.RESPONSE = 'true'"} {"question_id": 8528, "db_id": "software_company", "grading_method": "set", "question": "What is the average education level of customers from the place with the lowest average income per month?", "evidence": "place with the lowest average income per month refers to GEOID where MIN(INCOME_K); average education level refers to AVG(EDUCATIONNUM);", "SQL": "SELECT AVG(`EDUCATIONNUM`)\nFROM `Customers`\nWHERE `GEOID` = (\n SELECT `GEOID`\n FROM `Demog`\n ORDER BY `INCOME_K` \n LIMIT 1\n);"} {"question_id": 8531, "db_id": "software_company", "grading_method": "set", "question": "List down the customer's geographic identifier who are handlers or cleaners.", "evidence": "geographic identifier refers to GEOID; OCCUPATION = 'Handlers-cleaners';", "SQL": "SELECT GEOID FROM Customers WHERE OCCUPATION = 'Handlers-cleaners'"} {"question_id": 8547, "db_id": "software_company", "grading_method": "set", "question": "How many female customers aged 50 through 60 live in areas with 19,000 through 24,000 inhabitants?", "evidence": "Demog.INHABITANTS_K records population in thousands. Customers.GEOID identifies the geographic area.", "SQL": "SELECT COUNT(T1.ID) FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID WHERE T1.SEX = 'Female' AND T1.age >= 50 AND T1.age <= 60 AND T2.INHABITANTS_K >= 19 AND T2.INHABITANTS_K <= 24"} {"question_id": 8554, "db_id": "software_company", "grading_method": "set", "question": "Of customers who provide other services, how many are from places where inhabitants are more than 20000?", "evidence": "OCCUPATION = 'Other-service'; inhabitants are more than 20000 refer to INHABITANTS_K > 20;", "SQL": "SELECT COUNT(T2.GEOID) FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID WHERE T1.OCCUPATION = 'Other-service' AND T2.INHABITANTS_K > 20"} {"question_id": 8571, "db_id": "software_company", "grading_method": "set", "question": "List the marital status and response of female customers with an education level of 8 or above.", "evidence": "Customers.SEX = 'Female' denotes female; Customers.EDUCATIONNUM records education level. Mailings1_2.RESPONSE and mailings3.RESPONSE record mailing responses.", "SQL": "with sub as (\nselect * FROM Mailings1_2\nUNION \nselect * from mailings3\n)\nSELECT\n T1.`MARITAL_STATUS`,\n T2.`RESPONSE`\nFROM `Customers` AS T1\nJOIN sub AS T2\n ON T1.`ID` = T2.`REFID`\nWHERE T1.`SEX` = 'Female'\n AND T1.`EDUCATIONNUM` >= 8;"} {"question_id": 8572, "db_id": "software_company", "grading_method": "set", "question": "What are the ages of female customers living in areas with fewer than 30,000 inhabitants?", "evidence": "Demog.INHABITANTS_K records population in thousands. Customers.GEOID identifies the geographic area.", "SQL": "SELECT age FROM Customers WHERE GEOID IN ( SELECT GEOID FROM Demog WHERE INHABITANTS_K < 30 ) AND SEX = 'Female'"} {"question_id": 8576, "db_id": "software_company", "grading_method": "set", "question": "List the income and number of inhabitants for customers whose reference ID is greater than half the total number of false responses.", "evidence": "false responses refers to RESPONSE = 'false' in Mailings1_2 and mailings3; half the total number of false responses refers to 0.5 * COUNT(those responses); the customers listed refers to those whose REFID is greater than that; list both Demog.INCOME_K and Demog.INHABITANTS_K", "SQL": "WITH AllMailings AS (SELECT * FROM Mailings1_2 UNION SELECT * FROM mailings3) SELECT d.`INCOME_K`, d.`INHABITANTS_K` FROM Customers c JOIN Demog d ON c.`GEOID` = d.`GEOID` JOIN AllMailings m ON c.`ID` = m.`REFID` WHERE m.`REFID` > ( SELECT 0.5 * SUM(CASE WHEN `RESPONSE` = 'false' THEN 1 ELSE 0 END) FROM AllMailings )"} {"question_id": 8586, "db_id": "chicago_crime", "grading_method": "set", "question": "Which district is the community area Lincoln Square grouped into?", "evidence": "district refers to side; community area Lincoln Square refers to community_area_name = 'Lincoln Square'", "SQL": "SELECT side FROM Community_Area WHERE community_area_name = 'Lincoln Square'"} {"question_id": 8588, "db_id": "chicago_crime", "grading_method": "set", "question": "Which community area has the least population?", "evidence": "Community_Area.population stores population as text with comma thousands separators, so compare CAST(REPLACE(population, ',', '') AS INTEGER); the least population refers to the MIN of that compared value; return the community_area_name of the community area holding it", "SQL": "SELECT `community_area_name`\nFROM `Community_Area`\nWHERE CAST(REPLACE(population, ',', '') AS INTEGER) = (\n SELECT CAST(REPLACE(population, ',', '') AS INTEGER) \n FROM Community_Area\n ORDER BY CAST(REPLACE(population, ',', '') AS INTEGER)\n LIMIT 1)"} {"question_id": 8592, "db_id": "chicago_crime", "grading_method": "set", "question": "How many neighborhoods are there in the community area of Lincoln Square?", "evidence": "the community area of Lincoln Square refers to community_area_name = 'Lincoln Square'", "SQL": "SELECT COUNT(*)\nFROM `Neighborhood` AS N\nJOIN `Community_Area` AS C ON C.`community_area_no` = N.`community_area_no`\nWHERE C.`community_area_name` = 'Lincoln Square';"} {"question_id": 8593, "db_id": "chicago_crime", "grading_method": "set", "question": "Please list the names of all the neighborhoods in the community area with the most population.", "evidence": "name of neighborhood refers to neighborhood_name; the most population refers to max(population)", "SQL": "SELECT n.`neighborhood_name`\nFROM `Neighborhood` n\nJOIN `Community_Area` c ON n.`community_area_no` = c.`community_area_no`\nWHERE CAST(REPLACE(c.`population`, ',', '') AS INTEGER) = (\n SELECT MAX(CAST(REPLACE(`population`, ',', '') AS INTEGER))\n FROM `Community_Area`\n)"} {"question_id": 8597, "db_id": "chicago_crime", "grading_method": "set", "question": "Among all the crimes that had happened in Central Chicago, how many of them were cases of domestic violence?", "evidence": "Central Chicago refers to side = 'Central'; case of domestic violence refers to domestic = 'TRUE'", "SQL": "SELECT COUNT(*) FROM Crime AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no WHERE T2.side = 'Central' AND T1.domestic = 'TRUE'"} {"question_id": 8600, "db_id": "chicago_crime", "grading_method": "set", "question": "Among the crimes in Woodlawn, how many of them happened in January, 2018?", "evidence": "Woodlawn refers to community_area_name = 'Woodlawn'; in January 2018 refers to date like '1/%/2018%'", "SQL": "SELECT COUNT(*) AS num_crimes\nFROM `Crime` c\nJOIN `Community_Area` ca ON ca.`community_area_no` = c.`community_area_no`\nWHERE ca.`community_area_name` = 'Woodlawn'\n AND c.`date` LIKE '1/%/2018%' "} {"question_id": 8601, "db_id": "chicago_crime", "grading_method": "set", "question": "Which community area had more reported crimes in January 2018: Woodlawn or Lincoln Square?", "evidence": "in January 2018 refers to Crime.date LIKE '1/%/2018%'; reported crimes of a community area refers to the COUNT of Crime rows with that community_area_name; more reported crimes refers to whichever of 'Woodlawn' and 'Lincoln Square' had the larger such count", "SQL": "SELECT ca.community_area_name\nFROM Community_Area AS ca\nJOIN Crime AS c ON ca.community_area_no = c.community_area_no\nWHERE ca.community_area_name IN ('Woodlawn', 'Lincoln Square')\n AND (\n c.`date` LIKE '1/%/2018%' \n )\nGROUP BY ca.community_area_name\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8603, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the average number of crimes in a neighborhood in Central Chicago?", "evidence": "Central Chicago refers to side = 'Central'; average number = divide(count(report_no), count(neighborhood_name))", "SQL": "SELECT CAST(COUNT(*) AS REAL) / (SELECT COUNT(*)\n FROM `Neighborhood`\n WHERE `community_area_no` IN (SELECT `community_area_no`\n FROM `Community_Area`\n WHERE `side` = 'Central')) AS avg_crimes_per_neighborhood\nFROM `Crime` AS c\nJOIN `Community_Area` AS ca ON c.`community_area_no` = ca.`community_area_no`\nWHERE ca.`side` = 'Central';"} {"question_id": 8604, "db_id": "chicago_crime", "grading_method": "set", "question": "Among recorded crime cases assigned to a Chicago district, what percentage occurred in the Central district? Round your answer to 4 decimal places.", "evidence": "assigned to a Chicago district refers to Crime.district_no matching District.district_no; the Central district refers to District.district_name = 'Central'; crime cases refers to COUNT(DISTINCT case_number); percentage = ROUND(DIVIDE(COUNT(DISTINCT case_number in the Central district), COUNT(DISTINCT case_number)) * 100, 4)", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * COUNT(DISTINCT CASE WHEN d.district_name='Central' THEN c.case_number END) / COUNT(DISTINCT c.case_number) FROM Crime c JOIN District d ON d.district_no=c.district_no\n) SELECT ROUND(value, 4) FROM unrounded;"} {"question_id": 8605, "db_id": "chicago_crime", "grading_method": "set", "question": "How many community areas are in the Far North side?", "evidence": "the Far North side refers to side = 'Far North '", "SQL": "SELECT COUNT(*) FROM Community_Area WHERE side = 'Far North '"} {"question_id": 8608, "db_id": "chicago_crime", "grading_method": "set", "question": "Where is the coordinate (41.66236555, -87.63470194) located? Give the name of the district.", "evidence": "coordinate (41.66236555, -87.63470194) refers to latitude = '41.66236555' AND longitude = '-87.63470194'; name of the district refers to district_name", "SQL": "SELECT T2.district_name FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.longitude = '-87.63470194' AND T1.latitude = '41.66236555'"} {"question_id": 8612, "db_id": "chicago_crime", "grading_method": "set", "question": "How severe was case JB296775? Give the index code for severity.", "evidence": "index code refers to index_code; case JB296775 refers to case_number = 'JB296775'", "SQL": "SELECT DISTINCT IUCR.`index_code`\nFROM `Crime`\nJOIN `IUCR` ON `Crime`.`iucr_no` = `IUCR`.`iucr_no`\nWHERE `Crime`.`case_number` = 'JB296775';"} {"question_id": 8615, "db_id": "chicago_crime", "grading_method": "set", "question": "Give the neighborhood name of West Englewood community.", "evidence": "West Englewood community refers to community_area_name = 'West Englewood'", "SQL": "SELECT T1.neighborhood_name FROM Neighborhood AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no WHERE T2.community_area_name = 'West Englewood'"} {"question_id": 8616, "db_id": "chicago_crime", "grading_method": "set", "question": "How many different neighborhoods are there in Roseland community?", "evidence": "Roseland community refers to community_area_name = 'Roseland'", "SQL": "SELECT SUM(CASE WHEN T1.community_area_name = 'Roseland' THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no"} {"question_id": 8619, "db_id": "chicago_crime", "grading_method": "set", "question": "Of all cases recorded in West Englewood, what percentage were thefts classified as $500 and under? Round your answer to 2 decimal places.", "evidence": "West Englewood refers to community_area_name = 'West Englewood'; a $500-and-under theft refers to IUCR.primary_description = 'THEFT' AND secondary_description = '$500 AND UNDER'; percentage = DIVIDE(COUNT(DISTINCT case_number so classified), COUNT(DISTINCT case_number in West Englewood)) * 100, rounded to 2 decimals", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * COUNT(DISTINCT CASE WHEN i.primary_description='THEFT' AND i.secondary_description='$500 AND UNDER' THEN c.case_number END) / COUNT(DISTINCT c.case_number) FROM Crime c JOIN Community_Area ca ON ca.community_area_no=c.community_area_no LEFT JOIN IUCR i ON i.iucr_no=c.iucr_no WHERE ca.community_area_name='West Englewood'\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 8629, "db_id": "chicago_crime", "grading_method": "set", "question": "In Albany Park, how many arrests were made in an apartment due to criminal sexual abuse?", "evidence": "Albany Park refers to district_name = 'Albany Park'; in an apartment refers to location_description = 'APARTMENT'; criminal sexual abuse refers to title = 'Criminal Sexual Abuse'", "SQL": "SELECT SUM(CASE WHEN T3.title = 'Criminal Sexual Abuse' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T1.district_name = 'Albany Park' AND T2.arrest = 'TRUE' AND T2.location_description = 'APARTMENT'"} {"question_id": 8632, "db_id": "chicago_crime", "grading_method": "set", "question": "In the most populated ward, how many incidents of domestic violence were reported in a bar or tavern?", "evidence": "the most populated refers to max(population); domestic violence refers to domestic = 'TRUE'; in a bar or tavern refers to location_description = 'BAR OR TAVERN'", "SQL": "WITH most_pop_ward AS (\n SELECT `ward_no`\n FROM `Ward`\n ORDER BY CAST(`Population` AS INTEGER) DESC\n LIMIT 1\n)\nSELECT COUNT(*) AS incident_count\nFROM `Crime`\nWHERE `ward_no` = (SELECT `ward_no` FROM most_pop_ward)\n AND `domestic` = 'TRUE'\n AND `location_description` = 'BAR OR TAVERN';"} {"question_id": 8634, "db_id": "chicago_crime", "grading_method": "set", "question": "Out of all the incidents of domestic violence reported at the ward represented by alderman Walter Burnett Jr., how many were arrested?", "evidence": "domestic violence refers to domestic = 'TRUE'; arrested refers to arrest = 'TRUE'", "SQL": "SELECT SUM(CASE WHEN T2.arrest = 'TRUE' THEN 1 ELSE 0 END) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T1.alderman_first_name = 'Walter' AND T1.alderman_last_name = 'Burnett' AND alderman_name_suffix = 'Jr.' AND T2.domestic = 'TRUE'"} {"question_id": 8635, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the short description of the crime committed the most by criminals in the least populated community?", "evidence": "the least populated community refers to the community with the lowest population after removing commas and converting it to an INTEGER; committed the most refers to the highest COUNT(*) of crime records grouped by FBI_Code.title among criminals in that selected community; short description refers to that FBI_Code.title", "SQL": "WITH least_pop AS (\n SELECT community_area_no\n FROM Community_Area\n ORDER BY CAST(REPLACE(population, ',', '') AS INTEGER) ASC\n LIMIT 1\n)\nSELECT fc.title\nFROM Crime c\nJOIN least_pop lp ON c.community_area_no = lp.community_area_no\nJOIN FBI_Code fc ON c.fbi_code_no = fc.fbi_code_no\nGROUP BY fc.title\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8637, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the name of the community that has the highest number of crimes related to prostitution?", "evidence": "name of the community refers to community_area_name; the highest number of crimes refers to max(case_number); prostitution refers to primary_description = 'PROSTITUTION'", "SQL": "with sub as (SELECT CA.`community_area_name`, count(*) as num\nFROM `Crime` C\nJOIN `IUCR` I ON C.`iucr_no` = I.`iucr_no`\nJOIN `Community_Area` CA ON C.`community_area_no` = CA.`community_area_no`\nWHERE I.`primary_description` = 'PROSTITUTION'\nGROUP BY CA.`community_area_no`\n)\nselect community_area_name from sub where num = (select max(num) from sub)"} {"question_id": 8641, "db_id": "chicago_crime", "grading_method": "set", "question": "Provide the responsible person and his/her email address of Chicago Lawn.", "evidence": "responsible person refers to commander; email address refers to email; Chicago Lawn refers to district_name = 'Chicago Lawn'", "SQL": "SELECT commander, email FROM District WHERE district_name = 'Chicago Lawn'"} {"question_id": 8644, "db_id": "chicago_crime", "grading_method": "set", "question": "List the titles and descriptions of crime categories classified as crimes against persons.", "evidence": "Crime-category titles and descriptions are recorded in FBI_Code; crime_against = 'Persons' denotes crimes against persons.", "SQL": "SELECT title, description FROM FBI_Code WHERE crime_against = 'Persons'"} {"question_id": 8648, "db_id": "chicago_crime", "grading_method": "set", "question": "For crimes on 0000X N FRANCISCO AVE, list the case number, the alderman’s first and last names, and the district name, in that order.", "evidence": "Crime.block records '0000X N FRANCISCO AVE'. Ward.alderman_first_name and alderman_last_name record the requested name components; District.district_name records the district name.", "SQL": "SELECT T2.case_number, T3.alderman_first_name, T3.alderman_last_name, T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no INNER JOIN Ward AS T3 ON T2.ward_no = T3.ward_no WHERE T2.block = '0000X N FRANCISCO AVE' GROUP BY T2.case_number, T3.alderman_first_name, T3.alderman_last_name, T1.district_name"} {"question_id": 8650, "db_id": "chicago_crime", "grading_method": "set", "question": "List down the neighborhood areas of Douglas.", "evidence": "neighborhood area refers to neighborhood_name; Douglas refers to community_area_name = 'Douglas'", "SQL": "SELECT T2.neighborhood_name FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'Douglas'"} {"question_id": 8653, "db_id": "chicago_crime", "grading_method": "set", "question": "List the location descriptions and aldermen's full names of the arson by explosive.", "evidence": "aldermen's full name refers to alderman_name_suffix, alderman_first_name, alderman_last_name; arson by explosive refers to primary_description = 'ARSON' AND secondary_description = 'BY EXPLOSIVE'", "SQL": "SELECT T2.location_description, T1.alderman_first_name, T1.alderman_last_name, T1.alderman_name_suffix FROM Ward AS T1 INNER JOIN Crime AS T2 ON T2.ward_no = T1.ward_no INNER JOIN IUCR AS T3 ON T3.iucr_no = T2.iucr_no WHERE T3.primary_description = 'ARSON' AND T3.secondary_description = 'BY EXPLOSIVE'"} {"question_id": 8654, "db_id": "chicago_crime", "grading_method": "set", "question": "Provide the occurrence date and location of the deceptive practice due to the unlawful use of recorded sound.", "evidence": "location refers to latitude, longitude; deceptive practice refers to primary_description = 'DECEPTIVE PRACTICE'; unlawful use of recorded sound refers to secondary_description = 'UNLAWFUL USE OF RECORDED SOUND'", "SQL": "SELECT T2.date, T2.latitude, T2.longitude FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no WHERE T1.primary_description = 'DECEPTIVE PRACTICE' AND T1.secondary_description = 'UNLAWFUL USE OF RECORDED SOUND'"} {"question_id": 8664, "db_id": "chicago_crime", "grading_method": "set", "question": "List the case numbers of domestic violence crimes reported in Lincoln Square.", "evidence": "domestic violence refers to domestic = 'TRUE'; Lincoln Square refers to community_area_name = 'Lincoln Square'", "SQL": "SELECT T2.case_number FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'Lincoln Square' AND T2.domestic = 'TRUE'"} {"question_id": 8666, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the total number of crimes that happened in Bridgeport with beat less than 1000?", "evidence": "Bridgeport refers to community_area_name = 'Bridgeport'; with beat less than 1000 refers to beat < 1000; total number = count(beat) where community_area_name = 'Bridgeport' and beat < 1000", "SQL": "SELECT SUM(CASE WHEN T2.beat < 1000 THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'Bridgeport'"} {"question_id": 8670, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the district address associated with the case JB107731?", "evidence": "case JB107731 refers to case_number = 'JB107731'", "SQL": "SELECT T1.address FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T2.case_number = 'JB107731'"} {"question_id": 8673, "db_id": "chicago_crime", "grading_method": "set", "question": "Among the crimes located in the community area with the highest population, what is the percentage of domestic violence?", "evidence": "the highest population refers to max(population); domestic violence refers to domestic = 'TRUE'; percentage = divide(count(domestic = 'TRUE'), count(domestic)) where population = max(population) * 100%", "SQL": "WITH top_ca AS (\n SELECT `community_area_no`\n FROM `Community_Area`\n ORDER BY CAST(REPLACE(`population`, ',', '') AS INTEGER) DESC\n LIMIT 1\n)\nSELECT 100.0 * SUM(CASE WHEN `domestic` = 'TRUE' THEN 1 ELSE 0 END) / COUNT(*) AS domestic_percentage\nFROM `Crime`\nWHERE `community_area_no` = (SELECT `community_area_no` FROM top_ca);"} {"question_id": 8674, "db_id": "chicago_crime", "grading_method": "set", "question": "List the case numbers of crimes that occurred in wards with populations below 52,000 whose beat is greater than 90% of the average beat of all crimes in those wards.", "evidence": "population below 52000 refers to population < 52000; beat greater than the 90% of the average beat refers to beat > multiply(avg(beat), 0.9) where population < 52000", "SQL": "WITH avg_beat AS (\n SELECT AVG(T1.beat) as avg_be FROM Crime AS T1 INNER JOIN Ward AS T2 ON T1.ward_no = T2.ward_no WHERE CAST(T2.Population AS INTEGER) < 52000\n)\nSELECT DISTINCT c.`case_number`\nFROM `Crime` AS c\nJOIN `Ward` AS w ON c.`ward_no` = w.`ward_no`\nJOIN avg_beat AS a\nWHERE CAST(w.`Population` AS INTEGER) < 52000\n AND c.`beat` > 0.9 * a.`avg_be`;"} {"question_id": 8679, "db_id": "chicago_crime", "grading_method": "set", "question": "What percentage of recorded crime cases are classified as severe? Round your answer to 2 decimal places.", "evidence": "crime cases refers to COUNT(DISTINCT case_number), since repeated rows can describe the same case; severe refers to index_code = 'I' on the matching IUCR classification, with cases that lack one kept in the denominator; percentage = ROUND(DIVIDE(COUNT(DISTINCT severe case_number), COUNT(DISTINCT case_number)) * 100, 2)", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * COUNT(DISTINCT CASE WHEN i.index_code='I' THEN c.case_number END) / COUNT(DISTINCT c.case_number) FROM Crime c LEFT JOIN IUCR i ON i.iucr_no=c.iucr_no\n) SELECT ROUND(value, 2) FROM unrounded;"} {"question_id": 8680, "db_id": "chicago_crime", "grading_method": "set", "question": "What type of location in Austin had the most reported crimes?", "evidence": "Austin refers to District.district_name = 'Austin'; type of location refers to Crime.location_description; the most reported crimes refers to the location_description with the highest COUNT(case_number) among Austin crimes, taking the single top one", "SQL": "SELECT T2.location_description FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T1.district_name = 'Austin' GROUP BY T2.location_description ORDER BY COUNT(T2.case_number) DESC LIMIT 1"} {"question_id": 8683, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the average number of reckless homicides that happened in a district?", "evidence": "\"RECKLESS HOMICIDE\" is the secondary_description; average = Divide (Count(report_no), Count(district_name))", "SQL": "SELECT CAST(COUNT(*) AS REAL) /\n (SELECT COUNT(*) FROM `District`) AS avg_reckless_homicides_per_district\nFROM `Crime` c\nJOIN `IUCR` i ON i.`iucr_no` = c.`iucr_no`\nWHERE i.`secondary_description` = 'RECKLESS HOMICIDE';"} {"question_id": 8687, "db_id": "chicago_crime", "grading_method": "set", "question": "Find the community area where the least number of domestic crimes happened.", "evidence": "least number of domestic crime refers to Min(Count(domestic = \"TRUE\")); community area refers to community_area_no", "SQL": "SELECT T2.community_area_no FROM Crime AS T1 INNER JOIN Community_Area AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.domestic = 'TRUE' GROUP BY T2.community_area_no ORDER BY COUNT(T2.community_area_no) ASC LIMIT 1"} {"question_id": 8690, "db_id": "chicago_crime", "grading_method": "set", "question": "Which communities had more solicitation-for-prostitution reports than the average across all communities? List their names and populations.", "evidence": "solicitation-for-prostitution reports refers to crime records whose IUCR.secondary_description = 'SOLICIT FOR PROSTITUTE', counted for each community; the average refers to AVG of those per-community report counts across all communities; list the Community_Area.community_area_name and population of each community whose count is greater than that average", "SQL": "WITH solicit_counts AS (\n SELECT ca.`community_area_no`,\n SUM(CASE WHEN i.`secondary_description` = 'SOLICIT FOR PROSTITUTE' THEN 1 ELSE 0 END) AS solicit_cnt\n FROM `Community_Area` ca\n LEFT JOIN `Crime` c\n ON c.`community_area_no` = ca.`community_area_no`\n LEFT JOIN `IUCR` i\n ON i.`iucr_no` = c.`iucr_no`\n GROUP BY ca.`community_area_no`\n), avg_val AS (\n SELECT AVG(solicit_cnt*1.0) AS avg_cnt\n FROM solicit_counts\n)\nSELECT ca.`community_area_name`, ca.`population`\nFROM solicit_counts sc\nJOIN avg_val a ON 1=1\nJOIN `Community_Area` ca ON ca.`community_area_no` = sc.`community_area_no`\nWHERE sc.solicit_cnt > a.avg_cnt;"} {"question_id": 8692, "db_id": "chicago_crime", "grading_method": "set", "question": "Calculate the difference in the average number of vehicular hijackings and aggravated vehicular hijackings in the districts.", "evidence": "\"VEHICULAR HIJACKING\" and \"AGGRAVATED VEHICULAR HIJACKING\" are both secondary_description; difference in average = Subtract (Divide(Count(secondary_description = 'VEHICULAR HIJACKING'), Count(district_name)), Divide(Count(secondary_description = \"AGGRAVATED VEHICULAR HIJACKING\"), Count(district_name)))", "SQL": "SELECT CAST(COUNT(CASE WHEN T1.secondary_description = 'VEHICULAR HIJACKING' THEN T1.iucr_no END) AS REAL) / CAST(COUNT(DISTINCT CASE WHEN T1.secondary_description = 'VEHICULAR HIJACKING' THEN T3.district_name END) AS REAL) - CAST(COUNT(CASE WHEN T1.secondary_description = 'AGGRAVATED VEHICULAR HIJACKING' THEN T1.iucr_no END) AS REAL) / CAST(COUNT(DISTINCT CASE WHEN T1.secondary_description = 'AGGRAVATED VEHICULAR HIJACKING' THEN T3.district_name END) AS REAL) AS \"difference\" 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"} {"question_id": 8695, "db_id": "chicago_crime", "grading_method": "set", "question": "What are the first names of aldermen for wards with more than 50,000 inhabitants?", "evidence": "Ward.alderman_first_name records the alderman’s first name.", "SQL": "SELECT alderman_first_name FROM Ward WHERE Population > 50000"} {"question_id": 8696, "db_id": "chicago_crime", "grading_method": "set", "question": "List crimes that the FBI has classified as Drug Abuse by their report number.", "evidence": "\"Drug Abuse\" is the title of crime", "SQL": "SELECT T2.report_no FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T2.fbi_code_no = T1.fbi_code_no WHERE T1.title = 'Drug Abuse'"} {"question_id": 8700, "db_id": "chicago_crime", "grading_method": "set", "question": "How many domestic crime cases has Commander Ronald A. Pontecore Jr. been responsible for investigating?", "evidence": "domestic crime refers to domestic = 'TRUE'; person responsible for investigating refers to commander", "SQL": "SELECT SUM(CASE WHEN T2.domestic = 'TRUE' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T1.commander = 'Ronald A. Pontecore Jr.'"} {"question_id": 8705, "db_id": "chicago_crime", "grading_method": "set", "question": "Which types of domestic crimes occurred most often in the North Lawndale community?", "evidence": "North Lawndale community refers to Community_Area.community_area_name = 'North Lawndale'; domestic refers to Crime.domestic = 'TRUE'; type of crime refers to IUCR.primary_description; occurred most often refers to the single primary_description with the highest COUNT of such crimes", "SQL": "SELECT iucr.`primary_description`\nFROM `Community_Area` ca\nJOIN `Crime` c ON c.`community_area_no` = ca.`community_area_no`\nJOIN `IUCR` iucr ON iucr.`iucr_no` = c.`iucr_no`\nWHERE ca.`community_area_name` = 'North Lawndale'\n AND c.`domestic` = 'TRUE'\nGROUP BY iucr.`primary_description`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8709, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the average population of the wards where apartment crimes have been reported without arrests?", "evidence": "apartment crime refers to location_description = 'APARTMENT';  without arrest refers to arrest = 'FALSE'; average population = AVG(Population)", "SQL": "SELECT AVG(CAST(W.`Population` AS REAL)) AS avg_population\nFROM `Ward` AS W\nWHERE W.`ward_no` IN (\n SELECT DISTINCT `ward_no`\n FROM `Crime`\n WHERE `location_description` = 'APARTMENT'\n AND `arrest` = 'FALSE'\n);\n"} {"question_id": 8710, "db_id": "chicago_crime", "grading_method": "set", "question": "What are the full names of the aldermen for the five most populous wards?", "evidence": "the five most populous wards refers to ordering Ward rows by Ward.Population descending and taking the top 5; full name refers to Ward.alderman_first_name and Ward.alderman_last_name; return both name columns", "SQL": "SELECT alderman_first_name, alderman_last_name FROM Ward ORDER BY Population DESC LIMIT 5"} {"question_id": 8711, "db_id": "chicago_crime", "grading_method": "set", "question": "How many crime against property are there?", "evidence": "", "SQL": "SELECT COUNT(*) AS cnt\nFROM `Crime` AS c\nJOIN `FBI_Code` AS f ON c.`fbi_code_no` = f.`fbi_code_no`\nWHERE f.`crime_against` = 'Property';"} {"question_id": 8716, "db_id": "chicago_crime", "grading_method": "set", "question": "Who is the commanding officer in the district with the highest number of reported crimes where no arrest has been made?", "evidence": "where no arrest refers to arrest = 'FALSE'; highest number of crime refers to Max(Count(report_no)); commanding officer 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.arrest = 'FALSE' GROUP BY T2.commander ORDER BY COUNT(T1.report_no) DESC LIMIT 1"} {"question_id": 8718, "db_id": "chicago_crime", "grading_method": "set", "question": "Between Deering and Near West districts, which district reported the most number of crime incidents that happened in a library?", "evidence": "\"Deering\" and \"Near West\" are both district_name; 'LIBRARY' is the location_description; district with the most number of crime Max(Count(district_no))", "SQL": "SELECT T1.district_name FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.district_name IN ('Deering', 'Near West') AND T2.location_description = 'LIBRARY' GROUP BY T1.district_name ORDER BY COUNT(T2.district_no) DESC LIMIT 1"} {"question_id": 8721, "db_id": "chicago_crime", "grading_method": "set", "question": "In the least populated community, what is the most common location of all the reported crime incidents?", "evidence": "least populated refers to Min(Population); community refers to community_area_no; most common location refers to Max(Count(location_description))", "SQL": "WITH least_pop AS (\n SELECT community_area_no\n FROM Community_Area\n ORDER BY CAST(REPLACE(population, ',', '') AS INTEGER) ASC\n LIMIT 1\n)\nSELECT location_description\nFROM Crime\nWHERE community_area_no = (SELECT community_area_no FROM least_pop)\nGROUP BY location_description\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8724, "db_id": "chicago_crime", "grading_method": "set", "question": "In the South side community, what is the name of the community with the most reported incidents of unlawful taking, carrying, leading, or riding away of property from the possession or constructive possession of another person?", "evidence": "\"The unlawful taking, carrying, leading, or riding away of property from the possession or constructive possession of another person.\" is the description; name of community refer to community_area_name; most reported incidents refers to Max(Count(fbi_code_no))", "SQL": "SELECT ca.`community_area_name`\nFROM `Crime` AS c\nJOIN `Community_Area` AS ca ON ca.`community_area_no` = c.`community_area_no`\nJOIN `FBI_Code` AS f ON f.`fbi_code_no` = c.`fbi_code_no`\nWHERE TRIM(ca.`side`) = 'South'\n AND f.`description` = 'The unlawful taking, carrying, leading, or riding away of property from the possession or constructive possession of another person.'\nGROUP BY ca.`community_area_name`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8729, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the difference between the number of communities that are located on the north and south sides with a population of more than 30,000?", "evidence": "population of more than 30000 refers to Population > 30000; 'North' and 'South' both are the side; different number of community refers to Subtract(Count(Community_area_no where side = 'South'), Count(Community_area_no where side = 'North'))", "SQL": "WITH filtered AS (\n SELECT TRIM(`side`) AS side\n FROM `Community_Area`\n WHERE CAST(REPLACE(`population`, ',', '') AS INTEGER) > 30000\n)\nSELECT\n (SELECT COUNT(*) FROM filtered WHERE side = 'South') -\n (SELECT COUNT(*) FROM filtered WHERE side = 'North') AS difference;"} {"question_id": 8730, "db_id": "chicago_crime", "grading_method": "set", "question": "Please list all of the contact information for the police district Near West.", "evidence": "\"Near West\" is the district_name; all contact information refers to phone, fax, tty, twitter", "SQL": "SELECT phone, fax, tty, twitter FROM District WHERE district_name = 'Near West'"} {"question_id": 8732, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the general and specific description of incident 275?", "evidence": "incident 275 refers to iucr_no = 275; general description refers to primary_description; specific description refers to secondary_description", "SQL": "SELECT primary_description, secondary_description FROM IUCR WHERE iucr_no = 275"} {"question_id": 8735, "db_id": "chicago_crime", "grading_method": "set", "question": "How many neighborhoods can be found in the Forest Glen community area?", "evidence": "\"Forest Glen\" is the community_area_name; neighborhoods refers to neighborhood_name", "SQL": "SELECT SUM(CASE WHEN T2.community_area_name = 'Forest Glen' THEN 1 ELSE 0 END) FROM Neighborhood AS T1 INNER JOIN Community_Area AS T2 ON T1.community_area_no = T2.community_area_no"} {"question_id": 8737, "db_id": "chicago_crime", "grading_method": "set", "question": "How many crime cases have been classified as \"Weapons Violation\" by the FBI?", "evidence": "\"Weapons Violation\" is the title of FBI code; crime cases refers to report_no;", "SQL": "SELECT SUM(CASE WHEN T2.title = 'Weapons Violation' THEN 1 ELSE 0 END) FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no"} {"question_id": 8739, "db_id": "chicago_crime", "grading_method": "set", "question": "Please state the district name where incident number JB106545 took place.", "evidence": "incident number JB106545 refers to case_number = 'JB106545'", "SQL": "SELECT DISTINCT D.`district_name`\nFROM `Crime` AS C\nJOIN `District` AS D ON C.`district_no` = D.`district_no`\nWHERE C.`case_number` = 'JB106545';"} {"question_id": 8741, "db_id": "chicago_crime", "grading_method": "subset,=,3", "question": "Name three communities where a fraud incident occurred.", "evidence": "Community names are Community_Area.community_area_name. Fraud is identified by FBI_Code.title = 'Fraud'.", "SQL": "SELECT DISTINCT T3.`community_area_name` 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 T1.`title` = 'Fraud'"} {"question_id": 8746, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the beat and location description of the case JB112212?", "evidence": "case JB112212 refers to case_number = 'JB112212'", "SQL": "SELECT beat, location_description FROM Crime WHERE case_number = 'JB112212'"} {"question_id": 8747, "db_id": "chicago_crime", "grading_method": "set", "question": "Give the FBI code for the crime described by \"The killing of one human being by another.\"", "evidence": "\"The killing of one human being by another\" is the description; FBI code refers to fbi_code_no", "SQL": "SELECT fbi_code_no FROM FBI_Code WHERE description = 'The killing of one human being by another.'"} {"question_id": 8748, "db_id": "chicago_crime", "grading_method": "set", "question": "Provide all the ward office addresses associated with the crimes that happened in the community of Montclare.", "evidence": "\"Montclare\" is the community_area_name", "SQL": "SELECT T3.ward_office_address FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN Ward AS T3 ON T2.ward_no = T3.ward_no WHERE T1.community_area_name = 'Montclare' GROUP BY T3.ward_office_address"} {"question_id": 8753, "db_id": "chicago_crime", "grading_method": "set", "question": "List the report numbers of crimes associated with district commander Jill M. Stevens.", "evidence": "Crime report numbers are Crime.report_no. District commander is District.commander; Jill M. Stevens is stored as 'Jill M. Stevens'.", "SQL": "SELECT DISTINCT `T2`.`report_no`\nFROM `Crime` AS `T2`\nJOIN `District` AS `T1` ON `T1`.`district_no` = `T2`.`district_no`\nWHERE `T1`.`commander` = 'Jill M. Stevens';"} {"question_id": 8756, "db_id": "chicago_crime", "grading_method": "set", "question": "What is the ward ID of the most crowded ward?", "evidence": "most crowded ward refers to Max(Population)", "SQL": "SELECT ward_no FROM Ward ORDER BY Population DESC LIMIT 1"} {"question_id": 8757, "db_id": "chicago_crime", "grading_method": "set", "question": "How many incidents have the general description of \"ASSAULT\" in the IUCR classification?", "evidence": "IUCR.primary_description = 'ASSAULT' identifies the classification. Crime contains incident records; Crime.iucr_no identifies each incident’s IUCR classification.", "SQL": "SELECT COUNT(*)\nFROM `Crime` AS c\nJOIN `IUCR` AS i ON c.`iucr_no` = i.`iucr_no`\nWHERE i.`primary_description` = 'ASSAULT';"} {"question_id": 8765, "db_id": "chicago_crime", "grading_method": "set", "question": "Among the incidents with the generic description of \"BATTERY\" in the IUCR classification, how many of them do not have arrests made?", "evidence": "general description refers to primary_description; 'BATTERY' is the primary_description; do not have arrest made refers to arrest = 'FALSE'", "SQL": "SELECT SUM(CASE WHEN T2.arrest = 'FALSE' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'"} {"question_id": 8767, "db_id": "chicago_crime", "grading_method": "set", "question": "Among the incidents in January, 2018, how many of them were stated \"against Property\" in the FBI classification?", "evidence": "Crime.date stores month/day/year dates with a time component; month and day widths can vary. FBI_Code.crime_against = 'Property' identifies crimes against property.", "SQL": "SELECT COUNT(*) FROM `Crime` AS c JOIN `FBI_Code` AS f ON f.`fbi_code_no` = c.`fbi_code_no` WHERE f.`crime_against` = 'Property' AND c.`date` LIKE '1/%/2018%'"} {"question_id": 8775, "db_id": "food_inspection", "grading_method": "set", "question": "Among the inspections carried out in 2016, how many of them are routine?", "evidence": "inspections carried out in 2016 refer to YEAR(date) = 2016; routine inspections refer to type LIKE 'Routine%';", "SQL": "SELECT COUNT(*)\nFROM inspections\nWHERE STRFTIME('%Y', `date`) = '2016'\n AND `type` LIKE 'Routine%';"} {"question_id": 8776, "db_id": "food_inspection", "grading_method": "set", "question": "Please list the names of all the restaurants that have met all requirements in one inspection.", "evidence": "met all requirements refers to inspections where score = 100;", "SQL": "SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100"} {"question_id": 8777, "db_id": "food_inspection", "grading_method": "set", "question": "Among the restaurants being inspected in 2016, how many of them are in San Francisco?", "evidence": "inspected in 2016 refers to YEAR(date) = 2016; San Francisco refers to city in ('San Francisco', 'SF' ,'S.F.', 'SAN FRANCISCO');", "SQL": "SELECT COUNT(DISTINCT T2.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2016' AND T2.city IN ('San Francisco', 'SAN FRANCISCO', 'SF', 'S.F.')"} {"question_id": 8780, "db_id": "food_inspection", "grading_method": "set", "question": "Which restaurants had a low-risk violation recorded in 2014? List their names.", "evidence": "violations.date records the violation date; violations.risk_category = 'Low Risk' identifies low-risk violations. businesses.name records the business name.", "SQL": "SELECT DISTINCT T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2014' AND T1.risk_category = 'Low Risk'"} {"question_id": 8784, "db_id": "food_inspection", "grading_method": "set", "question": "Among the routine inspections of Tiramisu Kitchen, how many of them have a score of over 70?", "evidence": "Tiramisu Kitchen is the name of the business; routine inspections refer to type LIKE 'Routine%'; score of over 70 refers to score > 70;", "SQL": "SELECT COUNT(T2.business_id) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen' AND T1.type LIKE 'Routine%' AND T1.score > 70"} {"question_id": 8788, "db_id": "food_inspection", "grading_method": "set", "question": "What is the average score for Tiramisu Kitchen across all inspections?", "evidence": "Tiramisu Kitchen refers to businesses.name = 'Tiramisu Kitchen'; average score refers to AVG(inspections.score) over that business's inspections, which skips inspections with no recorded score", "SQL": "SELECT AVG(T1.score) FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen'"} {"question_id": 8791, "db_id": "food_inspection", "grading_method": "set", "question": "Give the name of the business which met all the required standards during the unscheduled routine inspection on 2016/9/28.", "evidence": "met all the required standards refers to score = 100; unscheduled routine inspection on 2016/9/28 refers to type = 'Routine - Unscheduled' where date = '2016-09-28';", "SQL": "SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100 AND T1.`date` = '2016-09-28' AND T1.type = 'Routine - Unscheduled'"} {"question_id": 8792, "db_id": "food_inspection", "grading_method": "set", "question": "Which business had the most number of high risk violations? Give the name of the business.", "evidence": "the most number of high risk violations refers to MAX(COUNT(business_id)) where risk_category = 'High';", "SQL": "SELECT b.`name`\nFROM `violations` AS v\nJOIN `businesses` AS b ON v.`business_id` = b.`business_id`\nWHERE v.`risk_category` = 'High Risk'\nGROUP BY v.`business_id`\nORDER BY COUNT(*) DESC\nLIMIT 1;"} {"question_id": 8796, "db_id": "food_inspection", "grading_method": "set", "question": "Provide the name of the business which had the most number of inspections because of complaint.", "evidence": "the most number of inspections because of complaint refers to type = 'Complaint' where MAX(COUNT(business_id));", "SQL": "with subquery as (SELECT b.`name`, COUNT(*) as num\nFROM `inspections` AS i\nJOIN `businesses` AS b ON i.`business_id` = b.`business_id`\nWHERE i.`type` = 'Complaint'\nGROUP BY i.`business_id`, b.`name`\n)\nselect name from subquery where num = (select max(num) from subquery)"} {"question_id": 8803, "db_id": "food_inspection", "grading_method": "set", "question": "What percentage of the violations for \"Melody Lounge\" are moderate risks?", "evidence": "the violations for 'Melody Lounge' refers to the violations of the businesses row whose name = 'Melody Lounge'; moderate risks refers to risk_category = 'Moderate Risk'; percentage = DIVIDE(SUM(CASE WHEN risk_category = 'Moderate Risk' THEN 1 ELSE 0 END), COUNT(those violations)) * 100", "SQL": "SELECT CAST(SUM(CASE WHEN T2.risk_category = 'Moderate Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.business_id) FROM businesses AS T1 INNER JOIN violations AS T2 ON T1.business_id = T2.business_id WHERE T1.name = 'Melody Lounge'"} {"question_id": 8804, "db_id": "food_inspection", "grading_method": "set", "question": "How many eateries are located in Hayward?", "evidence": "eateries in Hayward refer city = 'HAYWARD';", "SQL": "SELECT COUNT(business_id) FROM businesses WHERE city = 'HAYWARD'"} {"question_id": 8806, "db_id": "food_inspection", "grading_method": "set", "question": "How many eateries applied in 2012?", "evidence": "eateries applied in 2012 refer to business_id where application_date between '2012-01-01' and '2012-12-31';", "SQL": "SELECT COUNT(business_id) FROM businesses WHERE STRFTIME('%Y', application_date) = '2012'"} {"question_id": 8812, "db_id": "food_inspection", "grading_method": "set", "question": "How many High Risk violations are recorded for Tiramisu Kitchen?", "evidence": "violations.risk_category uses 'High Risk'.", "SQL": "SELECT COUNT(T1.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'Tiramisu Kitchen' AND T1.risk_category = 'High Risk'"} {"question_id": 8825, "db_id": "food_inspection", "grading_method": "set", "question": "Provide eateries' IDs, risk categories and descriptions with violation ID of 103101.", "evidence": "eateries' IDs refer to business_id; violation ID of 103101 refers to violation_type_id = '103101';", "SQL": "SELECT business_id, risk_category, description FROM violations WHERE violation_type_id = '103101'"} {"question_id": 8826, "db_id": "food_inspection", "grading_method": "set", "question": "When did eateries from San Bruno city get highest score in inspection?", "evidence": "eateries represent business; highest score in inspection refers to score = 100;", "SQL": "SELECT i.`date`\nFROM `inspections` AS i\nJOIN `businesses` AS b ON b.`business_id` = i.`business_id`\nWHERE b.`city` = 'SAN BRUNO'\n AND i.`score` = (SELECT MAX(ins.`score`)\n FROM `inspections` AS ins\n JOIN `businesses` AS bus ON bus.`business_id` = ins.`business_id`\n WHERE bus.`city` = 'SAN BRUNO')\nORDER BY i.`date`;"} {"question_id": 8828, "db_id": "food_inspection", "grading_method": "set", "question": "Mention the violation type ID and description of high risk category for STARBUCKS.", "evidence": "STARBUCKS is the name of the business; high risk category refers to risk_category = 'High Risk';", "SQL": "SELECT DISTINCT T1.violation_type_id, T1.description FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.name = 'STARBUCKS' AND T1.risk_category = 'High Risk'"} {"question_id": 8829, "db_id": "food_inspection", "grading_method": "set", "question": "List the inspection dates, scores and inspection types for the eateries with tax code AA.", "evidence": "eateries with tax code AA refer to business_id where tax_code = 'AA';", "SQL": "SELECT T1.`date`, T1.score, T1.type FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.tax_code = 'AA'"} {"question_id": 8831, "db_id": "food_inspection", "grading_method": "set", "question": "Describe the violation dates, risk categories, descriptions and names of the eateries under Jade Chocolates LLC.", "evidence": "eateries under Jade Chocolates LLC refer to business_id where owner_name = 'Jade Chocolates LLC';", "SQL": "SELECT T1.`date`, T1.risk_category, T1.description, T2.name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.owner_name = 'Jade Chocolates LLC'"} {"question_id": 8833, "db_id": "food_inspection", "grading_method": "subset,=,5", "question": "For violations on June 3, 2014, list any five high-risk eateries’ names, cities, and tax codes.", "evidence": "High risk is recorded as violations.risk_category = 'High Risk'; violations.date records the violation date. Eateries’ names, cities and tax codes are businesses.name, businesses.city and businesses.tax_code.", "SQL": "SELECT DISTINCT T2.name, T2.city, T2.tax_code FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' AND T1.`date` = '2014-06-03'"} {"question_id": 8834, "db_id": "food_inspection", "grading_method": "set", "question": "What was the inspection type for El Aji Peruvian Restaurant’s inspection with the highest score?", "evidence": "El Aji Peruvian Restaurant refers to businesses.name = 'El Aji Peruvian Restaurant'; the highest inspection score refers to MAX(inspections.score) among that business's inspections; return the DISTINCT inspections.type recorded at that score", "SQL": "WITH max_score AS (\n SELECT MAX(i.score) AS top_score\n FROM inspections i\n JOIN businesses b ON b.business_id = i.business_id\n WHERE b.name = 'El Aji Peruvian Restaurant'\n)\nSELECT DISTINCT i.type\nFROM inspections i\nJOIN businesses b ON b.business_id = i.business_id\nJOIN max_score m ON i.score = m.top_score\nWHERE b.name = 'El Aji Peruvian Restaurant';"} {"question_id": 8835, "db_id": "food_inspection", "grading_method": "set", "question": "Who were the owners of eateries with a high-risk violation for improper cooking time or temperatures?", "evidence": "Owners’ names are businesses.owner_name. High risk is violations.risk_category = 'High Risk'; the violation description is 'Improper cooking time or temperatures'.", "SQL": "SELECT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' AND T1.description = 'Improper cooking time or temperatures'"} {"question_id": 8837, "db_id": "food_inspection", "grading_method": "set", "question": "List the names and business certificates of the eateries which got inspection score under 50.", "evidence": "eateries which got inspection score under 50 refer to business_id where score < 50;", "SQL": "SELECT DISTINCT b.`name`, b.`business_certificate`\nFROM `businesses` b\nJOIN `inspections` i ON b.`business_id` = i.`business_id`\nWHERE i.`score` < 50;"} {"question_id": 8838, "db_id": "food_inspection", "grading_method": "set", "question": "How many of the businesses are located at 1825 POST St #223, San Francisco?", "evidence": "1825 POST St #223 refers to address = '1825 POST St #223', San Francisco is the name of the city;", "SQL": "SELECT COUNT(business_id) FROM businesses WHERE address = '1825 POST St #223' AND city = 'SAN FRANCISCO'"} {"question_id": 8844, "db_id": "food_inspection", "grading_method": "set", "question": "Among the businesses within the postal code 94117, what is total number of businesses with a high risk category?", "evidence": "businesses with a high risk category refer to business_id where risk_category = 'High Risk';", "SQL": "SELECT COUNT(DISTINCT T2.business_id) FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.postal_code = 94117 AND T1.risk_category = 'High Risk'"} {"question_id": 8848, "db_id": "food_inspection", "grading_method": "set", "question": "Who are the owners of businesses with a high-risk violation of type 103109 described as unclean or unsanitary food contact surfaces?", "evidence": "Owners’ names are businesses.owner_name; high risk is violations.risk_category = 'High Risk'. The description is recorded in violations.description as 'Unclean or unsanitary food contact surfaces'.", "SQL": "SELECT DISTINCT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.risk_category = 'High Risk' AND T1.violation_type_id = 103109 AND T1.description = 'Unclean or unsanitary food contact surfaces'"} {"question_id": 8851, "db_id": "food_inspection", "grading_method": "set", "question": "List the owner names of businesses with violation type 103156 recorded on June 12, 2014.", "evidence": "violations.violation_type_id identifies the violation type. violations.date uses YYYY-MM-DD.", "SQL": "SELECT DISTINCT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.violation_type_id = 103156 AND T1.`date` = '2014-06-12'"} {"question_id": 8859, "db_id": "craftbeer", "grading_method": "set", "question": "What percentage of Stevens Point Brewery’s beers are American Adjunct Lagers?", "evidence": "Stevens Point Brewery refers to breweries.name = 'Stevens Point Brewery'; American Adjunct Lager refers to beers.style = 'American Adjunct Lager'; percentage = DIVIDE(COUNT(that brewery's beers with that style), COUNT(all of that brewery's beers)) * 100", "SQL": "SELECT CAST(SUM(IIF(T1.style = 'American Adjunct Lager', 1, 0)) AS REAL) * 100 / COUNT(T1.brewery_id) FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.name = 'Stevens Point Brewery'"} {"question_id": 8862, "db_id": "cookbook", "grading_method": "set", "question": "Which recipe has the highest total fat content?", "evidence": "total fat content refers to Nutrition.total_fat; the recipe with the highest total fat content refers to the greatest total_fat; return Recipe.title", "SQL": "SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.total_fat DESC LIMIT 1"} {"question_id": 8868, "db_id": "cookbook", "grading_method": "set", "question": "How many calories does the recipe \"Raspberry Chiffon Pie\" contain?", "evidence": "Raspberry Chiffon Pie refers to title", "SQL": "SELECT T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'"} {"question_id": 8872, "db_id": "cookbook", "grading_method": "set", "question": "How many recipes include the ingredient \"graham cracker crumbs\"?", "evidence": "'graham cracker crumbs' is a name of an ingredient", "SQL": "SELECT COUNT(DISTINCT T2.`recipe_id`) FROM `Ingredient` AS T1 JOIN `Quantity` AS T2 ON T1.`ingredient_id` = T2.`ingredient_id` WHERE T1.`name` = 'graham cracker crumbs'"} {"question_id": 8876, "db_id": "cookbook", "grading_method": "set", "question": "How many calories does the turkey tenderloin bundles recipe have?", "evidence": "turkey tenderloin bundles refers to title", "SQL": "SELECT T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Turkey Tenderloin Bundles'"} {"question_id": 8879, "db_id": "cookbook", "grading_method": "set", "question": "How many times do seedless red grapes appear in the recipes?", "evidence": "seedless red grapes is a name of an ingredient", "SQL": "SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.name = 'seedless red grapes'"} {"question_id": 8882, "db_id": "cookbook", "grading_method": "set", "question": "Give the name of the most widely used ingredient.", "evidence": "the most widely used ingredient refers to MAX(COUNT(ingredient_id))", "SQL": "SELECT I.`name`\nFROM `Ingredient` AS I\nJOIN `Quantity` Q ON I.`ingredient_id` = Q.`ingredient_id`\nGROUP BY I.`ingredient_id`, I.`name`\nORDER BY COUNT(DISTINCT Q.`recipe_id`) DESC\nLIMIT 1;"} {"question_id": 8888, "db_id": "cookbook", "grading_method": "set", "question": "What is the ratio of the sodium content in Lasagne-Spinach Spirals to that in Beef and Spinach Pita Pockets?", "evidence": "sodium content refers to Nutrition.sodium for a recipe; ratio = DIVIDE(SUM(CASE WHEN the recipe is 'Lasagne-Spinach Spirals' THEN sodium ELSE 0 END), SUM(CASE WHEN the recipe is 'Beef and Spinach Pita Pockets' THEN sodium ELSE 0 END)), as a plain ratio", "SQL": "SELECT CAST(SUM(CASE WHEN T1.title = 'Lasagne-Spinach Spirals' THEN T2.sodium ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.title = 'Beef and Spinach Pita Pockets' THEN T2.sodium ELSE 0 END) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id"} {"question_id": 8889, "db_id": "cookbook", "grading_method": "set", "question": "What is the average calorie count for all recipes using coarsely ground black pepper?", "evidence": "coarsely ground black pepper is a name of an ingredient; calculation = AVG(calories)", "SQL": "SELECT AVG(T3.calories) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T2.ingredient_id = T1.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id WHERE T1.name = 'coarsely ground black pepper'"} {"question_id": 8890, "db_id": "cookbook", "grading_method": "set", "question": "Which recipes have a recorded iron content greater than 20 mg? List their names.", "evidence": "Recipe.title records the recipe name. Nutrition.iron records iron content in milligrams.", "SQL": "SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20"} {"question_id": 8891, "db_id": "cookbook", "grading_method": "set", "question": "How many ingredients are there in Apricot Yogurt Parfaits?", "evidence": "Apricot Yogurt Parfaits refers to title", "SQL": "SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Apricot Yogurt Parfaits'"} {"question_id": 8893, "db_id": "cookbook", "grading_method": "set", "question": "How many ingredient entries are associated with the recipe or recipes tied for the highest vitamin A content?", "evidence": "the highest vitamin A content refers to Nutrition.vitamin_a = MAX(vitamin_a), with every tied recipe included; ingredient entries refers to COUNT(*) of Quantity rows whose recipe_id is one of those recipes", "SQL": "WITH best_recipe AS ( SELECT recipe_id FROM Nutrition WHERE vitamin_a = (SELECT MAX(vitamin_a) FROM Nutrition) ) SELECT COUNT(*) FROM Quantity WHERE recipe_id IN (SELECT recipe_id FROM best_recipe)"} {"question_id": 8898, "db_id": "cookbook", "grading_method": "set", "question": "What are the optional ingredients for Warm Chinese Chicken Salad?", "evidence": "optional refers to optional = 'TRUE'; Warm Chinese Chicken Salad refers to title", "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 = 'Warm Chinese Chicken Salad' AND T2.optional = 'TRUE'"} {"question_id": 8901, "db_id": "cookbook", "grading_method": "set", "question": "Among the recipes whose source is the National Potato Board, which recipe has the highest calories?", "evidence": "the National Potato Board is a source; the highest calories refers to MAX(calories)", "SQL": "with subquery as (SELECT T1.title, T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'National Potato Board' )\nSELECT title from subquery where calories = (select max(calories) from subquery)"} {"question_id": 8906, "db_id": "cookbook", "grading_method": "set", "question": "List the ingredients in Tomato-Cucumber Relish.", "evidence": "Tomato-Cucumber Relish refers to title", "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 = 'Tomato-Cucumber Relish'"} {"question_id": 8908, "db_id": "cookbook", "grading_method": "set", "question": "Provide the ingredients that are rationed in the recipe with the highest carbohydrate content.", "evidence": "the highest carbohydrate content refers to MAX(carbo)", "SQL": "WITH max_carb AS (\n SELECT MAX(`carbo`) AS max_carb\n FROM `Nutrition`\n), top_recipe AS (\n SELECT `recipe_id`\n FROM `Nutrition`\n WHERE `carbo` = (SELECT max_carb FROM max_carb)\n)\nSELECT `I`.`name`\nFROM `Quantity` AS Q\nJOIN `Ingredient` AS I ON I.`ingredient_id` = Q.`ingredient_id`\nWHERE Q.`recipe_id` IN (SELECT `recipe_id` FROM top_recipe)\n AND Q.`max_qty` = Q.`min_qty`;"} {"question_id": 8912, "db_id": "cookbook", "grading_method": "set", "question": "Among the recipes from The California Tree Fruit Agreement, calculate the percentage of sodium-free recipes.", "evidence": "The California Tree Fruit Agreement is a source; sodium-free follows the definition recorded for Nutrition.sodium, under 5 mg of sodium per serving, and the column already holds a per-serving figure in milligrams; calculation = MULTIPLY(DIVIDE(COUNT(sodium < 5 THEN recipe_id), COUNT(recipe_id)), 100)", "SQL": "SELECT CAST(SUM(CASE WHEN T2.sodium < 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*)\nFROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id\nWHERE T1.source = 'The California Tree Fruit Agreement'"} {"question_id": 8919, "db_id": "cookbook", "grading_method": "set", "question": "How many ingredients are required to make the Raspberry Chiffon Pie?", "evidence": "Raspberry Chiffon Pie refer to title", "SQL": "SELECT COUNT(DISTINCT T2.`ingredient_id`) \nFROM `Recipe` AS T1 \nJOIN `Quantity` AS T2 ON T1.`recipe_id` = T2.`recipe_id` \nWHERE T1.`title` = 'Raspberry Chiffon Pie';"} {"question_id": 8920, "db_id": "cookbook", "grading_method": "set", "question": "List the names of alcohol free recipes.", "evidence": "alcohol free refers to alcohol = 0", "SQL": "SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.alcohol = 0"} {"question_id": 8921, "db_id": "cookbook", "grading_method": "set", "question": "What is the average vitamin C amount of all cakes?", "evidence": "average vitamin C refers to AVG(vitamin_c); all cakes refers to title LIKE '%cake%'", "SQL": "SELECT AVG(T1.vitamin_c) FROM Nutrition AS T1 INNER JOIN Recipe AS T2 ON T2.recipe_id = T1.recipe_id WHERE T2.title LIKE '%cake%'"} {"question_id": 8922, "db_id": "cookbook", "grading_method": "set", "question": "How many dairy recipes can serve more than 10 people?", "evidence": "dairy recipes refers to category = 'dairy'; serve more than 10 people refers to servings > 10", "SQL": "SELECT COUNT(DISTINCT T1.recipe_id) \nFROM 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 \nWHERE T3.category = 'dairy' AND T1.servings > 10"} {"question_id": 8930, "db_id": "cookbook", "grading_method": "set", "question": "Among all recipes containing cheese, what is the percentage of recipes with calories greater than 200?", "evidence": "cheese is a category; calories greater than 200 refers to calories > 200; calculation = MULTIPLY(DIVIDE(COUNT(calories > 200 THEN recipe_id), COUNT(recipe_id)), 100)", "SQL": "SELECT 100.0 * COUNT(DISTINCT CASE WHEN n.calories > 200 THEN r.recipe_id END)\n / COUNT(DISTINCT r.recipe_id) AS cheese_over_200_pct\nFROM Recipe AS r\nJOIN Quantity AS q ON q.recipe_id = r.recipe_id\nJOIN Ingredient AS i ON i.ingredient_id = q.ingredient_id\nJOIN Nutrition AS n ON n.recipe_id = r.recipe_id\nWHERE i.category = 'cheese';"} {"question_id": 8934, "db_id": "human_resources", "grading_method": "set", "question": "What is the required education for the position of regional manager?", "evidence": "required education refers to educationrequired; position of regional manager refers to  positiontitle = 'Regional Manager'", "SQL": "SELECT educationrequired FROM position WHERE positiontitle = 'Regional Manager'"} {"question_id": 8962, "db_id": "human_resources", "grading_method": "set", "question": "How many employees whose performance is poor have a salary of over $50,000 per year?", "evidence": "employee.performance = 'Poor' denotes poor performance. employee.salary stores annual salary as formatted currency text with comma separators.", "SQL": "SELECT COUNT(*) FROM employee WHERE performance = 'Poor' AND CAST(REPLACE(SUBSTR(salary, 4), ',', '') AS REAL) > 50000"} {"question_id": 8966, "db_id": "human_resources", "grading_method": "set", "question": "How much is the minimum salary given to the position with the most complex work?", "evidence": "most complex work refers to MAX(educationrequired); minimum salary refers to minsalary", "SQL": "SELECT `minsalary` FROM `position` WHERE CAST(substr(`educationrequired`, 1, instr(`educationrequired`, ' ') - 1) AS INTEGER) = (SELECT MAX(CAST(substr(`educationrequired`, 1, instr(`educationrequired`, ' ') - 1) AS INTEGER)) FROM `position`)"} {"question_id": 8967, "db_id": "human_resources", "grading_method": "set", "question": "What is the full office address where the most employees work?", "evidence": "the full office address refers to location.address, location.locationcity, location.state and location.zipcode together; where the most employees work refers to the address group with the greatest COUNT of employee rows with that employee.locationID; return that group's address, locationcity, state and zipcode", "SQL": "WITH subquery as (SELECT T2.address, T2.locationcity, T2.state, T2.zipcode, COUNT(*) as num\nFROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID \nGROUP BY T2.address, T2.locationcity, T2.state, T2.zipcode)\nSELECT address, locationcity, state, zipcode\nFROM subquery WHERE num = (select max(num) from subquery)"} {"question_id": 8974, "db_id": "human_resources", "grading_method": "set", "question": "Which state had the highest number of good-performing Account Representatives?", "evidence": "good-performing Account Representatives refers to employee.performance = 'Good' with position.positiontitle = 'Account Representative'; return the single location.state with the greatest COUNT of such employees, grouped by state", "SQL": "SELECT T2.state FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Account Representative' AND T1.performance = 'Good' GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1"} {"question_id": 8975, "db_id": "human_resources", "grading_method": "set", "question": "Which employees had the lowest annual salary? Give their first names, last names, and performance statuses.", "evidence": "annual salary refers to employee.salary, which is formatted text, taken as a number; the lowest annual salary refers to the MIN of that number; return firstname, lastname and performance for the employee at that minimum", "SQL": "SELECT `firstname`, `lastname`, `performance`\nFROM `employee`\nWHERE CAST(REPLACE(SUBSTR(salary, 4), ',', '') AS REAL) = (\n SELECT MIN(CAST(REPLACE(SUBSTR(salary, 4), ',', '') AS REAL)) FROM `employee`\n);"} {"question_id": 8981, "db_id": "human_resources", "grading_method": "set", "question": "When was Emily Wood hired? Mention her position title and salary.", "evidence": "Emily Wood is the full name of an employee; full name = firstname, lastname; when was she hired refers to hiredate", "SQL": "SELECT T1.hiredate, T2.positiontitle, T1.salary FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.firstname = 'Emily' AND T1.lastname = 'Wood'"} {"question_id": 8982, "db_id": "human_resources", "grading_method": "set", "question": "What are the maximum and minimum salary range and position title of Bill Marlin?", "evidence": "Bill Marlin is the full name of an employee; full name = firstname, lastname; maximum salary refers to maxsalary; minimum salary refers to minsalary", "SQL": "SELECT T2.maxsalary, T2.minsalary, T2.positiontitle FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.firstname = 'Bill' AND T1.lastname = 'Marlin'"} {"question_id": 8990, "db_id": "bike_share_1", "grading_method": "set", "question": "For trips tied for the longest duration, list their start and end station names.", "evidence": "trip.start_station_name and trip.end_station_name record the start and end stations; trip.duration records trip length.", "SQL": "SELECT start_station_name, end_station_name FROM trip WHERE duration = ( SELECT MAX(duration) FROM trip )"} {"question_id": 8992, "db_id": "bike_share_1", "grading_method": "set", "question": "State the final station of bike id 13. Which city was it at?", "evidence": "bike id 13 refers to the trip rows whose bike id is 13; the final station refers to the destination station that trip.end_station_id identifies on the one of those trips with the greatest trip.end_date, where end_date is month/day/year hour:minute text with variable-width fields and so must be compared as a timestamp rather than as text; return that station's name and its city", "SQL": "WITH ordered AS (\n SELECT t.*, \n substr(t.end_date, instr(t.end_date,' ')-4, 4) ||\n printf('%02d', CAST(substr(t.end_date,1,instr(t.end_date,'/')-1) AS INT)) ||\n printf('%02d', CAST(substr(t.end_date, instr(t.end_date,'/')+1,\n instr(substr(t.end_date, instr(t.end_date,'/')+1),'/')) AS INT)) ||\n printf('%02d', CAST(substr(substr(t.end_date, instr(t.end_date,' ')+1), 0,\n instr(substr(t.end_date, instr(t.end_date,' ')+1),':')) AS INT)) ||\n substr(t.end_date, instr(t.end_date,':'), 3) AS dt_key\n FROM trip t\n WHERE t.bike_id = 13\n)\nSELECT s.name AS final_station,\n s.city\nFROM ordered o\nJOIN station s ON s.id = o.end_station_id\nORDER BY o.dt_key DESC\nLIMIT 1;"} {"question_id": 8995, "db_id": "bike_share_1", "grading_method": "set", "question": "Which stations were the starting point for the most bike trips? Give their names and cities, including any ties.", "evidence": "the starting point of a trip refers to its start_station, where its bike was borrowed; trips from a start_station refers to COUNT(*) of the trips with that start_station; return the names and cities of each start_station whose count of trips is equal to the MAX such count, including all ties", "SQL": "with station_subquery as (SELECT T2.start_station_name as start_station_name, T1.city as city, COUNT(T2.start_station_name) as num\n FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_id = T1.id GROUP BY T2.start_station_id \n )\nSELECT start_station_name, city FROM station_subquery where num = (select max(num) from station_subquery)"} {"question_id": 8999, "db_id": "bike_share_1", "grading_method": "set", "question": "List all trips where bikes were returned at location 37.331415, -121.8932. State the time the bike was borrowed.", "evidence": "37.331415 and -121.8932 are latitude (lat) and longitude (long) coordinates indicating location; returned at refers to end_station_name; the time the bike was borrowed refers to start_date;", "SQL": "SELECT T2.start_date FROM station AS T1 INNER JOIN trip AS T2 ON T2.end_station_id = T1.id WHERE T1.lat = 37.331415 AND T1.long = -121.8932"} {"question_id": 9001, "db_id": "bike_share_1", "grading_method": "set", "question": "Which bike trips started in San Jose and lasted less than five minutes? List their trip IDs, start and end stations, and durations in seconds.", "evidence": "Trip.duration is measured in seconds. station.city records the city where a station is located.", "SQL": "SELECT\n t.id,\n t.start_station_name,\n t.end_station_name,\n t.duration\nFROM trip AS t\nINNER JOIN station AS s ON t.start_station_id = s.id\nWHERE t.duration < 300\n AND s.city = 'San Jose';"} {"question_id": 9003, "db_id": "bike_share_1", "grading_method": "set", "question": "Among bikes used from July through September 2013, what was the average total riding time per bike, in seconds? Round your answer to two decimal places.", "evidence": "bikes used from July through September 2013 refers to trip.start_date whose month is between 7 and 9 and whose year is 2013; total riding time per bike refers to SUM(duration) in seconds grouped by bike_id; average total riding time per bike = AVG of those per-bike totals, rounded to 2 decimal places", "SQL": "SELECT ROUND(AVG(total_duration), 2) FROM (SELECT bike_id, SUM(duration) AS total_duration FROM trip WHERE CAST(SUBSTR(start_date, 1, INSTR(start_date, '/') - 1) AS INTEGER) BETWEEN 7 AND 9 AND SUBSTR(start_date, INSTR(start_date, ' ') - 4, 4) = '2013' GROUP BY bike_id);"} {"question_id": 9005, "db_id": "bike_share_1", "grading_method": "set", "question": "What was the longest trip duration among trips that started and ended on August 29, 2013?", "evidence": "Trip duration is recorded in trip.duration. August 29, 2013 appears as '8/29/2013' in trip.start_date and trip.end_date.", "SQL": "SELECT MAX(duration) FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%'"} {"question_id": 9008, "db_id": "bike_share_1", "grading_method": "set", "question": "How many stations in San Francisco can hold more than 20 bikes?", "evidence": "San Francico is the name of the city; can hold more than 20 bikes implies dock's capacity and refers to dock_count > 20;", "SQL": "SELECT SUM(CASE WHEN city = 'San Francisco' AND dock_count > 20 THEN 1 ELSE 0 END) FROM station"} {"question_id": 9011, "db_id": "bike_share_1", "grading_method": "set", "question": "Which year experienced the largest number of rainy days?", "evidence": "events LIKE 'Rain'; year refers to YEAR(date);", "SQL": "SELECT SUBSTR(`date`, -4) AS yr\nFROM weather\nWHERE `events` LIKE 'Rain'\nGROUP BY yr\nORDER BY COUNT(DISTINCT `date`) DESC\nLIMIT 1;"} {"question_id": 9014, "db_id": "bike_share_1", "grading_method": "set", "question": "What was the daily maximum humidity in the city where bike ID 496 was borrowed from Powell Street BART on August 29, 2013?", "evidence": "trip.bike_id identifies the bike; trip.start_station_name records 'Powell Street BART'. weather.max_humidity records daily maximum humidity as a percentage. trip.start_station_id identifies station.id. weather.date uses M/D/YYYY; trip.start_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 DISTINCT w.max_humidity\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE t.start_station_name = 'Powell Street BART' AND t.bike_id = 496\n AND w.date = '8/29/2013';"} {"question_id": 9015, "db_id": "bike_share_1", "grading_method": "set", "question": "For each day in November 2014 with fog recorded in ZIP code 94301, how many subscriber bike trips started across all stations that day?", "evidence": "weather.events uses 'Fog'; trip.subscription_type uses 'Subscriber'. weather.date uses M/D/YYYY and trip.start_date uses M/D/YYYY H:MM on a 24-hour clock.", "SQL": "SELECT W.`date` AS day,\n COUNT(T.`id`) AS subscriber_bikes_borrowed\nFROM weather W\nLEFT JOIN trip T\n ON substr(T.`start_date`,1, instr(T.`start_date`, ' ') - 1) = W.`date`\n AND T.`subscription_type` = 'Subscriber'\nWHERE W.`zip_code` = '94301'\n AND W.`events` = 'Fog'\n AND W.`date` LIKE '11/%/2014%'\nGROUP BY W.`date`;"} {"question_id": 9016, "db_id": "bike_share_1", "grading_method": "set", "question": "Among stations where customers started at least one trip, which had the fewest customer trips? List their names and installation dates, including ties.", "evidence": "trip.subscription_type = 'Customer' distinguishes customer trips from subscriber trips. station.installation_date uses M/D/YYYY.", "SQL": "SELECT T1.start_station_name, T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.subscription_type = 'Customer' GROUP BY T1.start_station_name HAVING COUNT(T1.subscription_type) = (SELECT MIN(Counted) FROM (SELECT COUNT(T1.subscription_type) AS Counted FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.subscription_type = 'Customer' GROUP BY T1.start_station_name) AS counts);"} {"question_id": 9017, "db_id": "bike_share_1", "grading_method": "set", "question": "On 11/3/2013, which stations have no bike avaiable to borrow? Indicate the names of the stations.", "evidence": "time LIKE '2013/11/03%'; which stations are empty refers to bikes_available = '0';", "SQL": "SELECT DISTINCT T1.name FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.bikes_available = 0 AND T2.time LIKE '2013/11/03%'"} {"question_id": 9018, "db_id": "bike_share_1", "grading_method": "set", "question": "What is the average duration of bike trips that started in the city of Palo Alto?", "evidence": "DIVIDE(SUM(duration where city = 'Palo Alto'), COUNT(start_station_id));", "SQL": "SELECT AVG(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Palo Alto'"} {"question_id": 9019, "db_id": "bike_share_1", "grading_method": "set", "question": "Which trips lasted the longest? Give each trip’s starting station and city, followed by its ending station and city.", "evidence": "the trips that lasted the longest refers to the trips whose duration = MAX(duration) over all trips; for each such trip return its start_station_name and the station.city of that starting station, followed by its end_station_name and the station.city of that ending station", "SQL": "SELECT tr.start_station_name,\n s_start.city AS start_city,\n tr.end_station_name,\n s_end.city AS end_city\nFROM trip tr\nJOIN station s_start ON s_start.id = tr.start_station_id\nJOIN station s_end ON s_end.id = tr.end_station_id\nWHERE tr.duration = (SELECT MAX(duration) FROM trip);"} {"question_id": 9023, "db_id": "bike_share_1", "grading_method": "set", "question": "Which trips returned to their starting station? List each trip ID followed by the station’s latitude and longitude.", "evidence": "trip.start_station_id and trip.end_station_id identify the stations. station.id is the catalog station identifier; station.lat and station.long record latitude and longitude.", "SQL": "SELECT t.id, s.lat, s.long FROM trip t LEFT JOIN station s ON s.id=t.start_station_id WHERE t.start_station_id=t.end_station_id"} {"question_id": 9024, "db_id": "bike_share_1", "grading_method": "set", "question": "On 8/29/2013 at 6:14:01 PM, how many bikes were borrowed from San Jose Diridon Caltrain Station?", "evidence": "Here, \"borrowed bikes\" means the station capacity not accounted for by available bikes; it is a snapshot measure, not a count of departures. station.dock_count records capacity, status.bikes_available records available bikes, and station.name identifies the station. status.time uses YYYY/MM/DD HH:MM:SS in 24-hour time.", "SQL": "SELECT station.dock_count - status.bikes_available AS borrowed FROM station JOIN status ON station.id = status.station_id WHERE station.name = 'San Jose Diridon Caltrain Station' AND status.time = '2013/08/29 18:14:01'"} {"question_id": 9030, "db_id": "bike_share_1", "grading_method": "set", "question": "In 2014, what was the shortest duration of subscriber trips from 2nd at Folsom to 5th at Howard, and how much shorter was it than the average?", "evidence": "Subscribers have trip.subscription_type = 'Subscriber'. The station names '2nd at Folsom' and '5th at Howard' are recorded in trip.start_station_name and trip.end_station_name. trip.start_date records the trip’s starting date and time; trip.duration records its duration.", "SQL": "WITH trips AS (\n SELECT *\n FROM `trip`\n WHERE `subscription_type` = 'Subscriber'\n AND `start_station_name` = '2nd at Folsom'\n AND `end_station_name` = '5th at Howard'\n AND `start_date` LIKE '%/2014 %'\n),\nstats AS (\n SELECT MIN(`duration`) AS min_dur,\n AVG(`duration`) AS avg_dur\n FROM trips\n),\nmin_trip AS (\n SELECT *\n FROM trips\n WHERE `duration` = (SELECT min_dur FROM stats)\n)\nSELECT s.min_dur AS shortest_duration,\n s.avg_dur - s.min_dur AS shorter_than_avg\nFROM min_trip t\nJOIN stats s ON 1=1"} {"question_id": 9032, "db_id": "bike_share_1", "grading_method": "set", "question": "What are the average maximum and minimum temperatures in May 2015 when the mean humidity is between 65 and 75?", "evidence": "May 2015 refers to weather.date LIKE '5/%/2015', the date being month/day/year text with unpadded month and day; mean humidity between 65 and 75 refers to mean_humidity BETWEEN 65 AND 75; return both AVG(max_temperature_f) and AVG(min_temperature_f), in Fahrenheit", "SQL": "SELECT AVG(max_temperature_f), AVG(min_temperature_f) FROM weather WHERE date LIKE '5/%/2015' AND mean_humidity BETWEEN 65 AND 75"} {"question_id": 9035, "db_id": "bike_share_1", "grading_method": "set", "question": "Find the longest trips that started on a day when the starting city’s weather was recorded as Fog. Give that day’s mean visibility, mean wind speed and weather category, followed by the starting station’s latitude and longitude, the ending station’s latitude and longitude, and the start and end station names. Include ties.", "evidence": "trip.duration measures trip length in seconds; trip.start_station_name and trip.end_station_name are the recorded station names. trip.end_station_id identifies the ending station in station.id; station.lat and station.long are latitude and longitude. weather.events = 'Fog' is the requested weather category; weather.mean_visibility_miles and weather.mean_wind_speed_mph record daily mean visibility in miles and wind speed in miles per hour. trip.start_station_id identifies station.id. weather.date uses M/D/YYYY; trip.start_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": "WITH fog_rides AS (\n SELECT t.*, w.mean_visibility_miles, w.mean_wind_speed_mph, w.events\n FROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\n WHERE w.events = 'Fog'\n)\nSELECT fr.mean_visibility_miles, fr.mean_wind_speed_mph, fr.events,\n ss.lat, ss.long, es.lat, es.long,\n fr.start_station_name, fr.end_station_name\nFROM fog_rides AS fr\nJOIN station AS ss ON ss.id = fr.start_station_id\nJOIN station AS es ON es.id = fr.end_station_id\nWHERE fr.duration = (SELECT MAX(duration) FROM fog_rides);"} {"question_id": 9038, "db_id": "bike_share_1", "grading_method": "set", "question": "What was the average bike-trip duration, in seconds, for trips starting in a city on a day with rain and more than 0.8 inches of precipitation? Round your answer to 3 decimal places.", "evidence": "rain refers to lower(weather.events) LIKE '%rain%'; more than 0.8 inches refers to CAST(precipitation_inches AS REAL) > 0.8; match each trip to the weather row for its starting station's city (San Francisco 94107, San Jose 95113, Mountain View 94041, Palo Alto 94301, Redwood City 94063) on the date part of trip.start_date; average duration refers to ROUND(AVG(trip.duration), 3) seconds", "SQL": "SELECT ROUND(AVG(t.duration), 3)\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE LOWER(w.events) LIKE '%rain%'\n AND CAST(w.precipitation_inches AS REAL) > 0.8;"} {"question_id": 9044, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips with the subscription type Subscriber ended in San Jose city?", "evidence": "ended in San Jose refers to the city of end station is San Jose;", "SQL": "SELECT COUNT(T2.id) \nFROM trip AS T1 INNER JOIN station AS T2 ON T2.id = T1.end_station_id\nWHERE T1.subscription_type = 'Subscriber' AND T2.city = 'San Jose'"} {"question_id": 9045, "db_id": "bike_share_1", "grading_method": "set", "question": "Which trip had the shortest duration and started at the station that can hold 15 bikes?", "evidence": "shortest duration refers to MIN(duration); started at the station refers to start_station_name; can hold 15 bikes refers to dock_count = 15;", "SQL": "SELECT T1.id FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.dock_count = 15 AND T1.duration = ( SELECT MIN(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.dock_count = 15 )"} {"question_id": 9046, "db_id": "bike_share_1", "grading_method": "set", "question": "Which year had the most trips that started at stations in San Francisco?", "evidence": "started at stations in San Francisco refers to trips whose starting station is a station with station.city = 'San Francisco'; the year of a trip refers to the calendar year of trip.start_date; the most trips refers to the single year with the greatest COUNT of those trips; trip.start_date uses month/day/year hour:minute text with variable-width month and day fields", "SQL": "SELECT year\nFROM (\n SELECT SUBSTR(`start_date`, INSTR(`start_date`, ' ')-4, 4) AS year,\n COUNT(*) AS trip_count\n FROM `trip`\n JOIN `station` ON `station`.`id` = `trip`.`start_station_id`\n WHERE `station`.`city` = 'San Francisco'\n GROUP BY year\n ORDER BY trip_count DESC\n LIMIT 1\n);"} {"question_id": 9047, "db_id": "bike_share_1", "grading_method": "set", "question": "What percentage of bike trips starting in San Jose lasted more than 800 seconds? Round your answer to 3 decimal places.", "evidence": "trips starting in San Jose refers to trip.start_station_id joined to station.id where station.city = 'San Jose'; lasted more than 800 seconds refers to trip.duration > 800; percentage = DIVIDE(COUNT(those trips with duration > 800), COUNT(all those trips)) * 100, rounded to 3 decimal places", "SQL": "WITH unrounded(value) AS (\nSELECT 100.0 * SUM(CASE WHEN t.duration>800 THEN 1 ELSE 0 END) / COUNT(*) FROM trip t JOIN station s ON s.id=t.start_station_id WHERE s.city='San Jose'\n) SELECT ROUND(value, 3) FROM unrounded;"} {"question_id": 9050, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips which start station and end station are the same?", "evidence": "start station refers to start_station_id; end station refers to end_station_id; start station and end station are the same refers to start_station_id = end_station_id;", "SQL": "SELECT SUM(IIF(start_station_id = end_station_id, 1, 0)) FROM trip"} {"question_id": 9056, "db_id": "bike_share_1", "grading_method": "set", "question": "What was the daily mean humidity in the starting city of trip ID 4275?", "evidence": "trip.id identifies a trip. weather.mean_humidity records daily mean humidity as a percentage. trip.start_station_id identifies station.id. weather.date uses M/D/YYYY; trip.start_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 w.mean_humidity\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE t.id = 4275;"} {"question_id": 9058, "db_id": "bike_share_1", "grading_method": "set", "question": "How many bike stations were installed after August 2013 in San Jose?", "evidence": "Station installation dates are recorded in station.installation_date; San Jose is recorded as station.city = 'San Jose'.", "SQL": "SELECT COUNT(*)\nFROM `station`\nWHERE `city` = 'San Jose'\n AND (\n CAST(substr(`installation_date`, -4) AS INTEGER) > 2013 OR\n (CAST(substr(`installation_date`, -4) AS INTEGER) = 2013 AND\n CAST(substr(`installation_date`, 1, instr(`installation_date`, '/')) AS INTEGER) > 8)\n );"} {"question_id": 9061, "db_id": "bike_share_1", "grading_method": "set", "question": "How many bikes can be borrowed in San Jose Diridon Caltrain Station at 12:06:01 on 2013/8/29?", "evidence": "number of bikes that can be borrowed refers to bikes_available; San Jose Diridon Caltrain Station refers to name = 'San Jose Diridon Caltrain Station'; time = '2013/08/29 12:06:01'", "SQL": "SELECT T2.bikes_available FROM station AS T1 INNER JOIN status AS T2 ON T1.id = T2.station_id WHERE T1.name = 'San Jose Diridon Caltrain Station' AND T2.time = '2013/08/29 12:06:01'"} {"question_id": 9062, "db_id": "bike_share_1", "grading_method": "set", "question": "In which city's station is a bike borrowed on trip ID4069?", "evidence": "bike is borrowed from refers to start_station_id;", "SQL": "SELECT T2.city FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.id = 4069"} {"question_id": 9064, "db_id": "bike_share_1", "grading_method": "set", "question": "Which stations in San Francisco had trips start on days in 2013 when the daily maximum humidity exceeded 80%?", "evidence": "trip.start_station_name records the starting station name. weather.max_humidity records daily maximum humidity as a percentage. San Francisco’s weather is represented by ZIP code 94107. trip.start_station_id identifies station.id. weather.date uses M/D/YYYY; trip.start_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 DISTINCT t.start_station_name\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE s.city = 'San Francisco' AND SUBSTR(w.date, -4) = '2013'\n AND w.max_humidity > 80;"} {"question_id": 9065, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips made by a subscriber started in August, 2013 from a station that can hold more than 20 bikes?", "evidence": "subscriber refers to subscription_type = 'Subscriber'; in August 2013 refers to start_date LIKE'8%' AND start_date LIKE'%2013%'; station that can hold more than 20 bikes refers to dock_count>20;", "SQL": "SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T1.id = T2.start_station_id WHERE T2.subscription_type = 'Subscriber' AND T2.start_date LIKE '8/%/2013%' AND T1.dock_count > 20"} {"question_id": 9066, "db_id": "bike_share_1", "grading_method": "set", "question": "What are the coordinates of the station where the longest trip started?", "evidence": "the longest trip refers to duration = MAX(duration); the coordinates refers to the lat and long of the station where that trip started; return both lat and long", "SQL": "SELECT T2.lat, T2.long FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name )"} {"question_id": 9068, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips started at \"2nd at Townsend\" in 2013 on days when its city’s weather was recorded as Fog?", "evidence": "trip.start_station_name records '2nd at Townsend'; trip.start_station_id identifies station.id. weather.events = 'Fog' is the requested weather category. weather.date uses M/D/YYYY; trip.start_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 COUNT(*)\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE SUBSTR(w.date, -4) = '2013'\n AND w.events = 'Fog'\n AND t.start_station_name = '2nd at Townsend';"} {"question_id": 9069, "db_id": "bike_share_1", "grading_method": "set", "question": "What was the longest bike-trip duration, in seconds, for trips starting in 2013 on days when their starting city’s weather was recorded as Fog?", "evidence": "the starting city's weather refers to the weather row whose zip_code maps station.city (San Francisco 94107, San Jose 95113, Mountain View 94041, Palo Alto 94301, Redwood City 94063), not trip.zip_code, and whose date is the date part of trip.start_date; Fog refers to events = 'Fog'; in 2013 refers to that date ending in 2013; longest duration in seconds refers to MAX(trip.duration)", "SQL": "SELECT MAX(t.duration)\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE SUBSTR(w.date, -4) = '2013' AND w.events = 'Fog';"} {"question_id": 9071, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips with a bike borrowed from the stations in San Francisco were made by a subscriber?", "evidence": "bike was borrowed from refers to start_station_id; San Francisco refers to city = 'San Francisco'; subscriber refers to subscription_type = 'Subscriber';", "SQL": "SELECT COUNT(T1.id) FROM trip AS T1 INNER JOIN station AS T2 ON T2.ID = T1.start_station_id WHERE T2.city = 'San Francisco' AND T1.subscription_type = 'Subscriber'"} {"question_id": 9072, "db_id": "bike_share_1", "grading_method": "set", "question": "How many trips started at 2nd at Folsom on dates when any weather location recorded the highest temperature of 2014?", "evidence": "weather.max_temperature_f records daily maximum temperature in Fahrenheit; weather.zip_code identifies the weather location. weather.date uses M/D/YYYY, and trip.start_date uses M/D/YYYY H:MM. trip.start_station_name records '2nd at Folsom'.", "SQL": "WITH hottest_dates AS (\n SELECT DISTINCT date FROM weather\n WHERE date LIKE '%/2014' AND max_temperature_f=(SELECT MAX(max_temperature_f) FROM weather WHERE date LIKE '%/2014')\n)\nSELECT COUNT(*) FROM trip\nWHERE start_station_name='2nd at Folsom'\nAND substr(start_date,1,instr(start_date,' ')-1) IN (SELECT date FROM hottest_dates);"} {"question_id": 9077, "db_id": "bike_share_1", "grading_method": "set", "question": "What is the longest bike-trip duration, in both seconds and days?", "evidence": "the longest trip duration in seconds refers to MAX(trip.duration); in days refers to DIVIDE(MAX(duration), 86400) as a real value, which may be fractional; return both the seconds value and the days value", "SQL": "SELECT MAX(duration), CAST(MAX(duration) AS REAL) / 86400 FROM trip"} {"question_id": 9079, "db_id": "bike_share_1", "grading_method": "set", "question": "For trips that both started and ended at '2nd at South Park', what is the ratio of subscriber trips to customer trips?", "evidence": "trip.subscription_type uses 'Subscriber' and 'Customer'.", "SQL": "SELECT CAST(SUM(IIF(subscription_type = 'Subscriber', 1, 0)) AS REAL) / SUM(IIF(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_station_name = '2nd at South Park' AND end_station_name = '2nd at South Park'"} {"question_id": 9081, "db_id": "bike_share_1", "grading_method": "set", "question": "Which stations had a trip start or end on a day in 2014 when their city’s daily mean temperature was 20°C? List the station names recorded on those trips.", "evidence": "a trip start or end in 2014 refers to start_date or end_date LIKE '%/2014 %'; that trip's day is the text before the space in the date and matches weather.date; station.id is the trip's start_station_id or end_station_id, and station.city maps to weather.zip_code (San Francisco 94107, San Jose 95113, Mountain View 94041, Palo Alto 94301, Redwood City 94063); a daily mean temperature of 20 Celsius refers to DIVIDE(SUBTRACT(mean_temperature_f, 32), 1.8) = 20; list the DISTINCT start_station_name or end_station_name of those trips", "SQL": "WITH trip_day AS (\n SELECT start_station_id AS station_id, start_station_name AS station_name,\n SUBSTR(start_date, 1, INSTR(start_date, ' ') - 1) AS d\n FROM trip WHERE start_date LIKE '%/2014 %'\n UNION\n SELECT end_station_id, end_station_name,\n SUBSTR(end_date, 1, INSTR(end_date, ' ') - 1)\n FROM trip WHERE end_date LIKE '%/2014 %'\n)\nSELECT DISTINCT td.station_name\nFROM trip_day AS td\nJOIN station AS s ON s.id = td.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 = td.d\nWHERE (w.mean_temperature_f - 32) / 1.8 = 20;"} {"question_id": 9087, "db_id": "bike_share_1", "grading_method": "set", "question": "Which bike has been used for the fewest trips? Give me its ID. Did every trip with this bike end at the same station where it started? Answer “Yes” or “No”. Also give its total riding time in hours across all trips.", "evidence": "fewest trips refers to the bike_id with the lowest COUNT of its trip records, taking one bike; answer 'Yes' when start_station_id = end_station_id on every trip of that bike, otherwise 'No'; total riding time = DIVIDE(SUM of that bike's trip durations, 3600.0) hours; return the bike_id, that answer and the hours", "SQL": "SELECT bike_id,\n CASE WHEN MIN(CASE WHEN start_station_id = end_station_id THEN 1 ELSE 0 END) = 1\n THEN 'Yes' ELSE 'No' END AS all_trips_returned_to_start,\n SUM(duration) * 1.0 / 3600 AS total_hours\nFROM trip\nGROUP BY bike_id\nORDER BY COUNT(*)\nLIMIT 1;\n"} {"question_id": 9089, "db_id": "bike_share_1", "grading_method": "set", "question": "List the names of the stations within Mountain View that were installed on 12/31/2013.", "evidence": "Mountain View refers to city = 'Mountain View'; installed on 12/31/2013 refers to installation_date = '12/31/2013';", "SQL": "SELECT name FROM station WHERE installation_date = '12/31/2013' AND city = 'Mountain View'"} {"question_id": 9094, "db_id": "bike_share_1", "grading_method": "set", "question": "What is the average trip duration for trips starting at Santa Clara at Almaden, and what are the latitude and longitude of that station?", "evidence": "trips starting at Santa Clara at Almaden refers to trip.start_station_name = 'Santa Clara at Almaden'; average trip duration = AVG(trip.duration) over those trips, in the stored unit; the answer pairs that average with station.lat and station.long of that starting station", "SQL": "SELECT AVG(trip.duration) AS avg_duration, station.lat, station.long\nFROM trip\nJOIN station ON station.id = trip.start_station_id\nWHERE trip.start_station_name = 'Santa Clara at Almaden';"} {"question_id": 9095, "db_id": "bike_share_1", "grading_method": "set", "question": "For the shortest trips starting at Franklin at Maple, give the duration in seconds and the daily maximum wind speed in the starting city on the departure date. Include ties.", "evidence": "trip.start_station_name records 'Franklin at Maple'; trip.duration is in seconds. weather.max_wind_Speed_mph records daily maximum wind speed in miles per hour. trip.start_station_id identifies station.id. weather.date uses M/D/YYYY; trip.start_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 DISTINCT t.duration, w.max_wind_Speed_mph\nFROM trip AS t\nJOIN station AS s ON s.id = t.start_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.start_date, 1, INSTR(t.start_date, ' ') - 1)\nWHERE t.start_station_name = 'Franklin at Maple'\n AND t.duration = (SELECT MIN(duration) FROM trip WHERE start_station_name = 'Franklin at Maple');"} {"question_id": 9096, "db_id": "bike_share_1", "grading_method": "set", "question": "How many bikes can be borrowed at San Jose Diridon Caltrain Station on the date and time of 10/20/2013 8:11:01 AM and indicate the station's coordinates.", "evidence": "number of bikes that can be borrowed refers to SUM(bikes_available); San Jose Diridon Caltrain Station refers to name = 'San Jose Diridon Caltrain Station'; station's coordinates refers to (lat, long);", "SQL": "SELECT SUM(s.`bikes_available`) AS bikes_borrowed,\n st.`lat`, st.`long`\nFROM `station` st\nJOIN `status` s ON s.`station_id` = st.`id`\nWHERE st.`name` = 'San Jose Diridon Caltrain Station'\n AND s.`time` = '2013/10/20 08:11:01';"} {"question_id": 9100, "db_id": "bike_share_1", "grading_method": "set", "question": "How many subscriber trips ended at MLK Library, and how many docks does that station have?", "evidence": "trip.subscription_type uses 'Subscriber'; station.dock_count records the number of docks.", "SQL": "SELECT COUNT(T1.id), T2.dock_count FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.end_station_name WHERE T1.end_station_name = 'MLK Library' AND T1.subscription_type = 'Subscriber'"} {"question_id": 9134, "db_id": "movie_3", "grading_method": "set", "question": "Which customers have the most film rentals? Give their first and last names, including everyone tied for the most rentals.", "evidence": "film rentals refers to transactions, so repeat rentals of the same film count separately; the most film rentals refers to the greatest COUNT of rentals among customers; return the first and last names of everyone tied at that greatest count", "SQL": "WITH rental_subquery as (SELECT T1.first_name, T1.last_name, COUNT(T2.rental_id) AS num \nFROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id, T1.first_name, T1.last_name \n)\nSELECT T.first_name, T.last_name FROM rental_subquery T WHERE num = (SELECT max(num) FROM rental_subquery)"} {"question_id": 9137, "db_id": "movie_3", "grading_method": "set", "question": "Who has more film rentals, Ruth Martinez or Linda Williams? Give their first and last name.", "evidence": "The stored customer names are 'RUTH' 'MARTINEZ' and 'LINDA' 'WILLIAMS'. Rentals include repeat rentals of the same film.", "SQL": "SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T1.customer_id) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id WHERE (T1.first_name = 'RUTH' AND T1.last_name = 'MARTINEZ') OR (T1.first_name = 'LINDA' AND T1.last_name = 'WILLIAMS') GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 1"} {"question_id": 9141, "db_id": "movie_3", "grading_method": "set", "question": "What is the average duration time of the films starring PENELOPE GUINESS?", "evidence": "average duration time = AVG(length)", "SQL": "SELECT AVG(T3.length) 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 T1.first_name = 'PENELOPE' AND T1.last_name = 'GUINESS'"} {"question_id": 9145, "db_id": "movie_3", "grading_method": "set", "question": "Give the postal code for the address No.65.", "evidence": "address no. 65 refers to address_id = 65", "SQL": "SELECT postal_code FROM address WHERE address_id = 65"} {"question_id": 9149, "db_id": "movie_3", "grading_method": "set", "question": "Tell the special features of the film Uprising Uptown.", "evidence": "\"UPRISING UPTOWN\" is the title of film", "SQL": "SELECT special_features FROM film WHERE title = 'UPRISING UPTOWN'"} {"question_id": 9164, "db_id": "movie_3", "grading_method": "set", "question": "How much money did the customer No.297 pay for the rental which happened at 12:27:27 on 2005/7/28?", "evidence": "customer no. 297 refers to customer_id = 297; at 12:27:27 on 2005/7/28 refers to rental_date = '2005-07-28 12:27:27'; money pay for rent refers to amount", "SQL": "SELECT p.amount\nFROM `payment` AS p\nJOIN `rental` AS r ON p.`rental_id` = r.`rental_id`\nWHERE r.`customer_id` = 297\n AND r.`rental_date` LIKE '2005-07-28 12:27:27%';"} {"question_id": 9166, "db_id": "movie_3", "grading_method": "set", "question": "Give the number of documentary films.", "evidence": "\"Documentary\" is the name of category; number of film refers to Count(film_id)", "SQL": "SELECT COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id WHERE T2.name = 'Documentary'"} {"question_id": 9170, "db_id": "movie_3", "grading_method": "set", "question": "What is the ratio of the number of Indian cities to the number of Italian cities in the database?", "evidence": "Indian cities refers to the cities with the Indian country.country and Italian cities to the cities with the Italian country.country; the ratio refers to DIVIDE(COUNT(Indian cities), COUNT(Italian cities)), with no * 100", "SQL": "SELECT CAST(SUM(IIF(T1.country = 'India', 1, 0)) AS REAL) / SUM(IIF(T1.country = 'Italy', 1, 0)) FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id"} {"question_id": 9174, "db_id": "movie_3", "grading_method": "set", "question": "What are the special features for the film \"Smoochy Control\"?", "evidence": "\"SMOOCHY CONTROL\" is the title of film", "SQL": "SELECT special_features FROM film WHERE title = 'SMOOCHY CONTROL'"} {"question_id": 9185, "db_id": "movie_3", "grading_method": "set", "question": "What is the name of the most rented movie?", "evidence": "most rented movie refers to title where Max(Count(rental_id))", "SQL": "with rental_subquery as (\nSELECT T1.title, COUNT(T3.rental_id) AS num FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id \nINNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T1.title\n)\nSELECT title FROM rental_subquery WHERE num = (SELECT max(num) FROM rental_subquery)"} {"question_id": 9187, "db_id": "movie_3", "grading_method": "set", "question": "What is the full name of the actor who starred in most movies?", "evidence": "full name refers to first_name, last_name; actor who starred in the most movies refers to actor_id where Max(Count(film_id))", "SQL": "with actor_sub as (\nSELECT T2.first_name, T2.last_name, count(T1.film_id) AS num \nFROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id \nGROUP BY T2.actor_id, T2.first_name, T2.last_name \n)\n\nSELECT T.first_name, T.last_name FROM actor_sub AS T WHERE T.num = (SELECT max(num) FROM actor_sub)"} {"question_id": 9216, "db_id": "movie_3", "grading_method": "set", "question": "Which films did Brian Wyman rent in July 2005? List their titles.", "evidence": "The stored customer name is 'BRIAN' 'WYMAN'. rental.rental_date uses YYYY-MM-DD HH:MM:SS with fractional seconds. Inventory records represent film copies.", "SQL": "SELECT T4.title FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'BRIAN' AND T1.last_name = 'WYMAN' AND STRFTIME('%Y', T2.rental_date) = '2005' AND STRFTIME('%m',T2.rental_date) = '07'"} {"question_id": 9235, "db_id": "movie_3", "grading_method": "set", "question": "Among films with inventory IDs from 20 to 60, how many have a G rating?", "evidence": "film.rating records the film rating, including 'G'; inventory.inventory_id identifies inventory records.", "SQL": "SELECT COUNT(DISTINCT T1.film_id) FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.inventory_id BETWEEN 20 AND 60 AND T1.rating = 'G'"} {"question_id": 9240, "db_id": "movie_3", "grading_method": "set", "question": "In films with a rental rate of 4.99, list the inventory IDs of films starring Lucille Dee.", "evidence": "Lucille Dee is recorded as actor.first_name = 'LUCILLE' and actor.last_name = 'DEE'; film.rental_rate records the rental rate.", "SQL": "SELECT T4.inventory_id 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 INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'LUCILLE' AND T1.last_name = 'DEE' AND T3.rental_rate = 4.99"} {"question_id": 9246, "db_id": "movie_3", "grading_method": "subset,=,10", "question": "List the titles of the 10 films with the highest rental price per day, from highest to lowest.", "evidence": "film.rental_rate is the dollar charge for a rental period; film.rental_duration is that period’s length in days.", "SQL": "SELECT title FROM film WHERE rental_rate / rental_duration >= (SELECT rental_rate / rental_duration FROM film ORDER BY rental_rate / rental_duration DESC LIMIT 1 OFFSET 9)"} {"question_id": 9249, "db_id": "movie_3", "grading_method": "set", "question": "Among the movies, what percentage are horror?", "evidence": "horror is a name of film category; calculation = DIVIDE(COUNT('horror'), COUNT(category_id)) * 100", "SQL": "SELECT CAST(SUM(IIF(T2.name = 'Horror', 1, 0)) AS REAL) * 100 / COUNT(T2.category_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id"} {"question_id": 9269, "db_id": "movie_3", "grading_method": "set", "question": "What is the total amount paid for rentals made on July 29, 2005?", "evidence": "July 29, 2005 refers to rental_date like '2005-07-29'", "SQL": "SELECT SUM(T2.amount) FROM rental AS T1 INNER JOIN payment AS T2 ON T1.rental_id = T2.rental_id WHERE date(T1.rental_date) = '2005-07-29'"} {"question_id": 9274, "db_id": "movie_3", "grading_method": "set", "question": "What is the full name of the actor who has acted the most times in comedy films?", "evidence": "full name refers to first_name, last_name; 'comedy' is a name of a category;", "SQL": "with actor_sub as (SELECT T4.first_name, T4.last_name, COUNT(T2.actor_id) AS num \nFROM film_category AS T1 INNER JOIN film_actor AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T1.category_id = T3.category_id \nINNER JOIN actor AS T4 ON T2.actor_id = T4.actor_id WHERE T3.name = 'Comedy' GROUP BY T4.first_name, T4.last_name, T4.actor_id)\n\nSELECT T.first_name, T.last_name FROM actor_sub T WHERE num = (SELECT max(num) FROM actor_sub)"} {"question_id": 9291, "db_id": "movie_3", "grading_method": "set", "question": "Which city does the address 1623 Kingstown Drive belong to?", "evidence": "", "SQL": "SELECT T1.city FROM city AS T1 INNER JOIN address AS T2 ON T2.city_id = T1.city_id WHERE T2.address = '1623 Kingstown Drive'"} {"question_id": 9303, "db_id": "movie_3", "grading_method": "set", "question": "Which film has the longest duration?", "evidence": "film refers to the title; the longest duration refers to MAX(length)", "SQL": "SELECT title FROM film WHERE length = ( SELECT MAX(length) FROM film )"} {"question_id": 9306, "db_id": "movie_3", "grading_method": "set", "question": "What are the ratings of the film featuring behind the scenes?", "evidence": "film featuring behind the scenes refers to special_features LIKE '%Behind the Scenes%'", "SQL": "SELECT rating FROM film WHERE special_features LIKE '%Behind the Scenes%'"} {"question_id": 9307, "db_id": "movie_3", "grading_method": "set", "question": "What is the largest number of films rented by a single customer?", "evidence": "films rented by a customer refers to the COUNT of that customer's rental records, grouped by rental.customer_id; the largest number of films rented by a single customer refers to the greatest of those per-customer counts, returning that count", "SQL": "SELECT COUNT(rental_id) FROM rental GROUP BY customer_id ORDER BY COUNT(rental_id) DESC LIMIT 1"} {"question_id": 9308, "db_id": "movie_3", "grading_method": "set", "question": "List all the films with the word \"Lacklusture\" in their description.", "evidence": "films refers to title", "SQL": "SELECT title FROM film_text WHERE description LIKE '%Lacklusture%'"} {"question_id": 9313, "db_id": "movie_3", "grading_method": "set", "question": "Provide the cast for the film \"Jason trap\".", "evidence": "'Jason trap' is a title of a film; cast means actor; actor refers to first_name, last_name", "SQL": "SELECT T1.first_name, 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.title = 'JASON TRAP'"} {"question_id": 9316, "db_id": "movie_3", "grading_method": "set", "question": "Which country does Sasebo belong to?", "evidence": "'Sasebo' is a city", "SQL": "SELECT T1.country FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id WHERE T2.city = 'Sasebo'"} {"question_id": 9320, "db_id": "movie_3", "grading_method": "set", "question": "Which actor acted in the most films?", "evidence": "actor refers to first_name, last_name; the most film refers to MAX(COUNT(film_id))", "SQL": "with actor_sub as (\nSELECT T2.first_name, T2.last_name, count(T1.film_id) AS num \nFROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id \nGROUP BY T2.actor_id, T2.first_name, T2.last_name \n)\n\nSELECT T.first_name, T.last_name FROM actor_sub AS T WHERE T.num = (SELECT max(num) FROM actor_sub)"} {"question_id": 9321, "db_id": "movie_3", "grading_method": "set", "question": "What percentage of films are horror films?", "evidence": "'horror' is a name of a category; calculation = DIVIDE(SUM(name = 'Horror'), COUNT(film_id)) * 100", "SQL": "SELECT CAST(SUM(IIF(T2.name = 'Horror', 1, 0)) AS REAL) * 100 / COUNT(T1.film_id) 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"} {"question_id": 9325, "db_id": "movie_3", "grading_method": "set", "question": "Give the full names of all actors who appear in at least one film whose rental rate equals the global maximum.", "evidence": "Actor names are recorded in actor.first_name and actor.last_name; film.rental_rate records rental rates.", "SQL": "SELECT a.first_name, a.last_name FROM actor a JOIN film_actor fa ON a.actor_id = fa.actor_id JOIN film f ON f.film_id = fa.film_id GROUP BY a.actor_id, a.first_name, a.last_name HAVING MAX(f.rental_rate) = (SELECT MAX(rental_rate) FROM film)"} {"question_id": 9329, "db_id": "movie_3", "grading_method": "set", "question": "How many customers have an address in Abu Dhabi city?", "evidence": "", "SQL": "SELECT COUNT(DISTINCT c.`customer_id`) AS num_customers \nFROM `customer` c \nJOIN `address` a ON c.`address_id` = a.`address_id` \nJOIN `city` ci ON a.`city_id` = ci.`city_id` \nWHERE ci.`city` = 'Abu Dhabi';"} {"question_id": 9338, "db_id": "movie_3", "grading_method": "set", "question": "How many film titles were released in 2006?", "evidence": "released in 2006 refers to release_year = 2006", "SQL": "SELECT COUNT(film_id) FROM film WHERE release_year = 2006"} {"question_id": 9340, "db_id": "movie_3", "grading_method": "set", "question": "List the film IDs with the highest rental duration.", "evidence": "the highest rental duration refers to film.rental_duration = MAX(rental_duration) over film; list the ID of every film holding that value", "SQL": "SELECT film_id FROM film WHERE rental_duration = ( SELECT MAX(rental_duration) FROM film )"} {"question_id": 9341, "db_id": "movie_3", "grading_method": "set", "question": "Which film titles have the most expensive rental rate?", "evidence": "the most expensive rental rate refers to max(rental_rate)", "SQL": "SELECT title FROM film WHERE rental_rate = ( SELECT MAX(rental_rate) FROM film )"} {"question_id": 9345, "db_id": "movie_3", "grading_method": "set", "question": "How many Italian films had special features consisting of deleted scenes?", "evidence": "language.name records the language, including 'Italian'; film.special_features records features such as 'deleted scenes'.", "SQL": "SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN `language` AS T2 ON T1.language_id = T2.language_id WHERE T2.`name` = 'Italian' AND T1.special_features LIKE '%deleted scenes%'"} {"question_id": 9349, "db_id": "movie_3", "grading_method": "set", "question": "State the documentary film titles with longest length.", "evidence": "documentary film refers to name = 'documentary'; longest length refers to max(length)", "SQL": "WITH doc AS (\n SELECT f.`title`, f.`length`\n FROM `film` AS f\n JOIN `film_category` AS fc USING(`film_id`)\n JOIN `category` AS c USING(`category_id`)\n WHERE c.`name` = 'Documentary'\n)\nSELECT `title`\nFROM doc\nWHERE `length` = (SELECT MAX(`length`) FROM doc);"} {"question_id": 9352, "db_id": "movie_3", "grading_method": "set", "question": "List the first names of customers whose rentals were handled by the staff member with ID 1.", "evidence": "rental.staff_id identifies the staff member who handled a rental.", "SQL": "SELECT DISTINCT T1.first_name FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id WHERE T2.staff_id = 1"} {"question_id": 9354, "db_id": "movie_3", "grading_method": "set", "question": "List down the actor IDs of film titled \"BOUND CHEAPER\".", "evidence": "", "SQL": "SELECT T2.actor_id FROM film AS T1 INNER JOIN film_actor AS T2 ON T1.film_id = T2.film_id WHERE T1.title = 'BOUND CHEAPER'"} {"question_id": 9360, "db_id": "movie_3", "grading_method": "set", "question": "What is the percentage of horror film titles in English film titles?", "evidence": "horror film refers to category.name = 'Horror'; English film refers to language.name = 'English'; percentage = divide(count(film_id where category.name = 'Horror'), count(film_id)) where language.name = 'English' * 100%", "SQL": "SELECT CAST(SUM(IIF(T3.name = 'Horror', 1, 0)) AS REAL) * 100 / COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T1.category_id = T3.category_id INNER JOIN language AS T4 ON T2.language_id = T4.language_id WHERE T4.name = 'English'"} {"question_id": 9369, "db_id": "movie_3", "grading_method": "set", "question": "Give me the title and category name of films whose price per day is more than $1. Please include their special features.", "evidence": "price per day is more than $1 refers to DIVIDE(rental_rate, rental_duration) > 1; return the film title, the name of the film's category, and the film's special features", "SQL": "SELECT f.`title`,\n c.`name`,\n f.`special_features`\nFROM `film` AS f\nJOIN `film_category` AS fc ON f.`film_id` = fc.`film_id`\nJOIN `category` AS c ON fc.`category_id` = c.`category_id`\nWHERE f.`rental_rate` / f.`rental_duration` > 1;"} {"question_id": 9371, "db_id": "movie_3", "grading_method": "set", "question": "Identify the number of unique movies rented by Maria Miller.", "evidence": "", "SQL": "SELECT COUNT(DISTINCT i.film_id) AS distinct_films\nFROM rental r\nJOIN inventory i ON r.inventory_id = i.inventory_id\nWHERE r.customer_id = (\n SELECT customer_id\n FROM customer\n WHERE UPPER(first_name) = 'MARIA'\n AND UPPER(last_name) = 'MILLER'\n);"} {"question_id": 9372, "db_id": "movie_3", "grading_method": "set", "question": "Name the most recent movies rented by Dorothy Taylor.", "evidence": "movie name refers to title; the most recent refers to max(rental_date)", "SQL": "SELECT T4.title FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'DOROTHY' AND T1.last_name = 'TAYLOR' AND T2.rental_date = (SELECT MAX(rental_date) FROM rental AS T2 INNER JOIN customer AS T1 ON T1.customer_id = T2.customer_id WHERE T1.first_name = 'DOROTHY' AND T1.last_name = 'TAYLOR');"} {"question_id": 9373, "db_id": "movie_3", "grading_method": "set", "question": "Determine the number of action movies available for rent.", "evidence": "action movie refers to category.name = 'Action'", "SQL": "SELECT COUNT(DISTINCT fc.`film_id`) AS action_movies_available\nFROM `film_category` fc\nJOIN `category` c ON c.`category_id` = fc.`category_id`\nJOIN `inventory` i ON i.`film_id` = fc.`film_id`\nWHERE c.`name` = 'Action';"} {"question_id": 9375, "db_id": "movie_3", "grading_method": "set", "question": "How many days did Andre Rapp take to return the movie 'Destiny Saturday'?", "evidence": "'Destiny Saturday' refers to title = 'DESTINY SATURDAY'; length = subtract(julianday(return_date), julianday(rental_date))", "SQL": "SELECT julianday(r.return_date) - julianday(r.rental_date) AS days_to_return\nFROM customer c\nJOIN rental r ON c.customer_id = r.customer_id\nJOIN inventory i ON r.inventory_id = i.inventory_id\nJOIN film f ON i.film_id = f.film_id\nWHERE c.first_name = 'ANDRE'\n AND c.last_name = 'RAPP'\n AND f.title = 'DESTINY SATURDAY';"} {"question_id": 9379, "db_id": "movie_3", "grading_method": "set", "question": "What is the average replacement cost for the movies with a rental rate of 4.99?", "evidence": "a rental rate of 4.99 refers to rental_rate = 4.99; average replacement cost = avg(replacement_cost)", "SQL": "SELECT AVG(replacement_cost) FROM film WHERE rental_rate = 4.99"} {"question_id": 9384, "db_id": "movie_3", "grading_method": "list", "question": "Provide the list of the longest movies. Arrange these titles in alphabetical order.", "evidence": "the longest refers to max(length)", "SQL": "SELECT title FROM film WHERE length = ( SELECT MAX(length) FROM film ) order by title"} {"question_id": 9387, "db_id": "movie_3", "grading_method": "set", "question": "How many customers are still active?", "evidence": "active refers to active = 1", "SQL": "SELECT COUNT(customer_id) FROM customer WHERE active = 1"} {"question_id": 9388, "db_id": "movie_3", "grading_method": "set", "question": "List all the films that are rated as PG-13.", "evidence": "film refers to title; rated as PG-13 refers to rating = 'PG-13'", "SQL": "SELECT title FROM film WHERE rating = 'PG-13'"} {"question_id": 9391, "db_id": "movie_3", "grading_method": "set", "question": "List all customers who paid greater than $10 in a single payment. Provide the full name of the customers.", "evidence": "full name refers to first_name, last_name; greater than $10 refers to amount > 10", "SQL": "SELECT DISTINCT c.`first_name`,\n c.`last_name`\nFROM `customer` AS c\nJOIN `payment` AS p ON p.`customer_id` = c.`customer_id`\nWHERE p.`amount` > 10"} {"question_id": 9393, "db_id": "movie_3", "grading_method": "set", "question": "Give the first and last names of all actors in the film “Ending Crowds”.", "evidence": "The film title is recorded as film.title = 'ENDING CROWDS'; actor.first_name and actor.last_name record actor names.", "SQL": "SELECT T2.first_name, T2.last_name FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T3.title = 'ENDING CROWDS'"} {"question_id": 9396, "db_id": "movie_3", "grading_method": "set", "question": "List all cities in the Philippines.", "evidence": "city.city records city names; country.country identifies the Philippines, and city.country_id joins to country.country_id.", "SQL": "SELECT T1.city FROM city AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE country = 'Philippines'"} {"question_id": 9397, "db_id": "movie_3", "grading_method": "set", "question": "Which films have the fewest rentals, including films that have never been rented? List their titles.", "evidence": "the rentals of a film refers to the number of rental records of its inventory copies, counting 0 for a film never rented; the fewest rentals refers to the minimum of those per-film counts; list the titles of every film whose count is that minimum", "SQL": "WITH film_counts AS (\n SELECT f.film_id,\n f.title,\n COUNT(r.rental_id) AS num\n FROM film f\n LEFT JOIN inventory i ON f.film_id = i.film_id\n LEFT JOIN rental r ON r.inventory_id = i.inventory_id\n GROUP BY f.film_id\n),\nmin_cnt AS (\n SELECT MIN(num) AS mn FROM film_counts\n)\nSELECT fc.title\nFROM film_counts fc\nJOIN min_cnt m ON fc.num = m.mn\nORDER BY fc.title;"} {"question_id": 9399, "db_id": "movie_3", "grading_method": "set", "question": "Which category does the film “Beach Heartbreakers” fall into?", "evidence": "category.name records the film category; the film title is recorded as film.title = 'BEACH HEARTBREAKERS'.", "SQL": "SELECT T3.name 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 T1.title = 'BEACH HEARTBREAKERS'"} {"question_id": 9405, "db_id": "movie_3", "grading_method": "set", "question": "Among the active customers, how many of them have Nina as their first name?", "evidence": "customer.active = 1 denotes active customers; customer.first_name stores Nina as 'NINA'.", "SQL": "SELECT COUNT(customer_id) FROM customer WHERE first_name = 'NINA' AND active = 1"} {"question_id": 9408, "db_id": "movie_3", "grading_method": "set", "question": "Give the duration of the film starring Nick Wahlberg that has the highest rental rate.", "evidence": "Nick Wahlberg refers to actor.first_name = 'NICK' AND actor.last_name = 'WAHLBERG'; the highest rental rate refers to MAX(film.rental_rate) over the film rows starring Nick Wahlberg; duration refers to the film.length of the film at that maximum", "SQL": "WITH film_length as (\nSELECT f.`length`, f.`rental_rate`\nFROM `actor` AS a\nJOIN `film_actor` AS fa ON a.`actor_id` = fa.`actor_id`\nJOIN `film` AS f ON fa.`film_id` = f.`film_id`\nWHERE a.`first_name` = 'NICK'\n AND a.`last_name` = 'WAHLBERG'\n)\nSELECT `length`\nFROM film_length\nWHERE rental_rate = (SELECT max(`rental_rate`) FROM film_length)"} {"question_id": 9411, "db_id": "movie_3", "grading_method": "set", "question": "In films with a rental rate of 2.99, how many of the films are starred by Uma Wood?", "evidence": "a rental rate of 2.99 refers to rental_rate = 2.99", "SQL": "SELECT COUNT(T1.film_id)\n FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id \nWHERE T3.rental_rate = 2.99 AND T2.first_name = 'UMA' AND T2.last_name = 'WOOD'"} {"question_id": 9424, "db_id": "movie_3", "grading_method": "set", "question": "Please give the full name of the customer who paid the largest amount for a single film rental.", "evidence": "the largest amount paid for a single film rental refers to MAX(payment.amount) over all payments; return the distinct customer.first_name and customer.last_name of every customer with a payment equal to that maximum", "SQL": "SELECT DISTINCT c.first_name,\n c.last_name\nFROM payment p\nJOIN customer c ON p.customer_id = c.customer_id\nWHERE p.amount = (SELECT MAX(amount) FROM payment);"}