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 "season_review" ( "rnd" real, "race" text, "date" text, "location" text, "pole_position" text, "fastest_lap" text, "race_winner" text, "constructor" text, "report" text );. Question: "How many races did Ferrari win at each location sorted by the total number of wins per location, and show the date of their most recent and earliest win at each location?". [/INST] SELECT "location", COUNT("race") AS "total_wins", MAX("date") AS "most_recent_win_date", MIN("date") AS "earliest_win_date" FROM "season_review" WHERE "constructor"='Ferrari' AND "race_winner"='Ferrari' GROUP BY "location" ORDER BY "total_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 "season_review" ( "rnd" real, "race" text, "date" text, "location" text, "pole_position" text, "fastest_lap" text, "race_winner" text, "constructor" text, "report" text );. Question: "How many times for each constructor has Niki Lauda secured the pole position in the Monaco Grand Prix, and order them by count in descending order.". [/INST] SELECT "constructor", COUNT("rnd") AS "times_in_pole_position" FROM "season_review" WHERE "pole_position"='Niki Lauda' AND "race"='Monaco Grand Prix' GROUP BY "constructor" ORDER BY "times_in_pole_position" 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_review" ( "rnd" real, "race" text, "date" text, "location" text, "pole_position" text, "fastest_lap" text, "race_winner" text, "constructor" text, "report" text );. Question: "What are the top 3 constructors by the number of races won in Kyalami?". [/INST] SELECT "constructor", COUNT("race_winner") AS "race_wins" FROM "season_review" WHERE "location"='Kyalami' GROUP BY "constructor" ORDER BY "race_wins" 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_review" ( "rnd" real, "race" text, "date" text, "location" text, "pole_position" text, "fastest_lap" text, "race_winner" text, "constructor" text, "report" text );. Question: "What is the maximum number of times a constructor has achieved pole position for the first 5 rounds, and which constructor is it?". [/INST] SELECT "constructor", COUNT("pole_position") as "Number_of_Poles" FROM "season_review" WHERE "rnd" <= 5 GROUP BY "constructor" ORDER BY "Number_of_Poles" 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 "season_review" ( "rnd" real, "race" text, "date" text, "location" text, "pole_position" text, "fastest_lap" text, "race_winner" text, "constructor" text, "report" text );. Question: "In how many distinct races held at different locations has Jean-Pierre Jarier achieved the fastest lap, and also identify the constructor? List down the top 5 occurences.". [/INST] SELECT "race", "location", "constructor", COUNT(*) FROM "season_review" WHERE "fastest_lap"='Jean-Pierre Jarier' GROUP BY "race", "location", "constructor" 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "On how many distinct dates and for which constructors did Clay Regazzoni win for each circuit?". [/INST] SELECT "circuit", COUNT(DISTINCT "date"), GROUP_CONCAT(DISTINCT "constructor") FROM "non_championship_race_results" WHERE "winning_driver"='Clay Regazzoni' GROUP BY "circuit";</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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "On how many different dates and in which circuits did Chris Amon win, ordered by date?". [/INST] SELECT "date", "circuit", COUNT(*) FROM "non_championship_race_results" WHERE "winning_driver"='Chris Amon' GROUP BY "date", "circuit" ORDER BY "date" 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many different constructors won races in each respective circuit where the 'VI Rhein-Pokalrennen' was held?". [/INST] SELECT COUNT(DISTINCT "constructor") FROM "non_championship_race_results" WHERE "race_name"='VI Rhein-Pokalrennen' GROUP BY "circuit";</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 "non_championship_race_results" ( "num" real, "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "Which constructor participated in the most races and what's their last race's date?". [/INST] SELECT "constructor", COUNT("race_name"), MAX("date") FROM "non_championship_race_results" GROUP BY "constructor" ORDER BY COUNT("race_name") 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 "non_championship_race_results" ( "num" real, "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many winning drivers per constructor on the Solitudering circuit and what is the earliest and latest date each has won a race? Order them by constructor in ascending order but limit to top 5.". [/INST] SELECT "constructor", COUNT("winning_driver"), MIN("date"), MAX("date") FROM "non_championship_race_results" WHERE "circuit"='Solitudering' GROUP BY "constructor" ORDER BY "constructor" 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 "non_championship_race_results" ( "num" real, "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many races have been won by each constructor at Silverstone circuit, sorted in descending order, limit to top 5 constructors.". [/INST] SELECT "constructor", COUNT("winning_driver") as races_won FROM "non_championship_race_results" WHERE "circuit"='Silverstone' GROUP BY "constructor" ORDER BY races_won 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 "non_championship_race_results" ( "num" real, "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the maximum number of constructors involved in any single race, and list the top 5 races with the most number of constructors?". [/INST] SELECT "race_name", COUNT("constructor") AS "constructor_count" FROM "non_championship_race_results" GROUP BY "race_name" ORDER BY "constructor_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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many different drivers have won the race at each circuit for all the 'II Danish Grand Prix' races?". [/INST] SELECT COUNT(DISTINCT "winning_driver") FROM "non_championship_races_review" WHERE "race_name"='II Danish Grand Prix' GROUP BY "circuit";</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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the count of different race circuits for each constructor dated 26 March, sorted in descending order of count, limit to top 5?". [/INST] SELECT "constructor", COUNT(DISTINCT "circuit") as circuits_count FROM "non_championship_races_review" WHERE "date"='26 March' GROUP BY "constructor" ORDER BY circuits_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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the total count of unique circuits for every given constructor on 22nd April, sorted in descending order and limit the result to top 5?". [/INST] SELECT "constructor", COUNT(DISTINCT "circuit") AS total FROM "non_championship_races_review" WHERE "date"='22 April' GROUP BY "constructor" ORDER BY total 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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many races with unique names has each constructor won at Zeltweg Airfield, and list the top 5 in descending order.". [/INST] SELECT "constructor", COUNT(DISTINCT "race_name") AS count_of_races FROM "non_championship_races_review" WHERE "circuit"='Zeltweg Airfield' GROUP BY "constructor" ORDER BY count_of_races 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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the maximum and minimum event date for each constructor where the winning driver raced in the Posillipo circuit?". [/INST] SELECT "constructor", MAX("date"), MIN("date") FROM "non_championship_races_review" WHERE "circuit"='Posillipo' GROUP BY "constructor";</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 "non_championship_races_review" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the top 5 winning drivers and their corresponding constructors for each circuit where the race 'XI Syracuse Grand Prix' was held, and how many times each of them has won there?". [/INST] SELECT "winning_driver", "constructor", COUNT(*) as wins FROM "non_championship_races_review" WHERE "race_name" = 'XI Syracuse Grand Prix' GROUP BY "circuit", "winning_driver", "constructor" ORDER BY wins 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "Count of winning drivers for each constructor for races that took place in the Pau circuit". [/INST] SELECT "constructor", COUNT("winning_driver") FROM "non_championship_race_results" WHERE "circuit"='Pau' GROUP BY "constructor" ORDER BY COUNT("winning_driver") 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the top 3 most frequent constructors for the races that Juan Manuel Fangio won, along with the number of reports for each constructor?". [/INST] SELECT "constructor", COUNT("report") FROM "non_championship_race_results" WHERE "winning_driver"='Juan Manuel Fangio' GROUP BY "constructor" ORDER BY COUNT("report") 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many races have been won by each constructor at the Syracuse circuit, and what was the earliest and latest race dates for each constructor?". [/INST] SELECT "constructor", COUNT("winning_driver"), MIN("date"), MAX("date") FROM "non_championship_race_results" WHERE "circuit"='Syracuse' GROUP BY "constructor" ORDER BY COUNT("winning_driver") 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the name of the most frequently occurring race occurred in the Modena circuit and the count?". [/INST] SELECT "race_name", COUNT("race_name") AS "occurrence_count" FROM "non_championship_race_results" WHERE "circuit"='Modena' GROUP BY "race_name" ORDER BY "occurrence_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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the names of the top 3 races held at the Monza circuit, ordered by the frequency of occurrence?". [/INST] SELECT "race_name", COUNT(*) FROM "non_championship_race_results" WHERE "circuit"='Monza' GROUP BY "race_name" ORDER BY 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What was the maximum number of races held at each circuit, for the top 5 circuits where V Madgwick Cup took place?". [/INST] SELECT "circuit", COUNT("race_name") as "race_count" FROM "non_championship_race_results" WHERE "race_name"='V Madgwick Cup' GROUP BY "circuit" ORDER BY "race_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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "Can you provide the count of races won per constructor for the driver who won the race XIV El盲intarhanajot, ordered by the count in descending order and limit it to 5 records?". [/INST] SELECT "constructor", COUNT("race_name") AS wins FROM "non_championship_race_results" WHERE "winning_driver"=(SELECT "winning_driver" FROM "non_championship_race_results" WHERE "race_name"='XIV El盲intarhanajot') GROUP BY "constructor" ORDER BY wins 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "List the top 3 winning drivers with their respective constructors who won most frequently at the Modena circuit?". [/INST] SELECT "winning_driver", "constructor", COUNT(*) as victories FROM "non_championship_race_results" WHERE "circuit"='Modena' GROUP BY "winning_driver", "constructor" ORDER BY victories 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the top three most frequent constructors who won the III Redex Trophy and how many times did each win?". [/INST] SELECT "constructor", COUNT(*) AS "Victories" FROM "non_championship_race_results" WHERE "race_name"='III RedeX Trophy' GROUP BY "constructor" ORDER BY "Victories" 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the top 3 races where Mike Hawthorn won, grouped by circuit and ordered by the date of race?". [/INST] SELECT "race_name", "circuit", "date", COUNT(*) as "win_times" FROM "non_championship_race_results" WHERE "winning_driver"='Mike Hawthorn' GROUP BY "race_name", "circuit" ORDER BY "date" 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What were the top 3 longest race names held in Bordeaux, based on the number of characters in the name?". [/INST] SELECT "race_name", LENGTH("race_name") as name_length FROM "non_championship_race_results" WHERE "circuit"='Bordeaux' ORDER BY name_length 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What is the total number of races won by each constructor in the top 5 winning list? List them by the name of the constructor sorted in descending order.". [/INST] SELECT "constructor", COUNT("winning_driver") AS "Total Wins" FROM "non_championship_race_results" WHERE "race_name" = 'V Ulster Trophy' GROUP BY "constructor" ORDER BY COUNT("winning_driver") 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many races each constructor won at the Silverstone circuit, order the results by the number of races won, showing the top 5.". [/INST] SELECT "constructor", COUNT("race_name") as races_won FROM "non_championship_race_results" WHERE "circuit"='Silverstone' GROUP BY "constructor" ORDER BY races_won 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "What are the names and dates of the top five earliest races at the Silverstone circuit, grouped by winning driver?". [/INST] SELECT "winning_driver", "race_name", MIN("date") FROM "non_championship_race_results" WHERE "circuit"='Silverstone' GROUP BY "winning_driver" ORDER BY MIN("date") 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "How many races have occurred per circuit, and tell me the name and date of the most recent race as well as the winning driver and constructor for that race. Show this information only for the top 3 circuits with the most races.". [/INST] SELECT "circuit", COUNT("race_name") as race_count, MAX("date") as latest_race_date, "winning_driver", "constructor", "race_name" FROM "non_championship_race_results" GROUP BY "circuit" ORDER BY race_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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "Count the number of winning drivers per constructor for the race 'XII Pau Grand Prix' and order the result by count in descending order, and display the first 5 results.". [/INST] SELECT "constructor", COUNT("winning_driver") AS WinningDriverCount FROM "non_championship_race_results" WHERE "race_name"='XII Pau Grand Prix' GROUP BY "constructor" ORDER BY WinningDriverCount 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 "non_championship_race_results" ( "race_name" text, "circuit" text, "date" text, "winning_driver" text, "constructor" text, "report" text );. Question: "Get the top 3 dates when the winning drivers won the most races at the Goodwood circuit.". [/INST] SELECT "date", COUNT("winning_driver") AS "win_count" FROM "non_championship_race_results" WHERE "circuit"='Goodwood' GROUP BY "date" ORDER BY "win_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 "table1_11411026_2" ( "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 is the average number of U.S. viewers in millions for the top 5 episodes with the highest viewership written by Krystal Houghton, and how many such episodes are there?". [/INST] SELECT AVG("u_s_viewers_millions"), COUNT(*) FROM (SELECT "u_s_viewers_millions" FROM "table1_11411026_2" WHERE "written_by"='Krystal Houghton' ORDER BY "u_s_viewers_millions" DESC LIMIT 5) AS temp;</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_11411026_2" ( "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's the maximum number of episodes directed by the same director in series 79, and how many viewers (in millions) did the most and least viewed episode get?". [/INST] SELECT "directed_by", MAX("no_in_season"), MIN("u_s_viewers_millions"), MAX("u_s_viewers_millions") FROM "table1_11411026_2" WHERE "no_in_series"=79 GROUP BY "directed_by" ORDER BY COUNT("title") 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_11411026_2" ( "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: "Who are the top three writers by the total number of episodes they wrote, each having at least one episode watched by more than 19 million US viewers?". [/INST] SELECT "written_by", COUNT("title") as total_episodes FROM "table1_11411026_2" WHERE "u_s_viewers_millions" > '19' GROUP BY "written_by" ORDER BY total_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 "table1_11404452_1" ( "series_num" real, "episode_title" text, "writer_s" text, "director" text, "u_s_viewers_millions" text, "original_air_date" text );. Question: "What are the titles of the top 3 episodes with the highest viewer count directed by Rodman Flender, ordered by viewer count in descending order?". [/INST] SELECT "episode_title" FROM "table1_11404452_1" WHERE "director"='Rodman Flender' ORDER BY "u_s_viewers_millions" 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_11404452_1" ( "series_num" real, "episode_title" text, "writer_s" text, "director" text, "u_s_viewers_millions" text, "original_air_date" text );. Question: "What is the average series number of the episodes directed by Jamie Babbit, and how many were viewed by more than 1 million in the US, ordered in descending order by series number?". [/INST] SELECT AVG("series_num"), COUNT("u_s_viewers_millions") FROM "table1_11404452_1" WHERE "director"='Jamie Babbit' AND "u_s_viewers_millions" > '1' GROUP BY "series_num" ORDER BY "series_num" 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_11404452_1" ( "series_num" real, "episode_title" text, "writer_s" text, "director" text, "u_s_viewers_millions" text, "original_air_date" text );. Question: "What is the minimum, maximum and average series number aired on the date when 12.81 million u.s viewers recorded, ordered by original air date and also limiting to 5 records?". [/INST] SELECT MIN("series_num"), MAX("series_num"), AVG("series_num") FROM "table1_11404452_1" WHERE "u_s_viewers_millions"='12.81' 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_11404452_1" ( "series_num" real, "episode_title" text, "writer_s" text, "director" text, "u_s_viewers_millions" text, "original_air_date" text );. Question: "How many episodes has Shelia Lawrence written per series, and what was the highest viewership for each series she has written for? Order the series based on their original air dates.". [/INST] SELECT "series_num", COUNT("episode_title"), MAX("u_s_viewers_millions") FROM "table1_11404452_1" WHERE "writer_s"='Shelia Lawrence' GROUP BY "series_num" ORDER BY "original_air_date";</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_11404452_1" ( "series_num" real, "episode_title" text, "writer_s" text, "director" text, "u_s_viewers_millions" text, "original_air_date" text );. Question: "How many episodes are directed by each director when viewership is 13.66 million or more in the US, ordered by number of episodes in descending order? Get the top 5 results.". [/INST] SELECT "director", COUNT("episode_title") AS number_of_episodes FROM "table1_11404452_1" WHERE "u_s_viewers_millions" >= '13.66' GROUP BY "director" 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 "yearly_results" ( "season" text, "games" real, "won" real, "lost" real, "tied" real, "points" real, "pct_pct" text, "goals_for" real, "goals_against" real, "standing" text );. Question: "What was the average number of goals scored by the team and the maximum and minimum scores in those seasons where the team won more than 25 games?". [/INST] SELECT AVG("goals_for"), MAX("goals_for"), MIN("goals_for") FROM "yearly_results" WHERE "won">25 GROUP BY "season" ORDER BY "season" 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 "yearly_results" ( "season" text, "games" real, "won" real, "lost" real, "tied" real, "points" real, "pct_pct" text, "goals_for" real, "goals_against" real, "standing" text );. Question: "What is the average number of games won, maximum and minimum number of goals scored, and the total points for seasons in which '2nd OHA' was standing, grouped by the number of games, and limited to the top 5 records sorted by total points in descending order?". [/INST] SELECT AVG("won"), MAX("goals_for"), MIN("goals_for"), SUM("points") FROM "yearly_results" WHERE "standing"='2nd OHA' GROUP BY "games" HAVING "games"=62 ORDER BY SUM("points") 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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "In which wards does the count of Liscumb when Gauthier is 34 is more than 10 and sort these wards in ascending order by their names?". [/INST] SELECT "ward", COUNT("liscumb") FROM "results_by_ward" WHERE "gauthier"='34' GROUP BY "ward" HAVING COUNT("liscumb") > 10 ORDER BY "ward" 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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "What are the top 5 wards with the highest "Bello" value when "Ben-Tahir" exceeds 296, sorted in descending order?". [/INST] SELECT "ward", "bello" FROM "results_by_ward" WHERE "ben_tahir" > '296' ORDER BY "bello" 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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "What are the maximum, minimum, average, and total votes of Ben-Tahir grouped by ward when Bello has more than 51 votes?". [/INST] SELECT "ward", MAX("ben_tahir"), MIN("ben_tahir"), AVG("ben_tahir"), SUM("ben_tahir") FROM "results_by_ward" WHERE "bello" > '51' GROUP BY "ward";</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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "What are the top 5 wards where Haydon's score is the highest if Larter's score is above 11 and Libweshya's score is below 4?". [/INST] SELECT "ward", MAX("haydon") FROM "results_by_ward" WHERE "larter">'11' AND "libweshya"<'4' GROUP BY "ward" ORDER BY MAX("haydon") 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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "What are the top three wards where Haydon got the vote count of 1632 and the corresponding Liscumb vote count is at a minimum?". [/INST] SELECT "ward", MIN("liscumb") FROM "results_by_ward" WHERE "haydon"='1632' GROUP BY "ward" ORDER BY MIN("liscumb") 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 "results_by_ward" ( "ward" text, "bello" text, "ben_tahir" text, "doucet" text, "furtenbacher" text, "gauthier" text, "haydon" text, "larter" text, "lawrance" text, "libweshya" text, "liscumb" text );. Question: "How many unique values of "doucet" exist when "lawrance" is greater than 36 and group them by "ward", and only display the top 5 wards with the highest counts?". [/INST] SELECT "ward", COUNT(DISTINCT "doucet") FROM "results_by_ward" WHERE "lawrance" > '36' GROUP BY "ward" ORDER BY COUNT(DISTINCT "doucet") 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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "List the top 3 dates with the highest attendance which had their games aired on the same TV channel as the game on December 7, 1986, and also provide the count of such games.". [/INST] SELECT "date", "attendance", COUNT(*) FROM "schedule" WHERE "tv" = (SELECT "tv" FROM "schedule" WHERE "date"='December 7, 1986') GROUP BY "date", "attendance" ORDER BY "attendance" 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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "What is the maximum and minimum attendance when the opponent is 'at New Orleans Saints', and how many games were played there?". [/INST] SELECT MAX("attendance"), MIN("attendance"), COUNT("game_site") FROM "schedule" WHERE "opponent"='at New Orleans Saints' GROUP BY "game_site";</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 "houses" ( "house_name" text, "composition" text, "named_after" text, "founded" real, "colours" text );. Question: "What is the average foundation year for houses with green colour grouped by the composition and limit it to the top 5 oldest?". [/INST] SELECT AVG("founded"), "composition" FROM "houses" WHERE "colours" ='Green' GROUP BY "composition" ORDER BY AVG("founded") 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 "houses" ( "house_name" text, "composition" text, "named_after" text, "founded" real, "colours" text );. Question: "What is the total number of distinct individuals or entities the house named Gongola and houses founded in the same year were named after, ordered by the founding year and limiting the result to 5?". [/INST] SELECT COUNT(DISTINCT "named_after") FROM "houses" WHERE "founded" IN (SELECT "founded" FROM "houses" WHERE "house_name"='Gongola') GROUP BY "founded" ORDER BY "founded" 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 "houses" ( "house_name" text, "composition" text, "named_after" text, "founded" real, "colours" text );. Question: "Count the number of houses founded in each year, which are named after a green colour, and list them in descending order. Limit the result to the top 5.". [/INST] SELECT "founded", COUNT("house_name") FROM "houses" WHERE "colours"='Green' GROUP BY "founded" ORDER BY COUNT("house_name") 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 "houses" ( "house_name" text, "composition" text, "named_after" text, "founded" real, "colours" text );. Question: "Determine the earliest and latest year each color house was founded, and count the number of houses named after a specific individual or entity for each color category. Limit the result to the top 5.". [/INST] SELECT "colours", MIN("founded"), MAX("founded"), COUNT("named_after") FROM "houses" GROUP BY "colours" ORDER BY COUNT("named_after") 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 "houses" ( "house_name" text, "composition" text, "named_after" text, "founded" real, "colours" text );. Question: "What is the oldest year of foundation for each type of 'composition' for houses named 'Benue' and list them in descending order of count of each composition and only show top 5 results?". [/INST] SELECT "composition", MIN("founded") FROM "houses" WHERE "house_name"='Benue' GROUP BY "composition" ORDER BY COUNT("composition") 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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "Count the total number of games grouped by opponents in descending order where a game was played against teams with a record of 3-6 during the same week, and limit the result to top 5. Also, show the week with the most games.". [/INST] SELECT "opponent", COUNT("week") as Game_Count FROM "schedule" WHERE "record"='3-6' GROUP BY "opponent" ORDER BY Game_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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "What was the maximum attendance for games against the Minnesota Vikings, grouped by channel?". [/INST] SELECT "tv", MAX("attendance") FROM "schedule" WHERE "opponent"='Minnesota Vikings' GROUP BY "tv";</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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "What is the maximum number of unique game sites, where each opponent had played a game in which attendance was more than 64,087 sorted by the number of unique game sites in the descending order?". [/INST] SELECT "opponent", COUNT(DISTINCT "game_site") AS game_sites_count FROM "schedule" WHERE "attendance" > '64,087' GROUP BY "opponent" ORDER BY game_sites_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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "What was the highest attendance in a game where the team's record was 1-3 and group them by game site.". [/INST] SELECT "game_site", MAX("attendance") FROM "schedule" WHERE "record"='1-3' GROUP BY "game_site";</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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "How many kickoffs were there on each game site during all games happened before September 4, 1988 and list the top 5 sites with most kickoffs in descending order.". [/INST] SELECT "game_site", COUNT("kickoff_a") FROM "schedule" WHERE "date"<='September 4, 1988' GROUP BY "game_site" ORDER BY COUNT("kickoff_a") 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 "schedule" ( "week" text, "date" text, "opponent" text, "result" text, "kickoff_a" text, "game_site" text, "tv" text, "attendance" text, "record" text );. Question: "What was the maximum, minimum, and average number of crowds that watched the games grouped by the game sites where the record was 1-3 and order by average attendance in descending order and limit to 5 rows?". [/INST] SELECT "game_site", MAX("attendance"), MIN("attendance"), AVG("attendance") FROM "schedule" WHERE "record"='1-3' GROUP BY "game_site" ORDER BY 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 "series_summary" ( "series" real, "year" text, "winner" text, "runner_up" text, "third_place" text, "fourth_place" text, "fifth_place" text, "sixth_place" text, "host" text );. Question: "How many times has each host hosted a series where Daniel Zueras was the runner-up, and order it by the number of times in descending order, displaying only top 5 hosts?". [/INST] SELECT "host", COUNT("year") AS "times_hosted" FROM "series_summary" WHERE "runner_up"='Daniel Zueras' GROUP BY "host" ORDER BY "times_hosted" 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 "series_summary" ( "series" real, "year" text, "winner" text, "runner_up" text, "third_place" text, "fourth_place" text, "fifth_place" text, "sixth_place" text, "host" text );. Question: "Find out the maximum number of people who have hosted the show each year when Chenoa ended up in fourth place, and show only the top 5 years with the highest number.". [/INST] SELECT "year", COUNT("host") as host_count FROM "series_summary" WHERE "fourth_place"='Chenoa' GROUP BY "year" ORDER BY host_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 "series_summary" ( "series" real, "year" text, "winner" text, "runner_up" text, "third_place" text, "fourth_place" text, "fifth_place" text, "sixth_place" text, "host" text );. Question: "What is the maximum number of unique participants who got fourth place in each year and who hosted the competition that year?". [/INST] SELECT "year", "host", COUNT(DISTINCT "fourth_place") FROM "series_summary" GROUP BY "year", "host" ORDER BY COUNT(DISTINCT "fourth_place") 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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "Which engine type has the maximum displacement capacity and how many such engines are present for each model when the max torque at rpm is 'N路m ( lbf路ft ) @ 4,800'?". [/INST] SELECT "model", MAX("engine_displacement"), COUNT("engine_type") FROM "models_and_engines" WHERE "max_torque_at_rpm"='N路m ( lbf路ft ) @ 4,800' GROUP BY "model";</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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "How many different models are there per engine type, and what is the maximum and minimum engine displacement for the engine type B5244 T2?". [/INST] SELECT "model", COUNT(*), MAX("engine_displacement"), MIN("engine_displacement") FROM "models_and_engines" WHERE "engine_type"='B5244 T2' GROUP BY "model" ORDER BY COUNT(*) 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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "What is the average engine displacement and maximum motive power for each type of engine and how many models use each of them, sorted by average displacement in descending order, but only showing the top 5 records?". [/INST] SELECT "engine_type", AVG("engine_displacement"), MAX("max_motive_power"), COUNT("model") FROM "models_and_engines" WHERE "engine_type" LIKE 'B5254%' GROUP BY "engine_type" ORDER BY AVG("engine_displacement") 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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "What are the top two most used engine types in '2.4 AWD' model, and how many of them are there?". [/INST] SELECT "engine_type", COUNT("engine_type") AS "engine_type_frequency" FROM "models_and_engines" WHERE "model"='2.4 AWD' GROUP BY "engine_type" ORDER BY "engine_type_frequency" DESC LIMIT 2;</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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "What is the average and maximum motive power and torque at rpm for the 'B5204 T3' engines, arranged in descending order by average motive power with a limit of 5 results?". [/INST] SELECT AVG("max_motive_power"), MAX("max_torque_at_rpm") FROM "models_and_engines" WHERE "engine_type"='B5204 T3' GROUP BY "engine_displacement" ORDER BY AVG("max_motive_power") 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 "models_and_engines" ( "model" text, "max_motive_power" text, "max_torque_at_rpm" text, "engine_displacement" text, "engine_type" text, "engine_configuration_notes_0_100km_h" text );. Question: "What is the maximum engine displacement and motive power for the model which has the most engine type B5234 T3, sorted by maximum torque at RPM? Limit your results to 10.". [/INST] SELECT MAX("engine_displacement"), MAX("max_motive_power") FROM "models_and_engines" WHERE "engine_type"='B5234 T3' GROUP BY "model" ORDER BY "max_torque_at_rpm" 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What is the maximum and minimum power (ps), the sum and average displacement (cm) for each engine model having a torque (nm@rpm) of '240@2200-5000'? Additionally, limit the results to top 5 models ordered by descending average displacement and break any ties by ascending engine model.". [/INST] SELECT "model_name", MAX("power_ps"), MIN("power_ps"), SUM("displacement_cm"), AVG("displacement_cm") FROM "engines" WHERE "torque_nm_rpm"='240@2200-5000' GROUP BY "model_name" ORDER BY AVG("displacement_cm") DESC, "model_name" 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What's the average power for each displacement classification for models from 2001 to 2007, and list the top 5 displacements having maximum average power?". [/INST] SELECT "displacement_cm", AVG("power_ps") as average_power FROM "engines" WHERE "model_name" LIKE '%(2001-2007)' GROUP BY "displacement_cm" ORDER BY average_power 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What's the average power in ps, maximum and minimum displacement in cm of all models, grouped by model_name, for those with engine code starting with 'B5', limit the result to 5 and order them by maximum displacement in descending order". [/INST] SELECT "model_name", AVG("power_ps"), MAX("displacement_cm"), MIN("displacement_cm") FROM "engines" WHERE "engine_code" LIKE 'B5%' GROUP BY "model_name" ORDER BY MAX("displacement_cm") 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What is the average power and the maximum and minimum displacement of engines whose torque value is between 350@1800-6000, grouped by model name and sorted by average power in descending order? Include only the top 10 results.". [/INST] SELECT "model_name", AVG("power_ps"), MAX("displacement_cm"), MIN("displacement_cm") FROM "engines" WHERE "torque_nm_rpm"='350@1800-6000' GROUP BY "model_name" ORDER BY AVG("power_ps") 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What are the top 3 most common engine power (ps) for the engine models which have a torque of 230@4500, ranked in descending order?". [/INST] SELECT "power_ps", COUNT("model_name") FROM "engines" WHERE "torque_nm_rpm"='230@4500' GROUP BY "power_ps" ORDER BY COUNT("model_name") 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What's the average displacement and maximum power of the models, grouped by engine code, where the engine code for some models is 'B5254 T4', ordered by the average displacement in descending order, and limit the result set to 5". [/INST] SELECT "engine_code", AVG("displacement_cm"), MAX("power_ps") FROM "engines" WHERE "engine_code" = 'B5254 T4' GROUP BY "engine_code" ORDER BY AVG("displacement_cm") 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What is the average power of all engines which have the same displacement as the one with 'D5244 T5' engine code?". [/INST] SELECT AVG("power_ps") FROM "engines" WHERE "displacement_cm" = (SELECT "displacement_cm" FROM "engines" WHERE "engine_code"='D5244 T5') GROUP BY "displacement_cm";</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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What are the top 3 model names with the largest displacement and how many are they corresponding to each engine code 'D5244 T'?". [/INST] SELECT "model_name", COUNT(*) FROM "engines" WHERE "engine_code"='D5244 T' GROUP BY "model_name" ORDER BY "displacement_cm" 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "Get the model with the highest power in ps and least displacement in cm for each unique torque value.". [/INST] SELECT "model_name", MAX("power_ps"), MIN("displacement_cm") FROM "engines" WHERE "engine_code" LIKE '%D5252 T%' GROUP BY "torque_nm_rpm" ORDER BY "power_ps" DESC, "displacement_cm" 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 "engines" ( "model_name" text, "power_ps" real, "torque_nm_rpm" text, "displacement_cm" real, "engine_code" text, "comment" text );. Question: "What is the average displacement and maximum power for each model of engines like 'D5244 T7', grouped by model, and ordered by the average displacement in descending order? Limit the result to the top 10 records.". [/INST] SELECT "model_name", AVG("displacement_cm"), MAX("power_ps") FROM "engines" WHERE "engine_code" like 'D5244 T7' GROUP BY "model_name" ORDER BY AVG("displacement_cm") 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 "k" ( "player" text, "no" text, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "How many players from each nationality occupy the position of number 47?". [/INST] SELECT COUNT("player"), "nationality" FROM "k" WHERE "no"='47' GROUP BY "nationality";</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 "k" ( "player" text, "no" text, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "Count the number of players from Turkey for each position and order it by positions in descending order, limit it to top 5.". [/INST] SELECT "position", COUNT("player") AS player_count FROM "k" WHERE "nationality"='Turkey' GROUP BY "position" ORDER BY player_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 "k" ( "player" text, "no" text, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "How many players from each nationality have played for Jazz and ranked by descending order with a limit of 10?". [/INST] SELECT "nationality", COUNT("player") FROM "k" WHERE "years_for_jazz" IS NOT NULL GROUP BY "nationality" ORDER BY COUNT("player") 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 "k" ( "player" text, "no" text, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "For the years 1998-99, how many players, grouped by nationality, played in each position?". [/INST] SELECT COUNT("player"), "nationality", "position" FROM "k" WHERE "years_for_jazz"='1998-99' GROUP BY "nationality", "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 "k" ( "player" text, "no" text, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "What is the maximum number of years played for Jazz by players from each position who attended Creighton, and how many players from Creighton have been in each of these positions?". [/INST] SELECT "position", MAX("years_for_jazz"), COUNT("player") FROM "k" WHERE "school_club_team"='Creighton' 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 "l" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "Count the number of players, group by their position, from Marshall and who played 1974-75, also order the result by position and limit to 5.". [/INST] SELECT "position", COUNT("player") FROM "l" WHERE "years_for_jazz"='1974-75' AND "school_club_team"='Marshall' GROUP BY "position" ORDER BY "position" 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 "l" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "What is the most common player position by nationality for those who went to Oregon?". [/INST] SELECT "nationality", "position", COUNT("player") AS "num_of_players" FROM "l" WHERE "school_club_team"='Oregon' GROUP BY "nationality", "position" ORDER BY "num_of_players" 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 "l" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "What is the total number of players from each country that have played for Jazz, order it in the ascending order of player count and limit it to the top 5 countries?". [/INST] SELECT "nationality", COUNT("player") FROM "l" WHERE "years_for_jazz" IS NOT NULL GROUP BY "nationality" ORDER BY COUNT("player") 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 "l" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "What is the average number of players from each school or club team from Minnesota, listed in descending order?". [/INST] SELECT AVG("no"), "school_club_team" FROM "l" WHERE "school_club_team"='Minnesota' GROUP BY "school_club_team" ORDER BY AVG("no") 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 "s" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "For each position, what is the maximum, minimum and average number of players from each nationality who played between the years 2000-02?". [/INST] SELECT "position", "nationality", MAX("no"), MIN("no"), AVG("no") FROM "s" WHERE "years_for_jazz"='2000-02' GROUP BY "position", "nationality";</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 "s" ( "player" text, "no" real, "nationality" text, "position" text, "years_for_jazz" text, "school_club_team" text );. Question: "Find the count of players from each school_club_team that Kirk Snyder attended, grouped by their position, and order them based on their position in ascending order.". [/INST] SELECT "position", COUNT("player") FROM "s" WHERE "school_club_team" IN (SELECT "school_club_team" FROM "s" WHERE "player"='Kirk Snyder') GROUP BY "position" ORDER BY "position" ASC;</s>