text
stringlengths
411
1.74k
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "top_10_in_total_attendance" ( "league" text, "sport" text, "country" text, "season" text, "games" real, "average_attendance" real, "total_attendance" real );. Question: "What's the total and average attendance of each sport in each league for the seasons from 2010 to 2020, ordered by the total attendance in descending order, and limiting to the top 5 records?". [/INST] SELECT "sport", "league", SUM("total_attendance"), AVG("average_attendance") FROM "top_10_in_total_attendance" WHERE "season" BETWEEN '2010' AND '2020' GROUP BY "sport", "league" ORDER BY SUM("total_attendance") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10874596_1" ( "year_e_ceremony" text, "film_title_used_in_nomination" text, "original_title" text, "director" text, "result" text );. Question: "How many films per director were submitted with the title 'Young Törless' and which year had the most number of such films, ordered by the number of films in descending order?". [/INST] SELECT COUNT("film_title_used_in_nomination"), "year_e_ceremony" FROM "table1_10874596_1" WHERE "film_title_used_in_nomination"='Young Törless' GROUP BY "director", "year_e_ceremony" ORDER BY COUNT("film_title_used_in_nomination") DESC LIMIT 1;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10874596_1" ( "year_e_ceremony" text, "film_title_used_in_nomination" text, "original_title" text, "director" text, "result" text );. Question: "Which year had the most nominations for the director whose film was originally titled 'A Woman in Flames'?". [/INST] SELECT "year_e_ceremony", COUNT("director") AS "num_of_nominations" FROM "table1_10874596_1" WHERE "director" IN (SELECT "director" FROM "table1_10874596_1" WHERE "film_title_used_in_nomination"='A Woman in Flames') GROUP BY "year_e_ceremony" ORDER BY "num_of_nominations" DESC LIMIT 1;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10874596_1" ( "year_e_ceremony" text, "film_title_used_in_nomination" text, "original_title" text, "director" text, "result" text );. Question: "Count the number of submissions and group them by year, for the film with the title 'The Enigma of Kaspar Hauser' and order them in descending order.". [/INST] SELECT COUNT(*), "year_e_ceremony" FROM "table1_10874596_1" WHERE "film_title_used_in_nomination"='The Enigma of Kaspar Hauser' GROUP BY "year_e_ceremony" ORDER BY "year_e_ceremony" DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10874596_1" ( "year_e_ceremony" text, "film_title_used_in_nomination" text, "original_title" text, "director" text, "result" text );. Question: "What are the films with the most occurrences, their respective directors and the number of times they have appeared in the nominations, where the original title was 'o.k.' sorted in descending order?". [/INST] SELECT "film_title_used_in_nomination", "director", COUNT("film_title_used_in_nomination") AS Times_Nominated FROM "table1_10874596_1" WHERE "original_title"='o.k.' GROUP BY "film_title_used_in_nomination", "director" ORDER BY Times_Nominated DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "kansas_city_comets" ( "year" text, "division" text, "league" text, "reg_season" text, "playoffs" text, "avg_attendance" real );. Question: "What is the highest average attendance for each division during the division semifinals playoffs, and list the result in descending order limiting the result by 5 records?". [/INST] SELECT "division", MAX("avg_attendance") FROM "kansas_city_comets" WHERE "playoffs"='Division Semifinals' GROUP BY "division" ORDER BY MAX("avg_attendance") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10908676_7" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "What is the minimum, maximum, and average number in series for the episodes directed by the same person who directed "Say Uncle"?". [/INST] SELECT MIN("no_in_series"), MAX("no_in_series"), AVG("no_in_series") FROM "table1_10908676_7" WHERE "directed_by" IN (SELECT "directed_by" FROM "table1_10908676_7" WHERE "title"='\"Say Uncle\"');</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10908676_7" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "What are the top 3 titles written by David Mamet based on their number in the series?". [/INST] SELECT "title", "no_in_series" FROM "table1_10908676_7" WHERE "written_by"='David Mamet' ORDER BY "no_in_series" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "highest_rating_drama_series_of_2006" ( "rank" real, "english_title" text, "chinese_title" text, "average" real, "peak" real, "premiere" real, "finale" real, "hk_viewers" text );. Question: "Count distinct premiere dates and show the highest and lowest finales for each Chinese title with more than one unique premiere date, and order them by the highest finale in descending order but limit the result to top 10.". [/INST] SELECT "chinese_title", COUNT(DISTINCT "premiere"), MAX("finale"), MIN("finale") FROM "highest_rating_drama_series_of_2006" GROUP BY "chinese_title" HAVING COUNT(DISTINCT "premiere") > 1 ORDER BY MAX("finale") DESC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "highest_rating_drama_series_of_2006" ( "rank" real, "english_title" text, "chinese_title" text, "average" real, "peak" real, "premiere" real, "finale" real, "hk_viewers" text );. Question: "What is the average finale ranking for the top 3 dramas with the highest peak viewership in 2006?". [/INST] SELECT AVG("finale") FROM "highest_rating_drama_series_of_2006" ORDER BY "peak" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "highest_rating_drama_series_of_2006" ( "rank" real, "english_title" text, "chinese_title" text, "average" real, "peak" real, "premiere" real, "finale" real, "hk_viewers" text );. Question: "What's the average viewership, maximum and minimum viewership of the TV series ranked by premiere rating of 34 and list the results descending by average viewership, limit the result to top 5.". [/INST] SELECT AVG("hk_viewers"), MAX("hk_viewers"), MIN("hk_viewers") FROM "highest_rating_drama_series_of_2006" WHERE "premiere"=34 GROUP BY "english_title" ORDER BY AVG("hk_viewers") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "highest_rating_drama_series_of_2006" ( "rank" real, "english_title" text, "chinese_title" text, "average" real, "peak" real, "premiere" real, "finale" real, "hk_viewers" text );. Question: "What is the average and maximum peak rating of the series titled "潮爆大狀", and how many episodes achieved this maximum peak? Order the results by the premiere date in descending order but limit results to the top 5.". [/INST] SELECT AVG("peak"), MAX("peak"), COUNT("peak") FROM "highest_rating_drama_series_of_2006" WHERE "chinese_title"='潮爆大狀' GROUP BY "premiere" ORDER BY "premiere" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_2_1993_1994" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the average number of episodes that each director has directed, ordered by the director's name in alphabetical order and limited to the top 10 directors, in season 2?". [/INST] SELECT "director", AVG("no_in_series") as average_count FROM "season_2_1993_1994" WHERE "production_code"='2393059' GROUP BY "director" ORDER BY "director" ASC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_2_1993_1994" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "List the distinct number of writers for each episode, ordered by the number of writers in descending order, and show only the top 5.". [/INST] SELECT "title", COUNT(DISTINCT "writer_s") AS NumberOfWriters FROM "season_2_1993_1994" GROUP BY "title" ORDER BY NumberOfWriters DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_2_1993_1994" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "How many episodes are there in each season, ordered by the number of episodes? Show only top 5 seasons.". [/INST] SELECT "no_in_season", COUNT("title") AS episodes_count FROM "season_2_1993_1994" GROUP BY "no_in_season" ORDER BY episodes_count DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10935548_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "production_code" text, "u_s_viewers_millions" text );. Question: "Count and list the different directors for episodes which had more than 10 million U.S. viewers, ordered by most episodes directed.". [/INST] SELECT COUNT("title"), "directed_by" FROM "table1_10935548_1" WHERE "u_s_viewers_millions" > '10' GROUP BY "directed_by" ORDER BY COUNT("title") DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10935548_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "production_code" text, "u_s_viewers_millions" text );. Question: "Can you provide the count of episodes, average no_in_series, and the maximum and minimum number of U.S viewers in millions for each written_by José Molina that aired in distinct years, and order them by the count of episodes in descending order, limit to the top 5?". [/INST] SELECT COUNT("title"), AVG("no_in_series"), MAX("u_s_viewers_millions"), MIN("u_s_viewers_millions") FROM "table1_10935548_1" WHERE "written_by"='José Molina' GROUP BY strftime('%Y', "original_air_date") ORDER BY COUNT("title") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10935548_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "production_code" text, "u_s_viewers_millions" text );. Question: "What is the average number of viewers for episodes directed by each director and ordered by the number of viewers in descending order, limit the result to top 5 directors. Also, find out the earliest and latest air date for their episodes?". [/INST] SELECT "directed_by", AVG("u_s_viewers_millions"), MIN("original_air_date"), MAX("original_air_date") FROM "table1_10935548_1" GROUP BY "directed_by" ORDER BY AVG("u_s_viewers_millions") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10935548_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "production_code" text, "u_s_viewers_millions" text );. Question: "What is the average number of episodes directed by each director, for directors that have directed more than 3 episodes, ordered by the number of episodes they have directed?". [/INST] SELECT "directed_by", AVG("no_in_series") as average_episodes FROM "table1_10935548_1" WHERE "directed_by" IN (SELECT "directed_by" FROM "table1_10935548_1" GROUP BY "directed_by" HAVING COUNT(*) > 3) GROUP BY "directed_by" ORDER BY COUNT(*) DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10953197_3" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "Count the number of different directors for each unique original air date with a production code of '2394087', order the results by the date and limit the results to the top 5". [/INST] SELECT "original_air_date", COUNT(DISTINCT "director") FROM "table1_10953197_3" WHERE "production_code"='2394087' GROUP BY "original_air_date" ORDER BY "original_air_date" LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10953197_3" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the average number of seasons by each writer who worked on the title "Boxing Sydney", limiting the result to the top 5 writers referenced most frequently?". [/INST] SELECT "writer_s", AVG("no_in_season") as Avg_Seasons FROM "table1_10953197_3" WHERE "title"='\"Boxing Sydney\"' GROUP BY "writer_s" ORDER BY COUNT(*) DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10953197_3" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "Count the number of episodes per season for the title "all about brooke", sorted by the season number, and give me the top 3 seasons with the most episodes.". [/INST] SELECT "no_in_season", COUNT("no_in_series") FROM "table1_10953197_3" WHERE "title"='\"All About Brooke\"' GROUP BY "no_in_season" ORDER BY COUNT("no_in_series") DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10953197_3" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "For each director, what is the count and average number of episodes in a season they have written for production code 2394084, with results grouped by the director and ordered by count in descending order, and limiting the result to the top 5.". [/INST] SELECT "director", COUNT("no_in_season"), AVG("no_in_season") FROM "table1_10953197_3" WHERE "production_code"='2394084' GROUP BY "director" ORDER BY COUNT("no_in_season") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What's the total number of episodes directed by each director and written by each writer, for the production code 2395113A, ordered by the number of episodes in descending order and limit the result to the top 5?". [/INST] SELECT "director", "writer_s", COUNT("title") AS "Number_of_Episodes" FROM "season_4_1995_1996" WHERE "production_code"='2395113A' GROUP BY "director", "writer_s" ORDER BY "Number_of_Episodes" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the highest and the lowest episode number directed by the director of the episode "Melrose Unglued"?". [/INST] SELECT MAX("no_in_series"), MIN("no_in_series") FROM "season_4_1995_1996" WHERE "director"=(SELECT "director" FROM "season_4_1995_1996" WHERE "title"='\"Melrose Unglued\"');</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the maximum and minimum number of episodes any writer has written along with their names, for top 5 writers with the most episodes, with production code less than '2395114' in 'season_4_1995_1996'?". [/INST] SELECT "writer_s", MAX("no_in_season"), MIN("no_in_season") FROM "season_4_1995_1996" WHERE "production_code"<'2395114' GROUP BY "writer_s" ORDER BY COUNT("no_in_series") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "List the number of episodes directed by each director, sorted by the number of episodes they directed, for episodes titled "Full Metal Betsy" or similar titles.". [/INST] SELECT "director", count(*) as "num_episodes" FROM "season_4_1995_1996" WHERE "title" LIKE '%Full Metal Betsy%' GROUP BY "director" ORDER BY "num_episodes" DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What are the top 5 episodes in terms of number in season with production code 2395118, ordered in descending order by their number in the series?". [/INST] SELECT "no_in_season", "no_in_series" FROM "season_4_1995_1996" WHERE "production_code"='2395118' ORDER BY "no_in_series" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_4_1995_1996" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "How many episodes with different titles each writer wrote, for episodes with production code that is at least 2395096, ordered by descending number of episodes and limiting the list to the top 5?". [/INST] SELECT "writer_s", COUNT("title") FROM "season_4_1995_1996" WHERE "production_code">='2395096' GROUP BY "writer_s" ORDER BY COUNT("title") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "planets" ( "planet" text, "planet_type" text, "semimajor_axis_au" text, "orbital_period" text, "radial_velocity_m_s" text, "detectable_by" text );. Question: "What is the maximum, minimum and average orbital period of the planets detected by a spectrograph generation that is most likely to detect a planet with a radial velocity of 0.089 m/s and group them by planet types, list the results in ascending order of the average orbital period?". [/INST] SELECT "planet_type", MAX("orbital_period"), MIN("orbital_period"), AVG("orbital_period") FROM "planets" WHERE "radial_velocity_m_s"='0.089' GROUP BY "planet_type" ORDER BY AVG("orbital_period") ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "planets" ( "planet" text, "planet_type" text, "semimajor_axis_au" text, "orbital_period" text, "radial_velocity_m_s" text, "detectable_by" text );. Question: "What is the total orbital period and on average how long is the orbital period for planets with a semimajor axis greater than 5.20 au, sorted by radial velocity in ascending order, limiting to top 10 records?". [/INST] SELECT SUM("orbital_period"), AVG("orbital_period") FROM "planets" WHERE "semimajor_axis_au">'5.20' ORDER BY "radial_velocity_m_s" ASC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "planets" ( "planet" text, "planet_type" text, "semimajor_axis_au" text, "orbital_period" text, "radial_velocity_m_s" text, "detectable_by" text );. Question: "Count the number of different planet types per detection method used by a particular generation of spectrograph, and provide the name of the planet type with the minimum and maximum count, in descending order by count, for the first 20 results.". [/INST] WITH detection_counts AS ( SELECT "detectable_by", "planet_type", COUNT(*) AS "count" FROM "planets" WHERE "detectable_by" IN (SELECT "detectable_by" FROM "planets" WHERE "planet"='Jupiter') GROUP BY "detectable_by", "planet_type" ) SELECT "detectable_by", MIN("planet_type") AS "min_type", MAX("planet_type") AS "max_type", "count" FROM detection_counts ORDER BY "count" DESC LIMIT 20;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "planets" ( "planet" text, "planet_type" text, "semimajor_axis_au" text, "orbital_period" text, "radial_velocity_m_s" text, "detectable_by" text );. Question: "What is the sum of radial velocity for each type of planets which have an orbital period of 11.86 years?". [/INST] SELECT SUM("radial_velocity_m_s"), "planet_type" FROM "planets" WHERE "orbital_period"='11.86 years' GROUP BY "planet_type";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_7_1998_1999" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "List the top three most occurring directors in the production with the production code 2398204? Also, sort the results by the number of occurrences in descending order.". [/INST] SELECT "director", COUNT(*) AS "frequency" FROM "season_7_1998_1999" WHERE "production_code"='2398204' GROUP BY "director" ORDER BY "frequency" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_7_1998_1999" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "Count the episodes directed by each director and list 5 directors with maximum number of episodes, include the case when "Unpleasantville" was aired.". [/INST] SELECT "director", COUNT("title") AS episodes_count FROM "season_7_1998_1999" WHERE "title"='\"Unpleasantville\"' OR "director" IN (SELECT "director" FROM "season_7_1998_1999" GROUP BY "director" ORDER BY COUNT("title") DESC LIMIT 5) GROUP BY "director" ORDER BY episodes_count DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10960039_1" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the average pick number sorted in ascending order for each position of players who played in the same team as Alexis Bwenge, display only the top 5.". [/INST] SELECT AVG("pick_num"), "position" FROM "table1_10960039_1" WHERE "cfl_team"=(SELECT "cfl_team" FROM "table1_10960039_1" WHERE "player"='Alexis Bwenge') GROUP BY "position" ORDER BY AVG("pick_num") ASC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10960039_1" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many players from each college were picked, sorted in descending order, and limit the result to top 5?". [/INST] SELECT "college", COUNT("player") as "number_of_players" FROM "table1_10960039_1" GROUP BY "college" ORDER BY COUNT("player") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10960039_1" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many players of each position were picked by different CFL teams from Saskatchewan College?". [/INST] SELECT "cfl_team", "position", COUNT("player") FROM "table1_10960039_1" WHERE "college"='Saskatchewan' GROUP BY "cfl_team", "position" ORDER BY COUNT("player") DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10960039_1" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the highest and lowest pick number for each position from McMaster College, and how many players have these positions?". [/INST] SELECT "position", MAX("pick_num"), MIN("pick_num"), COUNT("player") FROM "table1_10960039_1" WHERE "college"='McMaster' GROUP BY "position" ORDER BY COUNT("player") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_6_1997_1998" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the least number of times an episode directed by the same person was shown throughout 1997-1998, and order the result by the director's name?". [/INST] SELECT "director", MIN("no_in_season") FROM "season_6_1997_1998" GROUP BY "director" ORDER BY "director" ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_6_1997_1998" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "Get the count of the episodes with different production codes that were directed by the same director as the one who directed "The Doctor Is In... Deep", and order it by the count in descending order. Limit the result to the top 5.". [/INST] SELECT "director", COUNT("production_code") AS "no_of_episodes" FROM "season_6_1997_1998" WHERE "director" IN (SELECT "director" FROM "season_6_1997_1998" WHERE "title"='\"The Doctor Is In... Deep\"') GROUP BY "director" ORDER BY "no_of_episodes" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_6_1997_1998" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "How many times does each episode title appear in the season, and find the three most repeated titles?". [/INST] SELECT "title", COUNT("no_in_series") AS "appearances" FROM "season_6_1997_1998" GROUP BY "title" ORDER BY "appearances" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "season_6_1997_1998" ( "no_in_series" real, "no_in_season" real, "title" text, "director" text, "writer_s" text, "original_air_date" text, "production_code" text );. Question: "What is the total count of the episodes refereed by each director in Season 6 and how many times maximum number was recorded for each director, considering only those instances when the production_code 12397162 was used, order the results by the total count in descending order.". [/INST] SELECT "director", COUNT("no_in_series"), MAX("no_in_season") FROM "season_6_1997_1998" WHERE "production_code"='12397162' GROUP BY "director" ORDER BY COUNT("no_in_series") DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10966926_2" ( "round" real, "choice" real, "player_name" text, "position" text, "height" text, "weight" real, "college" text );. Question: "What is the average weight of players who went to Michigan State, grouped by position, ordered by weight, limited to top 5?". [/INST] SELECT "position", AVG("weight") AS Average_Weight FROM "table1_10966926_2" WHERE "college"='Michigan State' GROUP BY "position" ORDER BY AVG("weight") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10966926_2" ( "round" real, "choice" real, "player_name" text, "position" text, "height" text, "weight" real, "college" text );. Question: "How many players who went to college in Oklahoma were selected in each round, and what is the average weight for players in each round? Order the results by round and limit the output to the top 5 rounds with the highest average weight.". [/INST] SELECT "round", COUNT("player_name") AS "number_of_players", AVG("weight") AS "average_weight" FROM "table1_10966926_2" WHERE "college"='Oklahoma' GROUP BY "round" ORDER BY "average_weight" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10966926_2" ( "round" real, "choice" real, "player_name" text, "position" text, "height" text, "weight" real, "college" text );. Question: "How many players from each college have been in the same position as Colt Brennan and what is their average weight?". [/INST] SELECT "college", COUNT(*), AVG("weight") FROM "table1_10966926_2" WHERE "position"=(SELECT "position" FROM "table1_10966926_2" WHERE "player_name"='Colt Brennan') GROUP BY "college";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_10966926_2" ( "round" real, "choice" real, "player_name" text, "position" text, "height" text, "weight" real, "college" text );. Question: "What is the average weight of the players from each college who stand at different heights, having a minimum weight of 320 pounds with results sorted in ascending order of average weight, and show only the top 5 results?". [/INST] SELECT "college", "height", AVG("weight") as Avg_weight FROM "table1_10966926_2" WHERE "weight" >= 320 GROUP BY "college", "height" ORDER BY Avg_weight ASC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_four" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "For each position, what is the maximum number of players that are picked from the same college, and from which college they are from, limited to top 3?". [/INST] SELECT "position", MAX("player_count"), "college" FROM (SELECT "position", COUNT("player") as "player_count", "college" FROM "round_four" GROUP BY "position", "college") SUBQUERY GROUP BY "position" ORDER BY MAX("player_count") DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_four" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the maximum and minimum number of pick among each positions for the CFL team Calgary Stampeders and order them by maximum pick number?". [/INST] SELECT "position", MAX("pick_num"), MIN("pick_num") FROM "round_four" WHERE "cfl_team"='Calgary Stampeders' GROUP BY "position" ORDER BY MAX("pick_num") ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_four" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the maximum number of players per position from York college, listed by the CFL team in ascending order of team name?". [/INST] SELECT "cfl_team", "position", MAX(COUNT("player")) FROM "round_four" WHERE "college"='York' GROUP BY "cfl_team", "position" ORDER BY "cfl_team" ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_four" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many players from Simon Fraser college were picked by each CFL team, ordered by descending number of picks and showing only the top 3?". [/INST] SELECT "cfl_team", COUNT("player") as "num_of_players" FROM "round_four" WHERE "college"='Simon Fraser' GROUP BY "cfl_team" ORDER BY "num_of_players" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_four" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the total number of players picked by each CFL team with a pick number of 27 and their corresponding positions?". [/INST] SELECT "cfl_team", "position", COUNT("player") FROM "round_four" WHERE "pick_num"=27 GROUP BY "cfl_team", "position" ORDER BY COUNT("player") DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "In which positions players named Brett Ralph were selected and how many times were they selected in each position?". [/INST] SELECT "position", COUNT("pick_num") FROM "round_six" WHERE "player"='Brett Ralph' GROUP BY "position";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many players from each college have been picked by the same CFL team as Lenard Semajuste, sorted by the number of players in descending order, limited to top 5 colleges?". [/INST] SELECT "college", COUNT("player") AS "Number_of_Players" FROM "round_six" WHERE "cfl_team" IN (SELECT "cfl_team" FROM "round_six" WHERE "player"='Lenard Semajuste') GROUP BY "college" ORDER BY "Number_of_Players" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "Which position has the highest number of players selected by the Saskatchewan Roughriders team and what is the lowest, highest and average selection number for that position?". [/INST] SELECT "position", COUNT(*), MIN("pick_num"), MAX("pick_num"), AVG("pick_num") FROM "round_six" WHERE "cfl_team" = 'Saskatchewan Roughriders' GROUP BY "position" ORDER BY COUNT(*) DESC, AVG("pick_num") ASC LIMIT 1;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many FB players were drafted by each CFL team, and provide the top 5 teams with the most FB players, ordered by the number of players in descending order". [/INST] SELECT "cfl_team", COUNT("pick_num") as "num_of_fb_players" FROM "round_six" WHERE "position"='FB' GROUP BY "cfl_team" ORDER BY "num_of_fb_players" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What's the maximum and minimum player pick number and their count per position from Adams State school?". [/INST] SELECT "position", MAX("pick_num"), MIN("pick_num"), COUNT("player") FROM "round_six" WHERE "college"='Adams State' GROUP BY "position";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_six" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many players from each position did the teams draft, for players that played for Northwood school, ordered by the number of players in descending order, and limited to the top 5 teams?". [/INST] SELECT "cfl_team", "position", COUNT("player") as num_players FROM "round_six" WHERE "college"='Northwood' GROUP BY "cfl_team", "position" ORDER BY num_players DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the most commonly attended college among the players picked by each CFL team, and how many players from that college did they pick?". [/INST] SELECT "cfl_team", "college", COUNT("player") as player_count FROM "round_five" GROUP BY "cfl_team", "college" ORDER BY player_count DESC LIMIT 1;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the highest, lowest and average pick number for players from Regina, grouped by their positions". [/INST] SELECT "position", MAX("pick_num"), MIN("pick_num"), AVG("pick_num") FROM "round_five" WHERE "college"='Regina' GROUP BY "position";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What are the top 3 colleges that the Saskatchewan Roughriders have selected players from, for the 'LB' position, and how many players have been picked from each college?". [/INST] SELECT "college", COUNT("player") FROM "round_five" WHERE "position"='LB' AND "cfl_team"='Saskatchewan Roughriders' GROUP BY "college" ORDER BY COUNT("player") DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What are the top 3 colleges based on the number of 'OL' position players they have produced for each CFL team?". [/INST] SELECT "cfl_team", "college", COUNT("player") as player_count FROM "round_five" WHERE "position"='OL' GROUP BY "cfl_team", "college" ORDER BY player_count DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "What is the distribution of player positions from the college with the maximum number of players selected under the top 50 pick numbers?". [/INST] SELECT "position", COUNT("player") FROM "round_five" WHERE "college" IN (SELECT "college" FROM "round_five" WHERE "pick_num" < 50 GROUP BY "college" ORDER BY COUNT("player") DESC LIMIT 1) GROUP BY "position" ORDER BY COUNT("player") DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "round_five" ( "pick_num" real, "cfl_team" text, "player" text, "position" text, "college" text );. Question: "How many different positions has Ryan Folk played for each CFL team he's been on?". [/INST] SELECT COUNT("position") FROM "round_five" WHERE "player"='Ryan Folk' GROUP BY "cfl_team";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "singles" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What are the top 3 earliest release dates for songs that have 'KIDS-270' as a reference, categorized by the Japanese title?". [/INST] SELECT "japanese_title", MIN("release_date") FROM "singles" WHERE "reference"='KIDS-270' GROUP BY "japanese_title" ORDER BY MIN("release_date") ASC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "singles" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What is the average Oricon rating for each Japanese title where the Romaji title contains 'Da.i.su.ki', ordered by Oricon rating in descending order, limit to top 5 records.". [/INST] SELECT "japanese_title", AVG("oricon") as average_oricon FROM "singles" WHERE "romaji_title" LIKE '%Da.i.su.ki%' GROUP BY "japanese_title" ORDER BY average_oricon DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "singles" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What are the top 10 Japanese titles ordered by their Oricon score in descending order, where the reference is 'KIDS-430', and count how many of each title are there?". [/INST] SELECT "japanese_title", COUNT("japanese_title"), MAX("oricon") FROM "singles" WHERE "reference"='KIDS-430' GROUP BY "japanese_title" ORDER BY MAX("oricon") DESC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "singles" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What is the average Oricon rating for each reference, with the results ordered by the release date and limited to the earliest five references, when the romaji title is 'Heartbreak Sniper'?". [/INST] SELECT "reference", AVG("oricon") as average_rating FROM "singles" WHERE "romaji_title"='Heartbreak Sniper' GROUP BY "reference" ORDER BY "release_date" LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "albums" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What is the highest and lowest rank of the album '愛のバカ' on the Japanese singles chart and how many times it got ranked?". [/INST] SELECT MAX("oricon"), MIN("oricon"), COUNT("oricon") FROM "albums" WHERE "japanese_title"='愛のバカ' GROUP BY "japanese_title" ORDER BY COUNT("oricon") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "albums" ( "romaji_title" text, "japanese_title" text, "release_date" text, "reference" text, "oricon" real );. Question: "What are the earliest and the latest release dates with the number of songs that have 'Mi-Chemin' as their Japanese name and romanji name and how is their distribution according to Oricon ranking?". [/INST] SELECT MIN("release_date"), MAX("release_date"), COUNT("romaji_title"), AVG("oricon") FROM "albums" WHERE "japanese_title"='Mi-Chemin' GROUP BY "oricon" ORDER BY "oricon" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "Which condition has the longest average partial thromboplastin time for the top 5 conditions with the lowest average platelet count?". [/INST] SELECT "condition", AVG("partial_thromboplastin_time") AS average_ptt FROM "laboratory_findings_in_various_platelet_" WHERE "condition" IN (SELECT "condition" FROM "laboratory_findings_in_various_platelet_" GROUP BY "condition" ORDER BY AVG("platelet_count") ASC LIMIT 5) GROUP BY "condition" ORDER BY average_ptt DESC LIMIT 1;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "What are the top three conditions that have the maximum frequency where prothrombin time is unaffected and bleeding time is prolonged, and how many times do they occur?". [/INST] SELECT "condition", COUNT("condition") AS "Frequency" FROM "laboratory_findings_in_various_platelet_" WHERE "prothrombin_time"='Unaffected' AND "bleeding_time"='Prolonged' GROUP BY "condition" ORDER BY "Frequency" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "What was the average platelet count and min, max bleeding time for each condition including factor x deficiency as seen in amyloid purpura, ordered by average platelet count descending and limit the result to top 5?". [/INST] SELECT "condition", AVG("platelet_count"), MIN("bleeding_time"), MAX("bleeding_time") FROM "laboratory_findings_in_various_platelet_" WHERE "condition" LIKE '%Factor X deficiency as seen in amyloid purpura%' GROUP BY "condition" ORDER BY AVG("platelet_count") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "In what conditions does the maximum count of occurrences of both prolonged bleeding times and prolonged partial thromboplastin times exist, and list the top five.". [/INST] SELECT "condition", COUNT(*) as frequency FROM "laboratory_findings_in_various_platelet_" WHERE "partial_thromboplastin_time" = 'Prolonged' AND "bleeding_time" = 'Prolonged' GROUP BY "condition" ORDER BY frequency DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "How many unique prothrombin_time results were found for each given bleeding time and platelet count for the condition factor xii deficiency and sort them in ascending order?". [/INST] SELECT "bleeding_time", "platelet_count", COUNT(DISTINCT "prothrombin_time") FROM "laboratory_findings_in_various_platelet_" WHERE "condition"='Factor XII deficiency' GROUP BY "bleeding_time", "platelet_count" ORDER BY COUNT(DISTINCT "prothrombin_time") ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "laboratory_findings_in_various_platelet_" ( "condition" text, "prothrombin_time" text, "partial_thromboplastin_time" text, "bleeding_time" text, "platelet_count" text );. Question: "Which condition has the highest count of unaffected bleeding times when both the platelet count was unaffected and the partial thromboplastin time was unaffected? Also return these selected conditions sorted in descending order and limit the result to the top 5.". [/INST] SELECT "condition", COUNT("bleeding_time") as Count_BleedingTime FROM "laboratory_findings_in_various_platelet_" WHERE "partial_thromboplastin_time"='unaffected' AND "platelet_count"='unaffected' AND "bleeding_time"='unaffected' GROUP BY "condition" ORDER BY Count_BleedingTime DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "Count the number of unique times recorded for each day at the Millhopper location, and order it from the day with the highest records to the least.". [/INST] SELECT "monday", COUNT(DISTINCT "tuesday"), COUNT(DISTINCT "wednesday"), COUNT(DISTINCT "thursday"), COUNT(DISTINCT "friday"), COUNT(DISTINCT "saturday"), COUNT(DISTINCT "sunday") FROM "locations" WHERE "location"='Millhopper' GROUP BY "monday" ORDER BY COUNT(DISTINCT "tuesday") DESC, COUNT(DISTINCT "wednesday") DESC, COUNT(DISTINCT "thursday") DESC, COUNT(DISTINCT "friday") DESC, COUNT(DISTINCT "saturday") DESC, COUNT(DISTINCT "sunday") DESC LIMIT 1 <complete;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "Count the different locations having the same business hours on Wednesday when Monday's operating hours are from 10:00 to 8:00, and order the result by the number of locations in descending order, displaying only the top 5.". [/INST] SELECT "wednesday", COUNT("location") AS count_location FROM "locations" WHERE "monday"='10:00-8:00' GROUP BY "wednesday" ORDER BY count_location DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "In how many locations is the opening time on Thursday the same as that at Hawthorne, and what are these locations sorted in ascending order?". [/INST] SELECT COUNT("location"), "location" FROM "locations" WHERE "thursday"=(SELECT "thursday" FROM "locations" WHERE "location"='Hawthorne') GROUP BY "location" ORDER BY "location" ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "How many different locations have a similar Saturday time if Wednesday's operating time is 10:00-5:00, sorted by Saturday time?". [/INST] SELECT "saturday", COUNT("location") FROM "locations" WHERE "wednesday"='10:00-5:00' GROUP BY "saturday" ORDER BY "saturday" ASC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "Count the number of locations that have the same "thursday" time for a given "sunday" and "tuesday" time and order the result in descending order.". [/INST] SELECT "thursday", COUNT(*) FROM "locations" WHERE "sunday"='1:00-5:00' AND "tuesday"='1:00-7:00' GROUP BY "thursday" ORDER BY COUNT(*) DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "locations" ( "location" text, "monday" text, "tuesday" text, "wednesday" text, "thursday" text, "friday" text, "saturday" text, "sunday" text );. Question: "What's the top 3 earliest open times on Monday for locations that open at 9:00-6:00 on Tuesday, ordered from earliest to latest?". [/INST] SELECT "monday" FROM "locations" WHERE "tuesday"='9:00-6:00' ORDER BY "monday" ASC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "race_results" ( "rnd" real, "race_name" text, "pole_position" text, "fastest_lap" text, "winning_driver" text, "winning_team" text, "report" text );. Question: "How many times did Paul Tracy have the fastest lap per race and for which winning team, order the results by the number of fastest laps in descending order, and limit the output to 5 results?". [/INST] SELECT "winning_team", COUNT("fastest_lap") AS count_fastest_laps FROM "race_results" WHERE "fastest_lap"='Paul Tracy' GROUP BY "winning_team" ORDER BY count_fastest_laps DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "race_results" ( "rnd" real, "race_name" text, "pole_position" text, "fastest_lap" text, "winning_driver" text, "winning_team" text, "report" text );. Question: "Which winning team had most races where their driver drove the fastest lap at the Tenneco Automotive Grand Prix of Detroit and list them with number of such races, limit to top 5?". [/INST] SELECT "winning_team", COUNT(*) FROM "race_results" WHERE "race_name"='Tenneco Automotive Grand Prix of Detroit' AND "fastest_lap"="winning_driver" GROUP BY "winning_team" ORDER BY COUNT(*) DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "race_results" ( "rnd" real, "race_name" text, "pole_position" text, "fastest_lap" text, "winning_driver" text, "winning_team" text, "report" text );. Question: "In the top 5 races with fastest laps, who were the drivers who won the most number of races and are they the same ones who made the fastest laps?". [/INST] SELECT "winning_driver", "fastest_lap", COUNT("winning_driver") AS winning_frequency FROM "race_results" WHERE "fastest_lap" IN (SELECT "fastest_lap" FROM "race_results" ORDER BY "fastest_lap" LIMIT 5) GROUP BY "winning_driver", "fastest_lap" ORDER BY winning_frequency DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "race_results" ( "rnd" real, "race_name" text, "pole_position" text, "fastest_lap" text, "winning_driver" text, "winning_team" text, "report" text );. Question: "In what order of most frequent to least, were the winning drivers in Round 6 and how many races did each driver win?". [/INST] SELECT "winning_driver", COUNT("race_name") as "number_of_wins" FROM "race_results" WHERE "rnd"=6 GROUP BY "winning_driver" ORDER BY "number_of_wins" DESC;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "districts_of_bogor_city" ( "english_name" text, "original_name" text, "area_in_km" text, "population_at_2010_census" real, "number_of_settlements_and_villages" real );. Question: "What is the total area and average number of settlements and villages for districts where the population at the 2010 census was more than 210450? List districts that have more than the average number of settlements and villages, and order them by total area from largest to smallest with a limit of 10.". [/INST] SELECT "original_name", SUM("area_in_km"), AVG("number_of_settlements_and_villages") FROM "districts_of_bogor_city" WHERE "population_at_2010_census" > 210450 GROUP BY "original_name" HAVING "number_of_settlements_and_villages" > AVG("number_of_settlements_and_villages") ORDER BY SUM("area_in_km") DESC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "districts_of_bogor_city" ( "english_name" text, "original_name" text, "area_in_km" text, "population_at_2010_census" real, "number_of_settlements_and_villages" real );. Question: "What is the average population for each unique area in km in the districts of Bogor City, and list the results in descending order, limiting the result to the top 5 districts?". [/INST] SELECT "area_in_km", AVG("population_at_2010_census") FROM "districts_of_bogor_city" GROUP BY "area_in_km" ORDER BY AVG("population_at_2010_census") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "districts_of_bogor_city" ( "english_name" text, "original_name" text, "area_in_km" text, "population_at_2010_census" real, "number_of_settlements_and_villages" real );. Question: "What is the maximum and minimum population of the 2010 census across all settlements and villages within West Bogor?". [/INST] SELECT MAX("population_at_2010_census"), MIN("population_at_2010_census") FROM "districts_of_bogor_city" WHERE "english_name"='West Bogor' GROUP BY "number_of_settlements_and_villages";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "districts_of_bogor_city" ( "english_name" text, "original_name" text, "area_in_km" text, "population_at_2010_census" real, "number_of_settlements_and_villages" real );. Question: "What is the maximum, minimum and average population among districts having an area of 17.72 KM2, and what are the top 3 districts in terms of the number of settlements and villages?". [/INST] SELECT MAX("population_at_2010_census"), MIN("population_at_2010_census"), AVG("population_at_2010_census"), "english_name" FROM "districts_of_bogor_city" WHERE "area_in_km"='17.72' GROUP BY "english_name" ORDER BY "number_of_settlements_and_villages" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "districts_of_bogor_city" ( "english_name" text, "original_name" text, "area_in_km" text, "population_at_2010_census" real, "number_of_settlements_and_villages" real );. Question: "What is the total population for districts with area greater than the average area size of all districts and how many settlements and villages are there in each of those districts?". [/INST] SELECT SUM("population_at_2010_census"), "original_name", COUNT("number_of_settlements_and_villages") FROM "districts_of_bogor_city" WHERE "area_in_km" > (SELECT AVG("area_in_km") FROM "districts_of_bogor_city") GROUP BY "original_name" ORDER BY SUM("population_at_2010_census") DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "production_overview" ( "pilot_car_no" real, "colour" text, "serial_no" text, "engine_no" real, "registration_no" text );. Question: "What is the total number of distinct colours for each pilot car with registration number starting with 'MG', sorted in descending order of the count, and limit the result to top 5?". [/INST] SELECT "pilot_car_no", COUNT(DISTINCT "colour") as "colour_count" FROM "production_overview" WHERE "registration_no" LIKE 'MG%' GROUP BY "pilot_car_no" ORDER BY "colour_count" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11058032_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "u_s_viewers_millions" text );. Question: "What are the top 5 most viewed episodes directed by Mark Tinker in descending order?". [/INST] SELECT "title", "u_s_viewers_millions" FROM "table1_11058032_1" WHERE "directed_by"='Mark Tinker' ORDER BY "u_s_viewers_millions" DESC LIMIT 5;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11058032_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "u_s_viewers_millions" text );. Question: "How many episodes directed by each director, which have a viewing rate higher than Jeff Melman's least viewed episode, are included in the series along with the maximum, minimum, and average season number of these episodes?". [/INST] SELECT "directed_by", COUNT("title") as "number_of_episodes", MAX("no_in_season") as "max_season_number", MIN("no_in_season") as "min_season_number", AVG("no_in_season") as "average_season_number" FROM "table1_11058032_1" WHERE "u_s_viewers_millions" > (SELECT MIN("u_s_viewers_millions") FROM "table1_11058032_1" WHERE "directed_by"='Jeff Melman') GROUP BY "directed_by" ORDER BY "number_of_episodes" DESC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11058032_1" ( "no_in_series" real, "no_in_season" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text, "u_s_viewers_millions" text );. Question: "What are the top 3 episodes with the most number of viewers, and how many episodes had the same number of viewers as those top 3 episodes?". [/INST] SELECT "u_s_viewers_millions", COUNT("no_in_series") AS "no_of_episodes" FROM "table1_11058032_1" GROUP BY "u_s_viewers_millions" ORDER BY "no_of_episodes" DESC LIMIT 3;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "list_of_imperial_vicars_1437_1792" ( "interregnum_began" text, "interregnum_ended" text, "duration" text, "count_palatine_of_saxony" text, "count_palatine_of_the_rhine" text );. Question: "What is the maximum number of interregnums occurred per count palatine of the rhine for the duration of 3 months, 6 days?". [/INST] SELECT "count_palatine_of_the_rhine", COUNT("interregnum_ended") as number_of_interregnums FROM "list_of_imperial_vicars_1437_1792" WHERE "duration"='3 months, 6 days' GROUP BY "count_palatine_of_the_rhine" ORDER BY number_of_interregnums DESC LIMIT 1<complete;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11075747_4" ( "series_num" real, "episode_num" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "What is the average number of episodes directed by each director and list them in descending order limited by 10?". [/INST] SELECT "directed_by", AVG("episode_num") as episode_avg FROM "table1_11075747_4" GROUP BY "directed_by" ORDER BY episode_avg DESC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11075747_4" ( "series_num" real, "episode_num" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "What is the average episode number for each series that the director who directed the episode called "Tell-tale Heart" has worked on, and sort the results in ascending order by series number with top 10 results only?". [/INST] SELECT "series_num", AVG("episode_num") AS avg_episode_num FROM "table1_11075747_4" WHERE "directed_by"= (SELECT "directed_by" FROM "table1_11075747_4" WHERE "title"='\"Tell-Tale Heart\"') GROUP BY "series_num" ORDER BY "series_num" ASC LIMIT 10;</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11075747_4" ( "series_num" real, "episode_num" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "What is the earliest and the latest air date for all episodes in Series 36?". [/INST] SELECT MIN("original_air_date"), MAX("original_air_date") FROM "table1_11075747_4" WHERE "series_num"=36 GROUP BY "series_num";</s>
<s>[INST] <<SYS>> You are an expert in SQL and data analysis. Given the table structure described by the CREATE TABLE statement, write an SQL query that provides the solution to the question. <</SYS>> CREATE TABLE statement: CREATE TABLE "table1_11075747_4" ( "series_num" real, "episode_num" real, "title" text, "directed_by" text, "written_by" text, "original_air_date" text );. Question: "Who wrote the most number of episodes in Series 38 and what is the count of those episodes? Also, limit the result to the top 5 writers.". [/INST] SELECT "written_by", COUNT("episode_num") AS "number_of_episodes" FROM "table1_11075747_4" WHERE "series_num"=38 GROUP BY "written_by" ORDER BY "number_of_episodes" DESC LIMIT 5;</s>