[ { "question": "Can you help me find the top 5 countries with the highest average runs per match for all players across all seasons, and also include their batting averages?", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you help me find the top 5 countries with the highest average runs per match for all players across all seasons, and also include their batting averages?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Find the IDs of players who scored the highest number of partnership runs for each match. The output should include the IDs of two players, each with their individual scores and the total partnership score. There can be multiple rows for a single match.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFind the IDs of players who scored the highest number of partnership runs for each match. The output should include the IDs of two players, each with their individual scores and the total partnership score. There can be multiple rows for a single match.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please help me find the names of top 5 players with the highest average runs per match in season 5, along with their batting averages.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease help me find the names of top 5 players with the highest average runs per match in season 5, along with their batting averages.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Help me respectively caulculate the percentage of motorcycle accident fatalities involving riders who were wearing helmets and those who weren't?", "schema": "CREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['12597', '020507']\n reporting_district TEXT, -- example: ['1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['077', '089']\n primary_road TEXT, -- example: ['RIDER', 'RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['clear', 'raining']\n weather_2 TEXT, -- example: ['raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['fatal', 'property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['construction', 'normal']\n road_condition_2 TEXT, -- example: ['normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['motorcycle', 'passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['motorcycle', 'passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['motorcycle', '00', 'semi']\n party_race TEXT, -- example: ['white', 'hispanic']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['12597', '020507']\n reporting_district TEXT, -- example: ['1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['077', '089']\n primary_road TEXT, -- example: ['RIDER', 'RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['clear', 'raining']\n weather_2 TEXT, -- example: ['raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['fatal', 'property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['construction', 'normal']\n road_condition_2 TEXT, -- example: ['normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['motorcycle', 'passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['motorcycle', 'passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['motorcycle', '00', 'semi']\n party_race TEXT, -- example: ['white', 'hispanic']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHelp me respectively caulculate the percentage of motorcycle accident fatalities involving riders who were wearing helmets and those who weren't?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you calculate the median from the highest season goals of each team?", "schema": "CREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you calculate the median from the highest season goals of each team?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Who is the player with the most wins?", "schema": "CREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWho is the player with the most wins?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which products were picked for order 421, and what is the average number of units picked for each product, using FIFO (First-In, First-Out) method?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich products were picked for order 421, and what is the average number of units picked for each product, using FIFO (First-In, First-Out) method?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What percentage of trees in the Bronx have a health status of Good?", "schema": "CREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['percentage', 'status', 'health', 'bronx', 'trees', 'good']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Health', 'Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['percentage', 'status', 'health', 'bronx', 'trees', 'good']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Health', 'Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat percentage of trees in the Bronx have a health status of Good?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the average pick percentage for each product (by name), considering the quantity picked from inventory locations that are ordered by the earliest purchase date and smallest quantity, while ensuring that the picked quantity matches the overlapping range between the order quantity and the available inventory?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Purchaser', 'Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Purchaser', 'Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the average pick percentage for each product (by name), considering the quantity picked from inventory locations that are ordered by the earliest purchase date and smallest quantity, while ensuring that the picked quantity matches the overlapping range between the order quantity and the available inventory?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please review our interest data from September 2018 to August 2019. I need to know the max average composition value for each month, as well as the three-month rolling average. Ensure the output includes the date, the interest name, the max index composition for that month, the rolling average, and the top-ranking interests from the one month ago and two months ago with their names.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease review our interest data from September 2018 to August 2019. I need to know the max average composition value for each month, as well as the three-month rolling average. Ensure the output includes the date, the interest name, the max index composition for that month, the rolling average, and the top-ranking interests from the one month ago and two months ago with their names.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please examine our records for Chinese cities in July 2021 and identify both the shortest and longest streaks of consecutive date entries. List the dates along with their corresponding city names, capitalizing the first letter of each city name, for these streaks.", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['records', 'streak', 'record', 'please', 'list', 'july']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['July', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Records', 'Streak', 'Record', 'Please', 'List', 'July']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['chinese', 'pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['LIST', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['records', 'streak', 'record', 'please', 'list', 'july']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['July', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Records', 'Streak', 'Record', 'Please', 'List', 'July']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['chinese', 'pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['LIST', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease examine our records for Chinese cities in July 2021 and identify both the shortest and longest streaks of consecutive date entries. List the dates along with their corresponding city names, capitalizing the first letter of each city name, for these streaks.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Tell me top10 teams with the most wins across the league", "schema": "CREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nTell me top10 teams with the most wins across the league\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which single team has the fewest wins in each league?", "schema": "CREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich single team has the fewest wins in each league?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Show me the names of strikers who scored no less than 100 runs in a match, but their team lost the game?", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nShow me the names of strikers who scored no less than 100 runs in a match, but their team lost the game?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you identify the hubs that saw more than a 20% increase in finished orders from February to March?", "schema": "CREATE TABLE channels (\n channel_id INTEGER, -- example: [1, 2]\n channel_name VARCHAR(50), -- example: ['OTHER PLACE', 'PHONE PLACE']\n channel_type VARCHAR(50), -- example: ['OWN CHANNEL', 'MARKETPLACE']\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE drivers (\n driver_id INTEGER, -- example: [133, 138]\n driver_modal VARCHAR(50), -- example: ['MOTOBOY', 'BIKER']\n driver_type VARCHAR(50), -- example: ['LOGISTIC OPERATOR', 'FREELANCE']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE deliveries (\n delivery_id INTEGER, -- example: [2174658, 2174660]\n delivery_order_id INTEGER, -- example: [68413340, 68414309]\n driver_id INTEGER, -- example: [8378, 2473]\n delivery_distance_meters DECIMAL(10, 2), -- example: [5199, 410]\n delivery_status VARCHAR(50), -- example: ['DELIVERED', 'CANCELLED']\n PRIMARY KEY (delivery_id)\n);\n\nCREATE TABLE hubs (\n hub_id INTEGER, -- example: [2, 3]\n hub_name VARCHAR(50), -- example: ['BLUE SHOPPING', 'GREEN SHOPPING']\n hub_city VARCHAR(50), -- example: ['PORTO ALEGRE', 'RIO DE JANEIRO']\n hub_state CHAR(2), -- example: ['RS', 'RJ']\n hub_latitude DECIMAL(9, 6), -- example: [-30.0474148, -30.0374149]\n hub_longitude DECIMAL(9, 6), -- example: [-51.21351, -51.20352]\n PRIMARY KEY (hub_id)\n);\n\nCREATE TABLE payments (\n payment_id INTEGER, -- example: [4427917, 4427918]\n payment_order_id INTEGER, -- example: [68410055, 68412721]\n payment_amount DECIMAL(10, 2), -- example: [118.44, 394.81]\n payment_fee DECIMAL(10, 2), -- example: [0, 7.9]\n payment_method VARCHAR(50), -- example: ['VOUCHER', 'ONLINE']\n payment_status VARCHAR(50), -- example: ['PAID', 'CHARGEBACK']\n PRIMARY KEY (payment_id)\n);\n\nCREATE TABLE stores (\n store_id INTEGER, -- example: [3, 6]\n hub_id INTEGER, -- example: [2, 3]\n store_name VARCHAR(50), -- example: ['CUMIURI', 'PIMGUCIS DA VIVA ']\n store_segment VARCHAR(50), -- example: ['FOOD', 'GOOD']\n store_plan_price DECIMAL(10, 2), -- example: [0, 49]\n store_latitude DECIMAL(9, 6), -- example: [-30.0374149, -22.921475]\n store_longitude DECIMAL(9, 6), -- example: [-51.20352, -43.234822]\n PRIMARY KEY (store_id)\n);\n\nCREATE TABLE orders (\n order_id INTEGER, -- example: [68405119, 68405123]\n store_id INTEGER, -- example: [3512, 3401]\n channel_id INTEGER, -- example: [5, 35]\n payment_order_id INTEGER, -- example: [68405119, 68405123]\n delivery_order_id INTEGER, -- example: [68405119, 68405123]\n order_status VARCHAR(50), -- example: ['FINISHED', 'CANCELED']\n order_amount DECIMAL(10, 2), -- example: [62.7, 115.5]\n order_delivery_fee DECIMAL(10, 2), -- example: [0, 9.9]\n order_delivery_cost DECIMAL(10, 2), -- example: [0, 6]\n order_created_hour INTEGER, -- example: [0, 1]\n order_created_minute INTEGER, -- example: [1, 4]\n order_created_day INTEGER, -- example: [1, 2]\n order_created_month INTEGER, -- example: [1, 2]\n order_created_year INTEGER, -- example: [2021]\n order_moment_created DATETIME, -- example: ['1/1/2021 12:01:36 AM', '1/1/2021 12:04:26 AM']\n order_moment_accepted DATETIME, -- example: ['1/1/2021 1:57:00 AM', '1/1/2021 2:33:00 AM']\n order_moment_ready DATETIME, -- example: ['1/2/2021 6:24:06 PM', '1/1/2021 2:38:15 PM']\n order_moment_collected DATETIME, -- example: ['1/2/2021 6:30:44 PM', '1/1/2021 2:38:31 PM']\n order_moment_in_expedition DATETIME, -- example: ['1/2/2021 6:31:15 PM', '1/1/2021 2:39:05 PM']\n order_moment_delivering DATETIME, -- example: ['1/2/2021 6:35:49 PM', '1/1/2021 2:49:18 PM']\n order_moment_delivered DATETIME, -- example: ['1/1/2021 4:22:19 PM', '1/1/2021 3:56:45 PM']\n order_moment_finished DATETIME, -- example: ['1/2/2021 6:57:34 PM', '1/1/2021 4:12:36 PM']\n order_metric_collected_time DECIMAL(10, 2), -- example: [6.63, 0.27]\n order_metric_paused_time DECIMAL(10, 2), -- example: [4.55, 10.22]\n order_metric_production_time DECIMAL(10, 2), -- example: [2391.25, 26.07]\n order_metric_walking_time DECIMAL(10, 2), -- example: [7.17, 0.83]\n order_metric_expediton_speed_time DECIMAL(10, 2), -- example: [11.72, 11.05]\n order_metric_transit_time DECIMAL(10, 2), -- example: [21.75, 83.3]\n order_metric_cycle_time DECIMAL(10, 2), -- example: [2424.72, 120.42]\n PRIMARY KEY (order_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [1, 2]\n channel_name VARCHAR(50), -- example: ['OTHER PLACE', 'PHONE PLACE']\n channel_type VARCHAR(50), -- example: ['OWN CHANNEL', 'MARKETPLACE']\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE drivers (\n driver_id INTEGER, -- example: [133, 138]\n driver_modal VARCHAR(50), -- example: ['MOTOBOY', 'BIKER']\n driver_type VARCHAR(50), -- example: ['LOGISTIC OPERATOR', 'FREELANCE']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE deliveries (\n delivery_id INTEGER, -- example: [2174658, 2174660]\n delivery_order_id INTEGER, -- example: [68413340, 68414309]\n driver_id INTEGER, -- example: [8378, 2473]\n delivery_distance_meters DECIMAL(10, 2), -- example: [5199, 410]\n delivery_status VARCHAR(50), -- example: ['DELIVERED', 'CANCELLED']\n PRIMARY KEY (delivery_id)\n);\n\nCREATE TABLE hubs (\n hub_id INTEGER, -- example: [2, 3]\n hub_name VARCHAR(50), -- example: ['BLUE SHOPPING', 'GREEN SHOPPING']\n hub_city VARCHAR(50), -- example: ['PORTO ALEGRE', 'RIO DE JANEIRO']\n hub_state CHAR(2), -- example: ['RS', 'RJ']\n hub_latitude DECIMAL(9, 6), -- example: [-30.0474148, -30.0374149]\n hub_longitude DECIMAL(9, 6), -- example: [-51.21351, -51.20352]\n PRIMARY KEY (hub_id)\n);\n\nCREATE TABLE payments (\n payment_id INTEGER, -- example: [4427917, 4427918]\n payment_order_id INTEGER, -- example: [68410055, 68412721]\n payment_amount DECIMAL(10, 2), -- example: [118.44, 394.81]\n payment_fee DECIMAL(10, 2), -- example: [0, 7.9]\n payment_method VARCHAR(50), -- example: ['VOUCHER', 'ONLINE']\n payment_status VARCHAR(50), -- example: ['PAID', 'CHARGEBACK']\n PRIMARY KEY (payment_id)\n);\n\nCREATE TABLE stores (\n store_id INTEGER, -- example: [3, 6]\n hub_id INTEGER, -- example: [2, 3]\n store_name VARCHAR(50), -- example: ['CUMIURI', 'PIMGUCIS DA VIVA ']\n store_segment VARCHAR(50), -- example: ['FOOD', 'GOOD']\n store_plan_price DECIMAL(10, 2), -- example: [0, 49]\n store_latitude DECIMAL(9, 6), -- example: [-30.0374149, -22.921475]\n store_longitude DECIMAL(9, 6), -- example: [-51.20352, -43.234822]\n PRIMARY KEY (store_id)\n);\n\nCREATE TABLE orders (\n order_id INTEGER, -- example: [68405119, 68405123]\n store_id INTEGER, -- example: [3512, 3401]\n channel_id INTEGER, -- example: [5, 35]\n payment_order_id INTEGER, -- example: [68405119, 68405123]\n delivery_order_id INTEGER, -- example: [68405119, 68405123]\n order_status VARCHAR(50), -- example: ['FINISHED', 'CANCELED']\n order_amount DECIMAL(10, 2), -- example: [62.7, 115.5]\n order_delivery_fee DECIMAL(10, 2), -- example: [0, 9.9]\n order_delivery_cost DECIMAL(10, 2), -- example: [0, 6]\n order_created_hour INTEGER, -- example: [0, 1]\n order_created_minute INTEGER, -- example: [1, 4]\n order_created_day INTEGER, -- example: [1, 2]\n order_created_month INTEGER, -- example: [1, 2]\n order_created_year INTEGER, -- example: [2021]\n order_moment_created DATETIME, -- example: ['1/1/2021 12:01:36 AM', '1/1/2021 12:04:26 AM']\n order_moment_accepted DATETIME, -- example: ['1/1/2021 1:57:00 AM', '1/1/2021 2:33:00 AM']\n order_moment_ready DATETIME, -- example: ['1/2/2021 6:24:06 PM', '1/1/2021 2:38:15 PM']\n order_moment_collected DATETIME, -- example: ['1/2/2021 6:30:44 PM', '1/1/2021 2:38:31 PM']\n order_moment_in_expedition DATETIME, -- example: ['1/2/2021 6:31:15 PM', '1/1/2021 2:39:05 PM']\n order_moment_delivering DATETIME, -- example: ['1/2/2021 6:35:49 PM', '1/1/2021 2:49:18 PM']\n order_moment_delivered DATETIME, -- example: ['1/1/2021 4:22:19 PM', '1/1/2021 3:56:45 PM']\n order_moment_finished DATETIME, -- example: ['1/2/2021 6:57:34 PM', '1/1/2021 4:12:36 PM']\n order_metric_collected_time DECIMAL(10, 2), -- example: [6.63, 0.27]\n order_metric_paused_time DECIMAL(10, 2), -- example: [4.55, 10.22]\n order_metric_production_time DECIMAL(10, 2), -- example: [2391.25, 26.07]\n order_metric_walking_time DECIMAL(10, 2), -- example: [7.17, 0.83]\n order_metric_expediton_speed_time DECIMAL(10, 2), -- example: [11.72, 11.05]\n order_metric_transit_time DECIMAL(10, 2), -- example: [21.75, 83.3]\n order_metric_cycle_time DECIMAL(10, 2), -- example: [2424.72, 120.42]\n PRIMARY KEY (order_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you identify the hubs that saw more than a 20% increase in finished orders from February to March?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please calculate the average of the highest runs conceded in a single over for each match.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease calculate the average of the highest runs conceded in a single over for each match.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Identify the top three batsmen with the most runs and the top three bowlers with the most wickets in each season, displaying them in the same row for each season. In case of ties, prioritize players with lower player_ids. Exclude 'run out', 'hit wicket', and 'retired hurt' as out_types for bowlers.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['retired hurt', 'hit wicket', 'run out', 'caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['retired hurt', 'hit wicket', 'run out', 'caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIdentify the top three batsmen with the most runs and the top three bowlers with the most wickets in each season, displaying them in the same row for each season. In case of ties, prioritize players with lower player_ids. Exclude 'run out', 'hit wicket', and 'retired hurt' as out_types for bowlers.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you review our records in June 2022 and identify which countries have the longest streak of consecutive inserted city dates? Please list the 2-letter length country codes of these countries.", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['June', 'Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['June', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['records', 'please', 'streak', 'record', 'list', 'have']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['June', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['June', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Records', 'Please', 'Streak', 'Record', 'List', 'Have']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['LIST', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['June', 'Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['June', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['records', 'please', 'streak', 'record', 'list', 'have']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['June', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['June', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Records', 'Please', 'Streak', 'Record', 'List', 'Have']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['LIST', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you review our records in June 2022 and identify which countries have the longest streak of consecutive inserted city dates? Please list the 2-letter length country codes of these countries.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you tell me the ID of the top 3 employees who have the highest percentage of orders delivered late, considering only those with more than 50 total orders? Also provide their respective number of late orders and the percentage. ", "schema": "CREATE TABLE categories (\n categoryid INTEGER, -- example: [1, 2]\n categoryname TEXT, -- example: ['Beverages', 'Condiments']\n description TEXT, -- example: ['Soft drinks, coffees, teas, beers, and a', 'Sweet and savory sauces, relishes, sprea']\n picture BLOB, -- example: ['\\\\x']\n);\n\nCREATE TABLE customercustomerdemo (\n customerid TEXT,\n customertypeid TEXT\n);\n\nCREATE TABLE customerdemographics (\n customertypeid TEXT,\n customerdesc TEXT\n);\n\nCREATE TABLE customers (\n customerid TEXT, -- example: ['ALFKI', 'ANATR']\n companyname TEXT, -- example: ['Alfreds Futterkiste', 'Ana Trujillo Emparedados y helados']\n contactname TEXT, -- example: ['Maria Anders', 'Ana Trujillo']\n contacttitle TEXT, -- example: ['Sales Representative', 'Owner']\n address TEXT, -- example: ['Obere Str. 57', 'Avda. de la Constitución 2222']\n city TEXT, -- example: ['Berlin', 'México D.F.']\n region TEXT, -- example: ['ID', 'BC', 'SP']\n postalcode TEXT, -- example: ['12209', '05021']\n country TEXT, -- example: ['Germany', 'Mexico']\n phone TEXT, -- example: ['030-0074321', '(5) 555-4729']\n fax TEXT, -- example: ['030-0076545', '(5) 555-3745']\n);\n\nCREATE TABLE employees (\n employeeid INTEGER, -- example: [1, 2]\n lastname TEXT, -- example: ['Davolio', 'Fuller']\n firstname TEXT, -- example: ['Nancy', 'Andrew']\n title TEXT, -- example: ['Sales Representative', 'Vice President, Sales']\n titleofcourtesy TEXT, -- example: ['Ms.', 'Dr.']\n birthdate DATE, -- example: ['1948-12-08', '1952-02-19']\n hiredate DATE, -- example: ['1992-05-01', '1992-08-14']\n address TEXT, -- example: ['507 - 20th Ave. E.\\\\nApt. 2A', '908 W. Capital Way']\n city TEXT, -- example: ['Seattle', 'Tacoma']\n region TEXT, -- example: ['WA']\n postalcode TEXT, -- example: ['98122', '98401']\n country TEXT, -- example: ['USA', 'UK']\n homephone TEXT, -- example: ['(206) 555-9857', '(206) 555-9482']\n extension TEXT, -- example: ['5467', '3457']\n photo BLOB, -- example: ['\\\\x']\n notes TEXT, -- example: ['Education includes a BA in psychology fr', 'Andrew received his BTS commercial in 19']\n reportsto INTEGER, -- example: [2, 5]\n photopath TEXT, -- example: ['http://accweb/emmployees/davolio.bmp', 'http://accweb/emmployees/fuller.bmp']\n);\n\nCREATE TABLE employeeterritories (\n employeeid INTEGER, -- example: [1, 2]\n territoryid TEXT, -- example: ['06897', '19713']\n);\n\nCREATE TABLE order_details (\n orderid INTEGER, -- example: [10248, 10249]\n productid INTEGER, -- example: [11, 42]\n unitprice REAL, -- example: [14.0, 9.80000019]\n quantity INTEGER, -- example: [12, 10]\n discount REAL, -- example: [0.0, 0.150000006]\n);\n\nCREATE TABLE orders (\n orderid INTEGER, -- example: [10248, 10249]\n customerid TEXT, -- example: ['VINET', 'TOMSP']\n employeeid INTEGER, -- example: [5, 6]\n orderdate DATE, -- example: ['1996-07-04', '1996-07-05']\n requireddate DATE, -- example: ['1996-08-01', '1996-08-16']\n shippeddate DATE, -- example: ['1996-07-16', '1996-07-10']\n shipvia INTEGER, -- example: [3, 1]\n freight REAL, -- example: [32.3800011, 11.6099997]\n shipname TEXT, -- example: ['Vins et alcools Chevalier', 'Toms Spezialitäten']\n shipaddress TEXT, -- example: [\"59 rue de l'Abbaye\", 'Luisenstr. 48']\n shipcity TEXT, -- example: ['Reims', 'Münster']\n shipregion TEXT, -- example: ['ID', 'RJ', 'SP']\n shippostalcode TEXT, -- example: ['51100', '44087']\n shipcountry TEXT, -- example: ['France', 'Germany']\n);\n\nCREATE TABLE products (\n productid INTEGER, -- example: [1, 2]\n productname TEXT, -- example: ['Chai', 'Chang']\n supplierid INTEGER, -- example: [8, 1]\n categoryid INTEGER, -- example: [1, 2]\n quantityperunit TEXT, -- example: ['10 boxes x 30 bags', '24 - 12 oz bottles']\n unitprice REAL, -- example: [18.0, 19.0]\n unitsinstock INTEGER, -- example: [39, 17]\n unitsonorder INTEGER, -- example: [0, 40]\n reorderlevel INTEGER, -- example: [10, 25]\n discontinued INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE region (\n regionid INTEGER, -- example: [1, 2]\n regiondescription TEXT, -- example: ['Eastern', 'Western']\n);\n\nCREATE TABLE shippers (\n shipperid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Speedy Express', 'United Package']\n phone TEXT, -- example: ['(503) 555-9831', '(503) 555-3199']\n);\n\nCREATE TABLE suppliers (\n supplierid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Exotic Liquids', 'New Orleans Cajun Delights']\n contactname TEXT, -- example: ['Charlotte Cooper', 'Shelley Burke']\n contacttitle TEXT, -- example: ['Purchasing Manager', 'Order Administrator']\n address TEXT, -- example: ['49 Gilbert St.', 'P.O. Box 78934']\n city TEXT, -- example: ['London', 'New Orleans']\n region TEXT, -- example: ['LA', 'MI']\n postalcode TEXT, -- example: ['EC1 4SD', '70117']\n country TEXT, -- example: ['UK', 'USA']\n phone TEXT, -- example: ['(171) 555-2222', '(100) 555-4822']\n fax TEXT, -- example: ['(313) 555-3349', '(03) 444-6588']\n homepage TEXT, -- example: ['#CAJUN.HTM#', \"Mayumi's (on the World Wide Web)#http://\"]\n);\n\nCREATE TABLE territories (\n territoryid TEXT, -- example: ['01581', '01730']\n territorydescription TEXT, -- example: ['Westboro', 'Bedford']\n regionid INTEGER, -- example: [1, 3]\n);\n\nCREATE TABLE usstates (\n stateid INTEGER, -- example: [1, 2]\n statename TEXT, -- example: ['Alabama', 'Alaska']\n stateabbr TEXT, -- example: ['ID', 'ME', 'AL', 'AK']\n stateregion TEXT, -- example: ['south', 'north']\n);\n\nCREATE TABLE customergroupthreshold (\n groupname TEXT, -- example: ['Low', 'Medium']\n rangebottom DECIMAL, -- example: [0, 1000]\n rangetop DECIMAL, -- example: [999.9999, 4999.9999]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE categories (\n categoryid INTEGER, -- example: [1, 2]\n categoryname TEXT, -- example: ['Beverages', 'Condiments']\n description TEXT, -- example: ['Soft drinks, coffees, teas, beers, and a', 'Sweet and savory sauces, relishes, sprea']\n picture BLOB, -- example: ['\\\\x']\n);\n\nCREATE TABLE customercustomerdemo (\n customerid TEXT,\n customertypeid TEXT\n);\n\nCREATE TABLE customerdemographics (\n customertypeid TEXT,\n customerdesc TEXT\n);\n\nCREATE TABLE customers (\n customerid TEXT, -- example: ['ALFKI', 'ANATR']\n companyname TEXT, -- example: ['Alfreds Futterkiste', 'Ana Trujillo Emparedados y helados']\n contactname TEXT, -- example: ['Maria Anders', 'Ana Trujillo']\n contacttitle TEXT, -- example: ['Sales Representative', 'Owner']\n address TEXT, -- example: ['Obere Str. 57', 'Avda. de la Constitución 2222']\n city TEXT, -- example: ['Berlin', 'México D.F.']\n region TEXT, -- example: ['ID', 'BC', 'SP']\n postalcode TEXT, -- example: ['12209', '05021']\n country TEXT, -- example: ['Germany', 'Mexico']\n phone TEXT, -- example: ['030-0074321', '(5) 555-4729']\n fax TEXT, -- example: ['030-0076545', '(5) 555-3745']\n);\n\nCREATE TABLE employees (\n employeeid INTEGER, -- example: [1, 2]\n lastname TEXT, -- example: ['Davolio', 'Fuller']\n firstname TEXT, -- example: ['Nancy', 'Andrew']\n title TEXT, -- example: ['Sales Representative', 'Vice President, Sales']\n titleofcourtesy TEXT, -- example: ['Ms.', 'Dr.']\n birthdate DATE, -- example: ['1948-12-08', '1952-02-19']\n hiredate DATE, -- example: ['1992-05-01', '1992-08-14']\n address TEXT, -- example: ['507 - 20th Ave. E.\\\\nApt. 2A', '908 W. Capital Way']\n city TEXT, -- example: ['Seattle', 'Tacoma']\n region TEXT, -- example: ['WA']\n postalcode TEXT, -- example: ['98122', '98401']\n country TEXT, -- example: ['USA', 'UK']\n homephone TEXT, -- example: ['(206) 555-9857', '(206) 555-9482']\n extension TEXT, -- example: ['5467', '3457']\n photo BLOB, -- example: ['\\\\x']\n notes TEXT, -- example: ['Education includes a BA in psychology fr', 'Andrew received his BTS commercial in 19']\n reportsto INTEGER, -- example: [2, 5]\n photopath TEXT, -- example: ['http://accweb/emmployees/davolio.bmp', 'http://accweb/emmployees/fuller.bmp']\n);\n\nCREATE TABLE employeeterritories (\n employeeid INTEGER, -- example: [1, 2]\n territoryid TEXT, -- example: ['06897', '19713']\n);\n\nCREATE TABLE order_details (\n orderid INTEGER, -- example: [10248, 10249]\n productid INTEGER, -- example: [11, 42]\n unitprice REAL, -- example: [14.0, 9.80000019]\n quantity INTEGER, -- example: [12, 10]\n discount REAL, -- example: [0.0, 0.150000006]\n);\n\nCREATE TABLE orders (\n orderid INTEGER, -- example: [10248, 10249]\n customerid TEXT, -- example: ['VINET', 'TOMSP']\n employeeid INTEGER, -- example: [5, 6]\n orderdate DATE, -- example: ['1996-07-04', '1996-07-05']\n requireddate DATE, -- example: ['1996-08-01', '1996-08-16']\n shippeddate DATE, -- example: ['1996-07-16', '1996-07-10']\n shipvia INTEGER, -- example: [3, 1]\n freight REAL, -- example: [32.3800011, 11.6099997]\n shipname TEXT, -- example: ['Vins et alcools Chevalier', 'Toms Spezialitäten']\n shipaddress TEXT, -- example: [\"59 rue de l'Abbaye\", 'Luisenstr. 48']\n shipcity TEXT, -- example: ['Reims', 'Münster']\n shipregion TEXT, -- example: ['ID', 'RJ', 'SP']\n shippostalcode TEXT, -- example: ['51100', '44087']\n shipcountry TEXT, -- example: ['France', 'Germany']\n);\n\nCREATE TABLE products (\n productid INTEGER, -- example: [1, 2]\n productname TEXT, -- example: ['Chai', 'Chang']\n supplierid INTEGER, -- example: [8, 1]\n categoryid INTEGER, -- example: [1, 2]\n quantityperunit TEXT, -- example: ['10 boxes x 30 bags', '24 - 12 oz bottles']\n unitprice REAL, -- example: [18.0, 19.0]\n unitsinstock INTEGER, -- example: [39, 17]\n unitsonorder INTEGER, -- example: [0, 40]\n reorderlevel INTEGER, -- example: [10, 25]\n discontinued INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE region (\n regionid INTEGER, -- example: [1, 2]\n regiondescription TEXT, -- example: ['Eastern', 'Western']\n);\n\nCREATE TABLE shippers (\n shipperid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Speedy Express', 'United Package']\n phone TEXT, -- example: ['(503) 555-9831', '(503) 555-3199']\n);\n\nCREATE TABLE suppliers (\n supplierid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Exotic Liquids', 'New Orleans Cajun Delights']\n contactname TEXT, -- example: ['Charlotte Cooper', 'Shelley Burke']\n contacttitle TEXT, -- example: ['Purchasing Manager', 'Order Administrator']\n address TEXT, -- example: ['49 Gilbert St.', 'P.O. Box 78934']\n city TEXT, -- example: ['London', 'New Orleans']\n region TEXT, -- example: ['LA', 'MI']\n postalcode TEXT, -- example: ['EC1 4SD', '70117']\n country TEXT, -- example: ['UK', 'USA']\n phone TEXT, -- example: ['(171) 555-2222', '(100) 555-4822']\n fax TEXT, -- example: ['(313) 555-3349', '(03) 444-6588']\n homepage TEXT, -- example: ['#CAJUN.HTM#', \"Mayumi's (on the World Wide Web)#http://\"]\n);\n\nCREATE TABLE territories (\n territoryid TEXT, -- example: ['01581', '01730']\n territorydescription TEXT, -- example: ['Westboro', 'Bedford']\n regionid INTEGER, -- example: [1, 3]\n);\n\nCREATE TABLE usstates (\n stateid INTEGER, -- example: [1, 2]\n statename TEXT, -- example: ['Alabama', 'Alaska']\n stateabbr TEXT, -- example: ['ID', 'ME', 'AL', 'AK']\n stateregion TEXT, -- example: ['south', 'north']\n);\n\nCREATE TABLE customergroupthreshold (\n groupname TEXT, -- example: ['Low', 'Medium']\n rangebottom DECIMAL, -- example: [0, 1000]\n rangetop DECIMAL, -- example: [999.9999, 4999.9999]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you tell me the ID of the top 3 employees who have the highest percentage of orders delivered late, considering only those with more than 50 total orders? Also provide their respective number of late orders and the percentage. \n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you help me calculate the average number of new unicorn companies per year in the top industry from 2019 to 2021?", "schema": "CREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['companies', 'calculate', 'industry', 'unicorn', 'average', 'number']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['companies', 'calculate', 'industry', 'unicorn', 'average', 'number']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you help me calculate the average number of new unicorn companies per year in the top industry from 2019 to 2021?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Calculate the duration of each track, classify them as short, medium, or long, output the minimum and maximum time for each kind (in minutes) and the total revenue for each category, group by the category.", "schema": "CREATE TABLE Album (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_album_artistid FOREIGN KEY (ArtistId) REFERENCES Artist (ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customer_supportrepid FOREIGN KEY (SupportRepId) REFERENCES Employee (EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employee_reportsto FOREIGN KEY (ReportsTo) REFERENCES Employee (EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoice_customerid FOREIGN KEY (CustomerId) REFERENCES Customer (CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoiceline_invoiceid FOREIGN KEY (InvoiceId) REFERENCES Invoice (InvoiceId),\n CONSTRAINT fk_invoiceline_trackid FOREIGN KEY (TrackId) REFERENCES Track (TrackId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlisttrack_playlistid FOREIGN KEY (PlaylistId) REFERENCES Playlist (PlaylistId),\n CONSTRAINT fk_playlisttrack_trackid FOREIGN KEY (TrackId) REFERENCES Track (TrackId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['Time', 'For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_track_albumid FOREIGN KEY (AlbumId) REFERENCES Album (AlbumId),\n CONSTRAINT fk_track_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES MediaType (MediaTypeId),\n CONSTRAINT fk_track_genreid FOREIGN KEY (GenreId) REFERENCES Genre (GenreId)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Album (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_album_artistid FOREIGN KEY (ArtistId) REFERENCES Artist (ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customer_supportrepid FOREIGN KEY (SupportRepId) REFERENCES Employee (EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employee_reportsto FOREIGN KEY (ReportsTo) REFERENCES Employee (EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoice_customerid FOREIGN KEY (CustomerId) REFERENCES Customer (CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoiceline_invoiceid FOREIGN KEY (InvoiceId) REFERENCES Invoice (InvoiceId),\n CONSTRAINT fk_invoiceline_trackid FOREIGN KEY (TrackId) REFERENCES Track (TrackId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlisttrack_playlistid FOREIGN KEY (PlaylistId) REFERENCES Playlist (PlaylistId),\n CONSTRAINT fk_playlisttrack_trackid FOREIGN KEY (TrackId) REFERENCES Track (TrackId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['Time', 'For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_track_albumid FOREIGN KEY (AlbumId) REFERENCES Album (AlbumId),\n CONSTRAINT fk_track_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES MediaType (MediaTypeId),\n CONSTRAINT fk_track_genreid FOREIGN KEY (GenreId) REFERENCES Genre (GenreId)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Music Length Types\n\n## Short \n- Duration between the minimum value and the midpoint between the minimum and average values.\n\n## Medium \n- Duration between the midpoint between the minimum and average values and the midpoint between the average and maximum values.\n\n## Long \n- Duration between the midpoint between the average and maximum values and the maximum value.\nCalculate the duration of each track, classify them as short, medium, or long, output the minimum and maximum time for each kind (in minutes) and the total revenue for each category, group by the category.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Music Length Types\n\n## Short \n- Duration between the minimum value and the midpoint between the minimum and average values.\n\n## Medium \n- Duration between the midpoint between the minimum and average values and the midpoint between the average and maximum values.\n\n## Long \n- Duration between the midpoint between the average and maximum values and the maximum value." }, { "question": "Prepare a comprehensive performance report on our sellers, focusing on total sales, average item price, average review scores, and packing times. Ensure that the report includes only those sellers who have sold a quantity of more than 100 products and highlight the product category names in English with the highest sales volume.", "schema": "CREATE TABLE customers (\n `index` INTEGER, -- example: [0, 1]\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix INTEGER, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['sales', 'franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE sellers (\n `index` INTEGER, -- example: [0, 1]\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix INTEGER, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE order_reviews (\n `index` INTEGER, -- example: [0, 1]\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score INTEGER, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE order_items (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id INTEGER, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price REAL, -- example: [58.9, 239.9]\n freight_value REAL, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE products (\n `index` INTEGER, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght REAL, -- example: [40.0, 44.0]\n product_description_lenght REAL, -- example: [287.0, 276.0]\n product_photos_qty REAL, -- example: [1.0, 4.0]\n product_weight_g REAL, -- example: [225.0, 1000.0]\n product_length_cm REAL, -- example: [16.0, 30.0]\n product_height_cm REAL, -- example: [10.0, 18.0]\n product_width_cm REAL, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE geolocation (\n `index` INTEGER, -- example: [0, 1]\n geolocation_zip_code_prefix INTEGER, -- example: [1037, 1046]\n geolocation_lat REAL, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng REAL, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sales', 'sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n `index` INTEGER, -- example: [0, 1]\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE orders (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE order_payments (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential INTEGER, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments INTEGER, -- example: [8, 1]\n payment_value REAL, -- example: [99.33, 24.39]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n `index` INTEGER, -- example: [0, 1]\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix INTEGER, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['sales', 'franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE sellers (\n `index` INTEGER, -- example: [0, 1]\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix INTEGER, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE order_reviews (\n `index` INTEGER, -- example: [0, 1]\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score INTEGER, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE order_items (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id INTEGER, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price REAL, -- example: [58.9, 239.9]\n freight_value REAL, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE products (\n `index` INTEGER, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght REAL, -- example: [40.0, 44.0]\n product_description_lenght REAL, -- example: [287.0, 276.0]\n product_photos_qty REAL, -- example: [1.0, 4.0]\n product_weight_g REAL, -- example: [225.0, 1000.0]\n product_length_cm REAL, -- example: [16.0, 30.0]\n product_height_cm REAL, -- example: [10.0, 18.0]\n product_width_cm REAL, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE geolocation (\n `index` INTEGER, -- example: [0, 1]\n geolocation_zip_code_prefix INTEGER, -- example: [1037, 1046]\n geolocation_lat REAL, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng REAL, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sales', 'sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n `index` INTEGER, -- example: [0, 1]\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE orders (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE order_payments (\n `index` INTEGER, -- example: [0, 1]\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential INTEGER, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments INTEGER, -- example: [8, 1]\n payment_value REAL, -- example: [99.33, 24.39]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPrepare a comprehensive performance report on our sellers, focusing on total sales, average item price, average review scores, and packing times. Ensure that the report includes only those sellers who have sold a quantity of more than 100 products and highlight the product category names in English with the highest sales volume.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which product ID, aisle, and position should be selected to pick the highest quantity for order 423, ensuring the picked quantity does not exceed the available inventory in warehouse 1, and calculate the quantity to be picked while prioritizing locations with earlier dates and smaller quantities?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich product ID, aisle, and position should be selected to pick the highest quantity for order 423, ensuring the picked quantity does not exceed the available inventory in warehouse 1, and calculate the quantity to be picked while prioritizing locations with earlier dates and smaller quantities?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which three boroughs have the highest number of trees, and what is the average mean income for each, considering only areas where both median and mean income estimates are greater than zero, and using the available ZIP code income data when tree ZIP codes are missing?", "schema": "CREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['considering', 'available', 'estimates', 'estimate', 'consider', 'boroughs']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['considering', 'available', 'estimates', 'estimate', 'consider', 'boroughs']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich three boroughs have the highest number of trees, and what is the average mean income for each, considering only areas where both median and mean income estimates are greater than zero, and using the available ZIP code income data when tree ZIP codes are missing?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Identify the top 10 and bottom 10 interest categories based on their highest composition values across all months. For each category, display the time(MM-YYYY), interest name, and the composition value", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIdentify the top 10 and bottom 10 interest categories based on their highest composition values across all months. For each category, display the time(MM-YYYY), interest name, and the composition value\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which products (by name) had a seasonality-adjusted sales ratio consistently above 2 for the entire year of 2017, based on monthly sales data from January 2016?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Explanation of Metrics\n\n## 1. Sales-to-CMA Ratio\n- **Definition**: This ratio compares actual sales to the centered moving average (CMA) of sales.\n- **Calculation**:\n - **Centered Moving Average (CMA)**: The CMA is a smoothed value of sales calculated over a rolling 12-month period. It averages sales from the months before and after a given month, specifically using two overlapping windows (5 months before and 6 months after, and vice versa).\n - **Sales-to-CMA Ratio**: The ratio is computed by dividing the actual sales amount for a month by its corresponding CMA value. A ratio greater than 2 indicates that the actual sales are more than twice the smoothed average for that period, suggesting significantly higher-than-average sales.\n\n## 2. 12-Month Overlapping Windows\n- **Definition**: A method to smooth sales data over time by averaging values in a specified window.\n- **Calculation**:\n - **Window Size**: The window spans 12 months, with the specific approach involving overlapping periods. \n - **First Window**: For a given month, this window includes 5 months before and 6 months after.\n - **Second Window**: Another window includes 6 months before and 5 months after the given month.\n - **Averaging**: Sales data is averaged over these two overlapping windows to compute the CMA. This method smooths out fluctuations by considering both the past and future sales in the calculation.\n\n## 3. Restriction to the 7th and 30th Months\n- **Definition**: A filter applied to focus calculations within a specific range of months.\n- **Calculation**:\n - **Time Range**: Only the months between the 7th and 30th time steps (which correspond to specific periods) are considered for calculating the CMA and ratio.\n - **Purpose**: This restriction is used to avoid edge effects in the data where the moving average might be less reliable (e.g., at the very beginning or end of the available data). By focusing on these months, the calculations are more stable and meaningful.\nWhich products (by name) had a seasonality-adjusted sales ratio consistently above 2 for the entire year of 2017, based on monthly sales data from January 2016?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Explanation of Metrics\n\n## 1. Sales-to-CMA Ratio\n- **Definition**: This ratio compares actual sales to the centered moving average (CMA) of sales.\n- **Calculation**:\n - **Centered Moving Average (CMA)**: The CMA is a smoothed value of sales calculated over a rolling 12-month period. It averages sales from the months before and after a given month, specifically using two overlapping windows (5 months before and 6 months after, and vice versa).\n - **Sales-to-CMA Ratio**: The ratio is computed by dividing the actual sales amount for a month by its corresponding CMA value. A ratio greater than 2 indicates that the actual sales are more than twice the smoothed average for that period, suggesting significantly higher-than-average sales.\n\n## 2. 12-Month Overlapping Windows\n- **Definition**: A method to smooth sales data over time by averaging values in a specified window.\n- **Calculation**:\n - **Window Size**: The window spans 12 months, with the specific approach involving overlapping periods. \n - **First Window**: For a given month, this window includes 5 months before and 6 months after.\n - **Second Window**: Another window includes 6 months before and 5 months after the given month.\n - **Averaging**: Sales data is averaged over these two overlapping windows to compute the CMA. This method smooths out fluctuations by considering both the past and future sales in the calculation.\n\n## 3. Restriction to the 7th and 30th Months\n- **Definition**: A filter applied to focus calculations within a specific range of months.\n- **Calculation**:\n - **Time Range**: Only the months between the 7th and 30th time steps (which correspond to specific periods) are considered for calculating the CMA and ratio.\n - **Purpose**: This restriction is used to avoid edge effects in the data where the moving average might be less reliable (e.g., at the very beginning or end of the available data). By focusing on these months, the calculations are more stable and meaningful." }, { "question": "Could you calculate the highest daily balance each customer had within each month? Treat any negative daily balances as zero. Then, for each month, add up these maximum daily balances across all customers to get a monthly total.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you calculate the highest daily balance each customer had within each month? Treat any negative daily balances as zero. Then, for each month, add up these maximum daily balances across all customers to get a monthly total.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Show entertainer and customer pairs where both the first and second style preferences of customers match the first and second strengths of entertainers (or vice versa), displaying only the entertainer's stage name and the customer's last name.", "schema": "CREATE TABLE Agents (\n AgentID int, -- example: [1, 2]\n AgtFirstName nvarchar (25), -- example: ['William', 'Scott']\n AgtLastName nvarchar (25), -- example: ['Thompson', 'Bishop']\n AgtStreetAddress nvarchar (50), -- example: ['122 Spring River Drive', '66 Spring Valley Drive']\n AgtCity nvarchar (30), -- example: ['Redmond', 'Seattle']\n AgtState nvarchar (2), -- example: ['WA']\n AgtZipCode nvarchar (10), -- example: ['98006', '98033']\n AgtPhoneNumber nvarchar (15), -- example: ['555-2681', '555-2666']\n DateHired date, -- example: ['1997-05-15', '1998-02-05']\n Salary decimal(15, 2), -- example: [35000, 27000]\n CommissionRate float(24), -- example: [0.04, 0.05]\n PRIMARY KEY (AgentID)\n);\n\nCREATE TABLE Customers (\n CustomerID int, -- example: [10001, 10002]\n CustFirstName nvarchar (25), -- example: ['Doris', 'Deb']\n CustLastName nvarchar (25), -- example: ['Hartwig', 'Waldal']\n CustStreetAddress nvarchar (50), -- example: ['4726 - 11th Ave. N.E.', '908 W. Capital Way']\n CustCity nvarchar (30), -- example: ['Seattle', 'Tacoma']\n CustState nvarchar (2), -- example: ['WA']\n CustZipCode nvarchar (10), -- example: ['98002', '98006']\n CustPhoneNumber nvarchar (15), -- example: ['555-2671', '555-2496']\n PRIMARY KEY (CustomerID)\n);\n\nCREATE TABLE Engagements (\n EngagementNumber int, -- example: [2, 3]\n StartDate date, -- example: ['2017-09-02', '2017-09-11']\n EndDate date, -- example: ['2017-09-06', '2017-09-16']\n StartTime time, -- example: ['13:00:00', '20:00:00']\n StopTime time, -- example: ['15:00:00', '00:00:00']\n ContractPrice decimal(15, 2), -- example: [200, 590]\n CustomerID int, -- example: [10001, 10002]\n AgentID int, -- example: [1, 2]\n EntertainerID int, -- example: [1001, 1002]\n PRIMARY KEY (EngagementNumber),\n CONSTRAINT fk_engagements_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_engagements_agentid FOREIGN KEY (AgentID) REFERENCES Agents (AgentID),\n CONSTRAINT fk_engagements_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID)\n);\n\nCREATE TABLE Entertainer_Members (\n EntertainerID int, -- example: [1001, 1002]\n MemberID int, -- example: [101, 102]\n Status smallint, -- example: [1, 2]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_members_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_members_memberid FOREIGN KEY (MemberID) REFERENCES Members (MemberID)\n);\n\nCREATE TABLE Entertainer_Styles (\n EntertainerID int, -- example: [1001, 1002]\n StyleID smallint, -- example: [3, 4]\n StyleStrength smallint, -- example: [2, 1]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_styles_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_styles_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Entertainers (\n EntertainerID int, -- example: [1001, 1002]\n EntStageName nvarchar (50), -- example: ['Carol Peacock Trio', 'Topazz']\n EntSSN nvarchar (12), -- example: ['888-90-1121', '888-50-1061']\n EntStreetAddress nvarchar (50), -- example: ['4110 Old Redmond Rd.', '16 Maple Lane']\n EntCity nvarchar (30), -- example: ['Redmond', 'Auburn']\n EntState nvarchar (2), -- example: ['WA']\n EntZipCode nvarchar (10), -- example: ['98002', '98005']\n EntPhoneNumber nvarchar (15), -- example: ['555-2691', '555-2591']\n EntWebPage nvarchar (50), -- example: ['www.cptrio.com', 'www.topazz.com']\n EntEMailAddress nvarchar (50), -- example: ['carolp@cptrio.com', 'jv@myspring.com']\n DateEntered date, -- example: ['1997-05-24', '1996-02-14']\n PRIMARY KEY (EntertainerID)\n);\n\nCREATE TABLE Members (\n MemberID int, -- example: [101, 102]\n MbrFirstName nvarchar (25), -- example: ['David', 'Suzanne']\n MbrLastName nvarchar (25), -- example: ['Hamilton', 'Viescas']\n MbrPhoneNumber nvarchar (15), -- example: ['555-2701', '555-2686']\n Gender nvarchar (2), -- example: ['M', 'F']\n PRIMARY KEY (MemberID)\n);\n\nCREATE TABLE Musical_Preferences (\n CustomerID int, -- example: [10001, 10002]\n StyleID smallint, -- example: [1, 3]\n PreferenceSeq smallint, -- example: [2, 1]\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_musical_preferences_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_musical_preferences_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Musical_Styles (\n StyleID smallint, -- example: [1, 2]\n StyleName nvarchar (75), -- example: [\"40's Ballroom Music\", \"50's Music\"]\n PRIMARY KEY (StyleID)\n);\n\nCREATE TABLE ztblDays (\n DateField date, -- example: ['2017-01-01', '2017-01-02']\n PRIMARY KEY (DateField)\n);\n\nCREATE TABLE ztblMonths (\n MonthYear nvarchar (15), -- example: ['April 2017', 'April 2018']\n YearNumber smallint, -- example: [2017, 2018]\n MonthNumber smallint, -- example: [1, 2]\n MonthStart date, -- example: ['2017-01-01', '2017-02-01']\n MonthEnd date, -- example: ['2017-01-31', '2017-02-28']\n January smallint, -- example: [1, 0]\n February smallint, -- example: [0, 1]\n March smallint, -- example: [0, 1]\n April smallint, -- example: [0, 1]\n May smallint, -- example: [0, 1]\n June smallint, -- example: [0, 1]\n July smallint, -- example: [0, 1]\n August smallint, -- example: [0, 1]\n September smallint, -- example: [0, 1]\n October smallint, -- example: [0, 1]\n November smallint, -- example: [0, 1]\n December smallint, -- example: [0, 1]\n PRIMARY KEY (YearNumber)\n);\n\nCREATE TABLE ztblSkipLabels (\n LabelCount int, -- example: [1, 2]\n PRIMARY KEY (LabelCount)\n);\n\nCREATE TABLE ztblWeeks (\n WeekStart date, -- example: ['2017-01-01', '2017-01-08']\n WeekEnd date, -- example: ['2017-01-07', '2017-01-14']\n PRIMARY KEY (WeekStart)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Agents (\n AgentID int, -- example: [1, 2]\n AgtFirstName nvarchar (25), -- example: ['William', 'Scott']\n AgtLastName nvarchar (25), -- example: ['Thompson', 'Bishop']\n AgtStreetAddress nvarchar (50), -- example: ['122 Spring River Drive', '66 Spring Valley Drive']\n AgtCity nvarchar (30), -- example: ['Redmond', 'Seattle']\n AgtState nvarchar (2), -- example: ['WA']\n AgtZipCode nvarchar (10), -- example: ['98006', '98033']\n AgtPhoneNumber nvarchar (15), -- example: ['555-2681', '555-2666']\n DateHired date, -- example: ['1997-05-15', '1998-02-05']\n Salary decimal(15, 2), -- example: [35000, 27000]\n CommissionRate float(24), -- example: [0.04, 0.05]\n PRIMARY KEY (AgentID)\n);\n\nCREATE TABLE Customers (\n CustomerID int, -- example: [10001, 10002]\n CustFirstName nvarchar (25), -- example: ['Doris', 'Deb']\n CustLastName nvarchar (25), -- example: ['Hartwig', 'Waldal']\n CustStreetAddress nvarchar (50), -- example: ['4726 - 11th Ave. N.E.', '908 W. Capital Way']\n CustCity nvarchar (30), -- example: ['Seattle', 'Tacoma']\n CustState nvarchar (2), -- example: ['WA']\n CustZipCode nvarchar (10), -- example: ['98002', '98006']\n CustPhoneNumber nvarchar (15), -- example: ['555-2671', '555-2496']\n PRIMARY KEY (CustomerID)\n);\n\nCREATE TABLE Engagements (\n EngagementNumber int, -- example: [2, 3]\n StartDate date, -- example: ['2017-09-02', '2017-09-11']\n EndDate date, -- example: ['2017-09-06', '2017-09-16']\n StartTime time, -- example: ['13:00:00', '20:00:00']\n StopTime time, -- example: ['15:00:00', '00:00:00']\n ContractPrice decimal(15, 2), -- example: [200, 590]\n CustomerID int, -- example: [10001, 10002]\n AgentID int, -- example: [1, 2]\n EntertainerID int, -- example: [1001, 1002]\n PRIMARY KEY (EngagementNumber),\n CONSTRAINT fk_engagements_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_engagements_agentid FOREIGN KEY (AgentID) REFERENCES Agents (AgentID),\n CONSTRAINT fk_engagements_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID)\n);\n\nCREATE TABLE Entertainer_Members (\n EntertainerID int, -- example: [1001, 1002]\n MemberID int, -- example: [101, 102]\n Status smallint, -- example: [1, 2]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_members_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_members_memberid FOREIGN KEY (MemberID) REFERENCES Members (MemberID)\n);\n\nCREATE TABLE Entertainer_Styles (\n EntertainerID int, -- example: [1001, 1002]\n StyleID smallint, -- example: [3, 4]\n StyleStrength smallint, -- example: [2, 1]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_styles_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_styles_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Entertainers (\n EntertainerID int, -- example: [1001, 1002]\n EntStageName nvarchar (50), -- example: ['Carol Peacock Trio', 'Topazz']\n EntSSN nvarchar (12), -- example: ['888-90-1121', '888-50-1061']\n EntStreetAddress nvarchar (50), -- example: ['4110 Old Redmond Rd.', '16 Maple Lane']\n EntCity nvarchar (30), -- example: ['Redmond', 'Auburn']\n EntState nvarchar (2), -- example: ['WA']\n EntZipCode nvarchar (10), -- example: ['98002', '98005']\n EntPhoneNumber nvarchar (15), -- example: ['555-2691', '555-2591']\n EntWebPage nvarchar (50), -- example: ['www.cptrio.com', 'www.topazz.com']\n EntEMailAddress nvarchar (50), -- example: ['carolp@cptrio.com', 'jv@myspring.com']\n DateEntered date, -- example: ['1997-05-24', '1996-02-14']\n PRIMARY KEY (EntertainerID)\n);\n\nCREATE TABLE Members (\n MemberID int, -- example: [101, 102]\n MbrFirstName nvarchar (25), -- example: ['David', 'Suzanne']\n MbrLastName nvarchar (25), -- example: ['Hamilton', 'Viescas']\n MbrPhoneNumber nvarchar (15), -- example: ['555-2701', '555-2686']\n Gender nvarchar (2), -- example: ['M', 'F']\n PRIMARY KEY (MemberID)\n);\n\nCREATE TABLE Musical_Preferences (\n CustomerID int, -- example: [10001, 10002]\n StyleID smallint, -- example: [1, 3]\n PreferenceSeq smallint, -- example: [2, 1]\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_musical_preferences_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_musical_preferences_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Musical_Styles (\n StyleID smallint, -- example: [1, 2]\n StyleName nvarchar (75), -- example: [\"40's Ballroom Music\", \"50's Music\"]\n PRIMARY KEY (StyleID)\n);\n\nCREATE TABLE ztblDays (\n DateField date, -- example: ['2017-01-01', '2017-01-02']\n PRIMARY KEY (DateField)\n);\n\nCREATE TABLE ztblMonths (\n MonthYear nvarchar (15), -- example: ['April 2017', 'April 2018']\n YearNumber smallint, -- example: [2017, 2018]\n MonthNumber smallint, -- example: [1, 2]\n MonthStart date, -- example: ['2017-01-01', '2017-02-01']\n MonthEnd date, -- example: ['2017-01-31', '2017-02-28']\n January smallint, -- example: [1, 0]\n February smallint, -- example: [0, 1]\n March smallint, -- example: [0, 1]\n April smallint, -- example: [0, 1]\n May smallint, -- example: [0, 1]\n June smallint, -- example: [0, 1]\n July smallint, -- example: [0, 1]\n August smallint, -- example: [0, 1]\n September smallint, -- example: [0, 1]\n October smallint, -- example: [0, 1]\n November smallint, -- example: [0, 1]\n December smallint, -- example: [0, 1]\n PRIMARY KEY (YearNumber)\n);\n\nCREATE TABLE ztblSkipLabels (\n LabelCount int, -- example: [1, 2]\n PRIMARY KEY (LabelCount)\n);\n\nCREATE TABLE ztblWeeks (\n WeekStart date, -- example: ['2017-01-01', '2017-01-08']\n WeekEnd date, -- example: ['2017-01-07', '2017-01-14']\n PRIMARY KEY (WeekStart)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nShow entertainer and customer pairs where both the first and second style preferences of customers match the first and second strengths of entertainers (or vice versa), displaying only the entertainer's stage name and the customer's last name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "How many overtakes of each type occurred during the first five laps of the race?", "schema": "CREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'speed', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Speed', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['R', '1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Retired', 'Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['R', '1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'speed', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Speed', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'speed', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'speed', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Speed', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['R', '1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Retired', 'Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['R', '1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'speed', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Speed', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'speed', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Overtake Label Classification\n\nIn racing, overtakes are categorized into different states based on specific conditions, reflecting the circumstances in which the overtaking occurred. Below are the classifications and their detailed explanations:\n\n## 1. R (Retirement) - Overtake during Retirement\nAn overtake is labeled as **R (Retirement)** if the overtaken driver retired on the same lap as the overtake. This indicates that the overtake occurred just before or during the overtaken driver's retirement, meaning they could no longer continue the race after that lap.\n\n## 2. P (Pit) - Overtake related to Pit Stops\nAn overtake is classified as **P (Pit)** under two scenarios:\n - **Pit Entry**: If the overtake occurred while the overtaken driver was entering the pit lane, and the driver pitted on the same lap, it indicates that the overtaking happened due to the overtaken driver reducing speed to enter the pit lane.\n - **Pit Exit**: If the overtake occurred as the overtaken driver was exiting the pit lane, especially if the driver pitted on the previous lap and the time gap between the drivers was less than a typical pit stop duration. This suggests that the overtake happened while the overtaken driver was potentially at a lower speed, rejoining the race track from the pit lane.\n\n## 3. S (Start) - Overtake at Race Start\nIf the overtake took place on the first lap of the race, and the two drivers were within two grid positions of each other at the start, the overtake is classified as **S (Start)**. This classification indicates that the overtake was part of the initial racing shuffle during the race's launch phase, where close position changes are common.\n\n## 4. T (Track) - Overtake under Normal Racing Conditions\nIf none of the above conditions apply, the overtake is categorized as **T (Track)**, meaning it occurred during normal racing conditions on the track, without any external factors like pit stops or retirements influencing the outcome. This is the default classification for overtakes that happen during regular competition.\n\n---\n\nThese classifications help to identify and record the context of each overtake with clarity, ensuring accurate representation of race dynamics.\nHow many overtakes of each type occurred during the first five laps of the race?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Overtake Label Classification\n\nIn racing, overtakes are categorized into different states based on specific conditions, reflecting the circumstances in which the overtaking occurred. Below are the classifications and their detailed explanations:\n\n## 1. R (Retirement) - Overtake during Retirement\nAn overtake is labeled as **R (Retirement)** if the overtaken driver retired on the same lap as the overtake. This indicates that the overtake occurred just before or during the overtaken driver's retirement, meaning they could no longer continue the race after that lap.\n\n## 2. P (Pit) - Overtake related to Pit Stops\nAn overtake is classified as **P (Pit)** under two scenarios:\n - **Pit Entry**: If the overtake occurred while the overtaken driver was entering the pit lane, and the driver pitted on the same lap, it indicates that the overtaking happened due to the overtaken driver reducing speed to enter the pit lane.\n - **Pit Exit**: If the overtake occurred as the overtaken driver was exiting the pit lane, especially if the driver pitted on the previous lap and the time gap between the drivers was less than a typical pit stop duration. This suggests that the overtake happened while the overtaken driver was potentially at a lower speed, rejoining the race track from the pit lane.\n\n## 3. S (Start) - Overtake at Race Start\nIf the overtake took place on the first lap of the race, and the two drivers were within two grid positions of each other at the start, the overtake is classified as **S (Start)**. This classification indicates that the overtake was part of the initial racing shuffle during the race's launch phase, where close position changes are common.\n\n## 4. T (Track) - Overtake under Normal Racing Conditions\nIf none of the above conditions apply, the overtake is categorized as **T (Track)**, meaning it occurred during normal racing conditions on the track, without any external factors like pit stops or retirements influencing the outcome. This is the default classification for overtakes that happen during regular competition.\n\n---\n\nThese classifications help to identify and record the context of each overtake with clarity, ensuring accurate representation of race dynamics." }, { "question": "For each year, which driver and which constructor scored the most points? I want the full name of each driver.", "schema": "CREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Starting Position - Grid Drop', 'Race']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Starting Position - Grid Drop', 'Race']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor each year, which driver and which constructor scored the most points? I want the full name of each driver.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "List the three most common third actions users take after visiting the `/detail` page twice in a row, including each action's occurrence count.", "schema": "CREATE TABLE mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n sex varchar(255), -- example: ['M', 'F']\n birth_date varchar(255), -- example: ['1977-06-17', '1953-06-12']\n register_date varchar(255), -- example: ['2016-10-01', '2016-10-05']\n register_device varchar(255), -- example: ['pc', 'sp']\n withdraw_date varchar(255), -- example: ['2016-10-10']\n);\n\nCREATE TABLE action_log (\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'view']\n category varchar(255), -- example: ['action', 'drama']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n);\n\nCREATE TABLE activity_log (\n stamp varchar(255), -- example: ['2017-01-09 12:18:43', '2017-01-09 12:19:27']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n action varchar(255), -- example: ['view']\n option varchar(255), -- example: ['detail', 'page', 'search']\n path varchar(255), -- example: ['/detail', '/detail/', '/search_list/', '/search_input/']\n search_type varchar(255), -- example: ['Area-L-with-Job', 'Pref']\n);\n\nCREATE TABLE read_log (\n stamp varchar(255), -- example: ['2016-12-29 21:45:47', '2016-12-29 21:45:56']\n `session` varchar(255), -- example: ['afbd3d09', 'df6eb25d']\n action varchar(255), -- example: ['view', 'read-20%']\n url varchar(255), -- example: ['http://www.example.com/article?id=news34', 'http://www.example.com/article?id=news73']\n);\n\nCREATE TABLE form_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:04']\n `session` varchar(255), -- example: ['647219c7', '9b5f320f']\n action varchar(255), -- example: ['view']\n path varchar(255), -- example: ['/regist/input', '/cart/input']\n status varchar(255), -- example: ['error']\n);\n\nCREATE TABLE form_error_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:21']\n `session` varchar(255), -- example: ['004dc3ef', '00700be4']\n form varchar(255), -- example: ['regist', 'cart']\n field varchar(255), -- example: ['email', 'kana']\n error_type varchar(255), -- example: ['require', 'format_error']\n `value` varchar(255), -- example: ['101-', 'xxx---.co.jp']\n);\n\nCREATE TABLE action_log_with_ip (\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view']\n ip varchar(255), -- example: ['216.58.220.238', '98.139.183.24']\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE access_log (\n `session` varchar(255), -- example: ['98900e', '1cf768']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view', '1CwlSX']\n stamp varchar(255), -- example: ['/detail', '2016-01-01 18:00:00', '2016-01-02 20:00:00']\n);\n\nCREATE TABLE action_log_with_noise (\n stamp varchar(255),\n `session` varchar(255),\n action varchar(255),\n products varchar(255),\n url text,\n ip varchar(255),\n user_agent text\n);\n\nCREATE TABLE invalid_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'favorite']\n category varchar(255), -- example: ['action', 'drama']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n);\n\nCREATE TABLE mst_categories (\n id integer, -- example: [1, 2]\n name varchar(255), -- example: ['ladys_fashion', 'mens_fashion']\n stamp varchar(255), -- example: ['2016-01-01 10:00:00', '2016-02-01 10:00:00']\n);\n\nCREATE TABLE dup_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['click']\n products varchar(255), -- example: ['D001', 'D002']\n);\n\nCREATE TABLE mst_products_20161201 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE mst_products_20170101 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE app1_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Sato', 'Suzuki']\n email varchar(255), -- example: ['sato@example.com', 'suzuki@example.com']\n);\n\nCREATE TABLE app2_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Ito', 'Tanaka']\n phone varchar(255), -- example: ['080-xxxx-xxxx', '070-xxxx-xxxx']\n);\n\nCREATE TABLE mst_users_with_card_number (\n user_id varchar(255), -- example: ['U001', 'U002']\n card_number varchar(255), -- example: ['1234-xxxx-xxxx-xxxx', '5678-xxxx-xxxx-xxxx']\n);\n\nCREATE TABLE purchase_log (\n purchase_id integer, -- example: [10001, 10002]\n user_id varchar(255), -- example: ['U001', 'U002']\n amount integer, -- example: [200, 500]\n stamp varchar(255), -- example: ['2017-01-30 10:00:00', '2017-02-10 10:00:00']\n);\n\nCREATE TABLE product_sales (\n category_name varchar(255), -- example: ['dvd', 'cd']\n product_id varchar(255), -- example: ['D001', 'D002']\n sales integer, -- example: [50000, 20000]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n sex varchar(255), -- example: ['M', 'F']\n birth_date varchar(255), -- example: ['1977-06-17', '1953-06-12']\n register_date varchar(255), -- example: ['2016-10-01', '2016-10-05']\n register_device varchar(255), -- example: ['pc', 'sp']\n withdraw_date varchar(255), -- example: ['2016-10-10']\n);\n\nCREATE TABLE action_log (\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'view']\n category varchar(255), -- example: ['action', 'drama']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n);\n\nCREATE TABLE activity_log (\n stamp varchar(255), -- example: ['2017-01-09 12:18:43', '2017-01-09 12:19:27']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n action varchar(255), -- example: ['view']\n option varchar(255), -- example: ['detail', 'page', 'search']\n path varchar(255), -- example: ['/detail', '/detail/', '/search_list/', '/search_input/']\n search_type varchar(255), -- example: ['Area-L-with-Job', 'Pref']\n);\n\nCREATE TABLE read_log (\n stamp varchar(255), -- example: ['2016-12-29 21:45:47', '2016-12-29 21:45:56']\n `session` varchar(255), -- example: ['afbd3d09', 'df6eb25d']\n action varchar(255), -- example: ['view', 'read-20%']\n url varchar(255), -- example: ['http://www.example.com/article?id=news34', 'http://www.example.com/article?id=news73']\n);\n\nCREATE TABLE form_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:04']\n `session` varchar(255), -- example: ['647219c7', '9b5f320f']\n action varchar(255), -- example: ['view']\n path varchar(255), -- example: ['/regist/input', '/cart/input']\n status varchar(255), -- example: ['error']\n);\n\nCREATE TABLE form_error_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:21']\n `session` varchar(255), -- example: ['004dc3ef', '00700be4']\n form varchar(255), -- example: ['regist', 'cart']\n field varchar(255), -- example: ['email', 'kana']\n error_type varchar(255), -- example: ['require', 'format_error']\n `value` varchar(255), -- example: ['101-', 'xxx---.co.jp']\n);\n\nCREATE TABLE action_log_with_ip (\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view']\n ip varchar(255), -- example: ['216.58.220.238', '98.139.183.24']\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE access_log (\n `session` varchar(255), -- example: ['98900e', '1cf768']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view', '1CwlSX']\n stamp varchar(255), -- example: ['/detail', '2016-01-01 18:00:00', '2016-01-02 20:00:00']\n);\n\nCREATE TABLE action_log_with_noise (\n stamp varchar(255),\n `session` varchar(255),\n action varchar(255),\n products varchar(255),\n url text,\n ip varchar(255),\n user_agent text\n);\n\nCREATE TABLE invalid_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'favorite']\n category varchar(255), -- example: ['action', 'drama']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n);\n\nCREATE TABLE mst_categories (\n id integer, -- example: [1, 2]\n name varchar(255), -- example: ['ladys_fashion', 'mens_fashion']\n stamp varchar(255), -- example: ['2016-01-01 10:00:00', '2016-02-01 10:00:00']\n);\n\nCREATE TABLE dup_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['click']\n products varchar(255), -- example: ['D001', 'D002']\n);\n\nCREATE TABLE mst_products_20161201 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE mst_products_20170101 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE app1_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Sato', 'Suzuki']\n email varchar(255), -- example: ['sato@example.com', 'suzuki@example.com']\n);\n\nCREATE TABLE app2_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Ito', 'Tanaka']\n phone varchar(255), -- example: ['080-xxxx-xxxx', '070-xxxx-xxxx']\n);\n\nCREATE TABLE mst_users_with_card_number (\n user_id varchar(255), -- example: ['U001', 'U002']\n card_number varchar(255), -- example: ['1234-xxxx-xxxx-xxxx', '5678-xxxx-xxxx-xxxx']\n);\n\nCREATE TABLE purchase_log (\n purchase_id integer, -- example: [10001, 10002]\n user_id varchar(255), -- example: ['U001', 'U002']\n amount integer, -- example: [200, 500]\n stamp varchar(255), -- example: ['2017-01-30 10:00:00', '2017-02-10 10:00:00']\n);\n\nCREATE TABLE product_sales (\n category_name varchar(255), -- example: ['dvd', 'cd']\n product_id varchar(255), -- example: ['D001', 'D002']\n sales integer, -- example: [50000, 20000]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList the three most common third actions users take after visiting the `/detail` page twice in a row, including each action's occurrence count.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the average salary for remote Data Analyst jobs requiring the top three most in-demand skills?", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['top', 'afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Job', 'Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['Job', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['Remote Data Analyst', 'Data Analyst Jobs', 'Data Analyst jobs', 'Data Analyst Job', 'JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['job', 'tyrus', 'ealasaid']\n last_name TEXT, -- example: ['skill', 'top', 'job', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['most', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Job', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Skill', 'Top', 'Job', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Remoted', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['top', 'afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Job', 'Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['Job', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['Remote Data Analyst', 'Data Analyst Jobs', 'Data Analyst jobs', 'Data Analyst Job', 'JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['job', 'tyrus', 'ealasaid']\n last_name TEXT, -- example: ['skill', 'top', 'job', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['most', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Job', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Skill', 'Top', 'Job', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Remoted', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the average salary for remote Data Analyst jobs requiring the top three most in-demand skills?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For our upcoming meeting, please provide the daily percentage change in trading volume for all tickers from August 1 to August 10, 2021. This trend analysis is crucial for our strategic planning.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor our upcoming meeting, please provide the daily percentage change in trading volume for all tickers from August 1 to August 10, 2021. This trend analysis is crucial for our strategic planning.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which Formula 1 drivers, during the 1950s, had seasons in which they did not change their constructors at the beginning and end of the year and participated in at least two different race rounds within those seasons?", "schema": "CREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich Formula 1 drivers, during the 1950s, had seasons in which they did not change their constructors at the beginning and end of the year and participated in at least two different race rounds within those seasons?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please find out how widespread the appeal of our top five actors is. What percentage of our customers have rented films featuring these actors?", "schema": "CREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease find out how widespread the appeal of our top five actors is. What percentage of our customers have rented films featuring these actors?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For each web page, how many unique user sessions either start or end there", "schema": "CREATE TABLE mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n sex varchar(255), -- example: ['M', 'F']\n birth_date varchar(255), -- example: ['1977-06-17', '1953-06-12']\n register_date varchar(255), -- example: ['2016-10-01', '2016-10-05']\n register_device varchar(255), -- example: ['pc', 'sp']\n withdraw_date varchar(255), -- example: ['2016-10-10']\n);\n\nCREATE TABLE action_log (\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'view']\n category varchar(255), -- example: ['drama', 'action']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n);\n\nCREATE TABLE activity_log (\n stamp varchar(255), -- example: ['2017-01-09 12:18:43', '2017-01-09 12:19:27']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n action varchar(255), -- example: ['view']\n option varchar(255), -- example: ['page', 'search']\n path varchar(255), -- example: ['/search_list/', '/search_input/']\n search_type varchar(255), -- example: ['Area-L-with-Job', 'Pref']\n);\n\nCREATE TABLE read_log (\n stamp varchar(255), -- example: ['2016-12-29 21:45:47', '2016-12-29 21:45:56']\n `session` varchar(255), -- example: ['afbd3d09', 'df6eb25d']\n action varchar(255), -- example: ['view', 'read-20%']\n url varchar(255), -- example: ['http://www.example.com/article?id=news34', 'http://www.example.com/article?id=news73']\n);\n\nCREATE TABLE form_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:04']\n `session` varchar(255), -- example: ['647219c7', '9b5f320f']\n action varchar(255), -- example: ['view']\n path varchar(255), -- example: ['/regist/input', '/cart/input']\n status varchar(255), -- example: ['error']\n);\n\nCREATE TABLE form_error_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:21']\n `session` varchar(255), -- example: ['004dc3ef', '00700be4']\n form varchar(255), -- example: ['regist', 'cart']\n field varchar(255), -- example: ['email', 'kana']\n error_type varchar(255), -- example: ['require', 'format_error']\n `value` varchar(255), -- example: ['101-', 'xxx---.co.jp']\n);\n\nCREATE TABLE action_log_with_ip (\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view']\n ip varchar(255), -- example: ['216.58.220.238', '98.139.183.24']\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE access_log (\n `session` varchar(255), -- example: ['98900e', '1cf768']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view', '1CwlSX']\n stamp varchar(255), -- example: ['2016-01-01 18:00:00', '2016-01-02 20:00:00']\n);\n\nCREATE TABLE action_log_with_noise (\n stamp varchar(255),\n `session` varchar(255),\n action varchar(255),\n products varchar(255),\n url text,\n ip varchar(255),\n user_agent text\n);\n\nCREATE TABLE invalid_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'favorite']\n category varchar(255), -- example: ['drama', 'action']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n);\n\nCREATE TABLE mst_categories (\n id integer, -- example: [1, 2]\n name varchar(255), -- example: ['ladys_fashion', 'mens_fashion']\n stamp varchar(255), -- example: ['2016-01-01 10:00:00', '2016-02-01 10:00:00']\n);\n\nCREATE TABLE dup_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['click']\n products varchar(255), -- example: ['D001', 'D002']\n);\n\nCREATE TABLE mst_products_20161201 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE mst_products_20170101 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE app1_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Sato', 'Suzuki']\n email varchar(255), -- example: ['sato@example.com', 'suzuki@example.com']\n);\n\nCREATE TABLE app2_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Ito', 'Tanaka']\n phone varchar(255), -- example: ['080-xxxx-xxxx', '070-xxxx-xxxx']\n);\n\nCREATE TABLE mst_users_with_card_number (\n user_id varchar(255), -- example: ['U001', 'U002']\n card_number varchar(255), -- example: ['1234-xxxx-xxxx-xxxx', '5678-xxxx-xxxx-xxxx']\n);\n\nCREATE TABLE purchase_log (\n purchase_id integer, -- example: [10001, 10002]\n user_id varchar(255), -- example: ['U001', 'U002']\n amount integer, -- example: [200, 500]\n stamp varchar(255), -- example: ['2017-01-30 10:00:00', '2017-02-10 10:00:00']\n);\n\nCREATE TABLE product_sales (\n category_name varchar(255), -- example: ['dvd', 'cd']\n product_id varchar(255), -- example: ['D001', 'D002']\n sales integer, -- example: [50000, 20000]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n sex varchar(255), -- example: ['M', 'F']\n birth_date varchar(255), -- example: ['1977-06-17', '1953-06-12']\n register_date varchar(255), -- example: ['2016-10-01', '2016-10-05']\n register_device varchar(255), -- example: ['pc', 'sp']\n withdraw_date varchar(255), -- example: ['2016-10-10']\n);\n\nCREATE TABLE action_log (\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'view']\n category varchar(255), -- example: ['drama', 'action']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n);\n\nCREATE TABLE activity_log (\n stamp varchar(255), -- example: ['2017-01-09 12:18:43', '2017-01-09 12:19:27']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n action varchar(255), -- example: ['view']\n option varchar(255), -- example: ['page', 'search']\n path varchar(255), -- example: ['/search_list/', '/search_input/']\n search_type varchar(255), -- example: ['Area-L-with-Job', 'Pref']\n);\n\nCREATE TABLE read_log (\n stamp varchar(255), -- example: ['2016-12-29 21:45:47', '2016-12-29 21:45:56']\n `session` varchar(255), -- example: ['afbd3d09', 'df6eb25d']\n action varchar(255), -- example: ['view', 'read-20%']\n url varchar(255), -- example: ['http://www.example.com/article?id=news34', 'http://www.example.com/article?id=news73']\n);\n\nCREATE TABLE form_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:04']\n `session` varchar(255), -- example: ['647219c7', '9b5f320f']\n action varchar(255), -- example: ['view']\n path varchar(255), -- example: ['/regist/input', '/cart/input']\n status varchar(255), -- example: ['error']\n);\n\nCREATE TABLE form_error_log (\n stamp varchar(255), -- example: ['2016-12-30 00:56:08', '2016-12-30 00:57:21']\n `session` varchar(255), -- example: ['004dc3ef', '00700be4']\n form varchar(255), -- example: ['regist', 'cart']\n field varchar(255), -- example: ['email', 'kana']\n error_type varchar(255), -- example: ['require', 'format_error']\n `value` varchar(255), -- example: ['101-', 'xxx---.co.jp']\n);\n\nCREATE TABLE action_log_with_ip (\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view']\n ip varchar(255), -- example: ['216.58.220.238', '98.139.183.24']\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE access_log (\n `session` varchar(255), -- example: ['98900e', '1cf768']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['view', '1CwlSX']\n stamp varchar(255), -- example: ['2016-01-01 18:00:00', '2016-01-02 20:00:00']\n);\n\nCREATE TABLE action_log_with_noise (\n stamp varchar(255),\n `session` varchar(255),\n action varchar(255),\n products varchar(255),\n url text,\n ip varchar(255),\n user_agent text\n);\n\nCREATE TABLE invalid_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:10:00', '2016-11-03 18:00:00']\n `session` varchar(255), -- example: ['0CVKaz', '1QceiB']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['purchase', 'favorite']\n category varchar(255), -- example: ['drama', 'action']\n products varchar(255), -- example: ['D001,D002', 'D001']\n amount integer, -- example: [2000, 1000]\n);\n\nCREATE TABLE mst_categories (\n id integer, -- example: [1, 2]\n name varchar(255), -- example: ['ladys_fashion', 'mens_fashion']\n stamp varchar(255), -- example: ['2016-01-01 10:00:00', '2016-02-01 10:00:00']\n);\n\nCREATE TABLE dup_action_log (\n stamp varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n `session` varchar(255), -- example: ['989004ea', '47db0370']\n user_id varchar(255), -- example: ['U001', 'U002']\n action varchar(255), -- example: ['click']\n products varchar(255), -- example: ['D001', 'D002']\n);\n\nCREATE TABLE mst_products_20161201 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE mst_products_20170101 (\n product_id varchar(255), -- example: ['A001', 'A002']\n name varchar(255), -- example: ['AAA', 'AAB']\n price integer, -- example: [3000, 4000]\n updated_at varchar(255), -- example: ['2016-11-03 18:00:00', '2016-11-03 19:00:00']\n);\n\nCREATE TABLE app1_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Sato', 'Suzuki']\n email varchar(255), -- example: ['sato@example.com', 'suzuki@example.com']\n);\n\nCREATE TABLE app2_mst_users (\n user_id varchar(255), -- example: ['U001', 'U002']\n name varchar(255), -- example: ['Ito', 'Tanaka']\n phone varchar(255), -- example: ['080-xxxx-xxxx', '070-xxxx-xxxx']\n);\n\nCREATE TABLE mst_users_with_card_number (\n user_id varchar(255), -- example: ['U001', 'U002']\n card_number varchar(255), -- example: ['1234-xxxx-xxxx-xxxx', '5678-xxxx-xxxx-xxxx']\n);\n\nCREATE TABLE purchase_log (\n purchase_id integer, -- example: [10001, 10002]\n user_id varchar(255), -- example: ['U001', 'U002']\n amount integer, -- example: [200, 500]\n stamp varchar(255), -- example: ['2017-01-30 10:00:00', '2017-02-10 10:00:00']\n);\n\nCREATE TABLE product_sales (\n category_name varchar(255), -- example: ['dvd', 'cd']\n product_id varchar(255), -- example: ['D001', 'D002']\n sales integer, -- example: [50000, 20000]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor each web page, how many unique user sessions either start or end there\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "In a scoring system where the first preference in musical styles receives 3 points, the second 2 points, and the third 1 point, calculate the total weighted score for each style ranked by at least one user. Determine the absolute differences between each style's weighted score and the average score across all styles.", "schema": "CREATE TABLE Agents (\n AgentID int, -- example: [1, 2]\n AgtFirstName nvarchar (25), -- example: ['William', 'Scott']\n AgtLastName nvarchar (25), -- example: ['Thompson', 'Bishop']\n AgtStreetAddress nvarchar (50), -- example: ['122 Spring River Drive', '66 Spring Valley Drive']\n AgtCity nvarchar (30), -- example: ['Redmond', 'Seattle']\n AgtState nvarchar (2), -- example: ['WA']\n AgtZipCode nvarchar (10), -- example: ['98006', '98033']\n AgtPhoneNumber nvarchar (15), -- example: ['555-2681', '555-2666']\n DateHired date, -- example: ['1997-05-15', '1998-02-05']\n Salary decimal(15, 2), -- example: [35000, 27000]\n CommissionRate float(24), -- example: [0.04, 0.05]\n PRIMARY KEY (AgentID)\n);\n\nCREATE TABLE Customers (\n CustomerID int, -- example: [10001, 10002]\n CustFirstName nvarchar (25), -- example: ['Doris', 'Deb']\n CustLastName nvarchar (25), -- example: ['Hartwig', 'Waldal']\n CustStreetAddress nvarchar (50), -- example: ['4726 - 11th Ave. N.E.', '908 W. Capital Way']\n CustCity nvarchar (30), -- example: ['Seattle', 'Tacoma']\n CustState nvarchar (2), -- example: ['WA']\n CustZipCode nvarchar (10), -- example: ['98002', '98006']\n CustPhoneNumber nvarchar (15), -- example: ['555-2671', '555-2496']\n PRIMARY KEY (CustomerID)\n);\n\nCREATE TABLE Engagements (\n EngagementNumber int, -- example: [2, 3]\n StartDate date, -- example: ['2017-09-02', '2017-09-11']\n EndDate date, -- example: ['2017-09-06', '2017-09-16']\n StartTime time, -- example: ['13:00:00', '20:00:00']\n StopTime time, -- example: ['15:00:00', '00:00:00']\n ContractPrice decimal(15, 2), -- example: [200, 590]\n CustomerID int, -- example: [10001, 10002]\n AgentID int, -- example: [1, 2]\n EntertainerID int, -- example: [1001, 1002]\n PRIMARY KEY (EngagementNumber),\n CONSTRAINT fk_engagements_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_engagements_agentid FOREIGN KEY (AgentID) REFERENCES Agents (AgentID),\n CONSTRAINT fk_engagements_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID)\n);\n\nCREATE TABLE Entertainer_Members (\n EntertainerID int, -- example: [1001, 1002]\n MemberID int, -- example: [101, 102]\n Status smallint, -- example: [1, 2]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_members_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_members_memberid FOREIGN KEY (MemberID) REFERENCES Members (MemberID)\n);\n\nCREATE TABLE Entertainer_Styles (\n EntertainerID int, -- example: [1001, 1002]\n StyleID smallint, -- example: [3, 4]\n StyleStrength smallint, -- example: [2, 1]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_styles_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_styles_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Entertainers (\n EntertainerID int, -- example: [1001, 1002]\n EntStageName nvarchar (50), -- example: ['Carol Peacock Trio', 'Topazz']\n EntSSN nvarchar (12), -- example: ['888-90-1121', '888-50-1061']\n EntStreetAddress nvarchar (50), -- example: ['4110 Old Redmond Rd.', '16 Maple Lane']\n EntCity nvarchar (30), -- example: ['Redmond', 'Auburn']\n EntState nvarchar (2), -- example: ['WA']\n EntZipCode nvarchar (10), -- example: ['98002', '98005']\n EntPhoneNumber nvarchar (15), -- example: ['555-2691', '555-2591']\n EntWebPage nvarchar (50), -- example: ['www.cptrio.com', 'www.topazz.com']\n EntEMailAddress nvarchar (50), -- example: ['carolp@cptrio.com', 'jv@myspring.com']\n DateEntered date, -- example: ['1997-05-24', '1996-02-14']\n PRIMARY KEY (EntertainerID)\n);\n\nCREATE TABLE Members (\n MemberID int, -- example: [101, 102]\n MbrFirstName nvarchar (25), -- example: ['David', 'Suzanne']\n MbrLastName nvarchar (25), -- example: ['Hamilton', 'Viescas']\n MbrPhoneNumber nvarchar (15), -- example: ['555-2701', '555-2686']\n Gender nvarchar (2), -- example: ['M', 'F']\n PRIMARY KEY (MemberID)\n);\n\nCREATE TABLE Musical_Preferences (\n CustomerID int, -- example: [10001, 10002]\n StyleID smallint, -- example: [1, 3]\n PreferenceSeq smallint, -- example: [2, 1]\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_musical_preferences_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_musical_preferences_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Musical_Styles (\n StyleID smallint, -- example: [1, 2]\n StyleName nvarchar (75), -- example: [\"40's Ballroom Music\", \"50's Music\"]\n PRIMARY KEY (StyleID)\n);\n\nCREATE TABLE ztblDays (\n DateField date, -- example: ['2017-01-01', '2017-01-02']\n PRIMARY KEY (DateField)\n);\n\nCREATE TABLE ztblMonths (\n MonthYear nvarchar (15), -- example: ['April 2017', 'April 2018']\n YearNumber smallint, -- example: [2017, 2018]\n MonthNumber smallint, -- example: [1, 2]\n MonthStart date, -- example: ['2017-01-01', '2017-02-01']\n MonthEnd date, -- example: ['2017-01-31', '2017-02-28']\n January smallint, -- example: [1, 0]\n February smallint, -- example: [0, 1]\n March smallint, -- example: [0, 1]\n April smallint, -- example: [0, 1]\n May smallint, -- example: [0, 1]\n June smallint, -- example: [0, 1]\n July smallint, -- example: [0, 1]\n August smallint, -- example: [0, 1]\n September smallint, -- example: [0, 1]\n October smallint, -- example: [0, 1]\n November smallint, -- example: [0, 1]\n December smallint, -- example: [0, 1]\n PRIMARY KEY (YearNumber)\n);\n\nCREATE TABLE ztblSkipLabels (\n LabelCount int, -- example: [1, 2]\n PRIMARY KEY (LabelCount)\n);\n\nCREATE TABLE ztblWeeks (\n WeekStart date, -- example: ['2017-01-01', '2017-01-08']\n WeekEnd date, -- example: ['2017-01-07', '2017-01-14']\n PRIMARY KEY (WeekStart)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Agents (\n AgentID int, -- example: [1, 2]\n AgtFirstName nvarchar (25), -- example: ['William', 'Scott']\n AgtLastName nvarchar (25), -- example: ['Thompson', 'Bishop']\n AgtStreetAddress nvarchar (50), -- example: ['122 Spring River Drive', '66 Spring Valley Drive']\n AgtCity nvarchar (30), -- example: ['Redmond', 'Seattle']\n AgtState nvarchar (2), -- example: ['WA']\n AgtZipCode nvarchar (10), -- example: ['98006', '98033']\n AgtPhoneNumber nvarchar (15), -- example: ['555-2681', '555-2666']\n DateHired date, -- example: ['1997-05-15', '1998-02-05']\n Salary decimal(15, 2), -- example: [35000, 27000]\n CommissionRate float(24), -- example: [0.04, 0.05]\n PRIMARY KEY (AgentID)\n);\n\nCREATE TABLE Customers (\n CustomerID int, -- example: [10001, 10002]\n CustFirstName nvarchar (25), -- example: ['Doris', 'Deb']\n CustLastName nvarchar (25), -- example: ['Hartwig', 'Waldal']\n CustStreetAddress nvarchar (50), -- example: ['4726 - 11th Ave. N.E.', '908 W. Capital Way']\n CustCity nvarchar (30), -- example: ['Seattle', 'Tacoma']\n CustState nvarchar (2), -- example: ['WA']\n CustZipCode nvarchar (10), -- example: ['98002', '98006']\n CustPhoneNumber nvarchar (15), -- example: ['555-2671', '555-2496']\n PRIMARY KEY (CustomerID)\n);\n\nCREATE TABLE Engagements (\n EngagementNumber int, -- example: [2, 3]\n StartDate date, -- example: ['2017-09-02', '2017-09-11']\n EndDate date, -- example: ['2017-09-06', '2017-09-16']\n StartTime time, -- example: ['13:00:00', '20:00:00']\n StopTime time, -- example: ['15:00:00', '00:00:00']\n ContractPrice decimal(15, 2), -- example: [200, 590]\n CustomerID int, -- example: [10001, 10002]\n AgentID int, -- example: [1, 2]\n EntertainerID int, -- example: [1001, 1002]\n PRIMARY KEY (EngagementNumber),\n CONSTRAINT fk_engagements_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_engagements_agentid FOREIGN KEY (AgentID) REFERENCES Agents (AgentID),\n CONSTRAINT fk_engagements_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID)\n);\n\nCREATE TABLE Entertainer_Members (\n EntertainerID int, -- example: [1001, 1002]\n MemberID int, -- example: [101, 102]\n Status smallint, -- example: [1, 2]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_members_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_members_memberid FOREIGN KEY (MemberID) REFERENCES Members (MemberID)\n);\n\nCREATE TABLE Entertainer_Styles (\n EntertainerID int, -- example: [1001, 1002]\n StyleID smallint, -- example: [3, 4]\n StyleStrength smallint, -- example: [2, 1]\n PRIMARY KEY (EntertainerID),\n CONSTRAINT fk_entertainer_styles_entertainerid FOREIGN KEY (EntertainerID) REFERENCES Entertainers (EntertainerID),\n CONSTRAINT fk_entertainer_styles_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Entertainers (\n EntertainerID int, -- example: [1001, 1002]\n EntStageName nvarchar (50), -- example: ['Carol Peacock Trio', 'Topazz']\n EntSSN nvarchar (12), -- example: ['888-90-1121', '888-50-1061']\n EntStreetAddress nvarchar (50), -- example: ['4110 Old Redmond Rd.', '16 Maple Lane']\n EntCity nvarchar (30), -- example: ['Redmond', 'Auburn']\n EntState nvarchar (2), -- example: ['WA']\n EntZipCode nvarchar (10), -- example: ['98002', '98005']\n EntPhoneNumber nvarchar (15), -- example: ['555-2691', '555-2591']\n EntWebPage nvarchar (50), -- example: ['www.cptrio.com', 'www.topazz.com']\n EntEMailAddress nvarchar (50), -- example: ['carolp@cptrio.com', 'jv@myspring.com']\n DateEntered date, -- example: ['1997-05-24', '1996-02-14']\n PRIMARY KEY (EntertainerID)\n);\n\nCREATE TABLE Members (\n MemberID int, -- example: [101, 102]\n MbrFirstName nvarchar (25), -- example: ['David', 'Suzanne']\n MbrLastName nvarchar (25), -- example: ['Hamilton', 'Viescas']\n MbrPhoneNumber nvarchar (15), -- example: ['555-2701', '555-2686']\n Gender nvarchar (2), -- example: ['M', 'F']\n PRIMARY KEY (MemberID)\n);\n\nCREATE TABLE Musical_Preferences (\n CustomerID int, -- example: [10001, 10002]\n StyleID smallint, -- example: [1, 3]\n PreferenceSeq smallint, -- example: [2, 1]\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_musical_preferences_customerid FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),\n CONSTRAINT fk_musical_preferences_styleid FOREIGN KEY (StyleID) REFERENCES Musical_Styles (StyleID)\n);\n\nCREATE TABLE Musical_Styles (\n StyleID smallint, -- example: [1, 2]\n StyleName nvarchar (75), -- example: [\"40's Ballroom Music\", \"50's Music\"]\n PRIMARY KEY (StyleID)\n);\n\nCREATE TABLE ztblDays (\n DateField date, -- example: ['2017-01-01', '2017-01-02']\n PRIMARY KEY (DateField)\n);\n\nCREATE TABLE ztblMonths (\n MonthYear nvarchar (15), -- example: ['April 2017', 'April 2018']\n YearNumber smallint, -- example: [2017, 2018]\n MonthNumber smallint, -- example: [1, 2]\n MonthStart date, -- example: ['2017-01-01', '2017-02-01']\n MonthEnd date, -- example: ['2017-01-31', '2017-02-28']\n January smallint, -- example: [1, 0]\n February smallint, -- example: [0, 1]\n March smallint, -- example: [0, 1]\n April smallint, -- example: [0, 1]\n May smallint, -- example: [0, 1]\n June smallint, -- example: [0, 1]\n July smallint, -- example: [0, 1]\n August smallint, -- example: [0, 1]\n September smallint, -- example: [0, 1]\n October smallint, -- example: [0, 1]\n November smallint, -- example: [0, 1]\n December smallint, -- example: [0, 1]\n PRIMARY KEY (YearNumber)\n);\n\nCREATE TABLE ztblSkipLabels (\n LabelCount int, -- example: [1, 2]\n PRIMARY KEY (LabelCount)\n);\n\nCREATE TABLE ztblWeeks (\n WeekStart date, -- example: ['2017-01-01', '2017-01-08']\n WeekEnd date, -- example: ['2017-01-07', '2017-01-14']\n PRIMARY KEY (WeekStart)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIn a scoring system where the first preference in musical styles receives 3 points, the second 2 points, and the third 1 point, calculate the total weighted score for each style ranked by at least one user. Determine the absolute differences between each style's weighted score and the average score across all styles.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "I need an analysis of our sales performance around mid-June for the years 2018, 2019, and 2020. Specifically, calculate the percentage change in sales between the four weeks leading up to June 15 and the four weeks following June 15 for each year.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nI need an analysis of our sales performance around mid-June for the years 2018, 2019, and 2020. Specifically, calculate the percentage change in sales between the four weeks leading up to June 15 and the four weeks following June 15 for each year.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please provide a list of the top three revenue-generating films for each actor, along with the average revenue per actor in those films, calculated by dividing the total film revenue equally among the actors for each film.", "schema": "CREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease provide a list of the top three revenue-generating films for each actor, along with the average revenue per actor in those films, calculated by dividing the total film revenue equally among the actors for each film.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you find out the average percentage of the total lifetime sales (LTV) that occur in the first 7 and 30 days after a customer's initial purchase? Also, include the average total lifetime sales (LTV). Please exclude customers with zero lifetime sales. The percentage should be shown with %, and the 7- and 30-day periods should be based on the exact number of hours-minutes-seconds, not calendar days.", "schema": "CREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['ZERO', 'PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['DAY', 'ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['ZERO', 'PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['DAY', 'ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you find out the average percentage of the total lifetime sales (LTV) that occur in the first 7 and 30 days after a customer's initial purchase? Also, include the average total lifetime sales (LTV). Please exclude customers with zero lifetime sales. The percentage should be shown with %, and the 7- and 30-day periods should be based on the exact number of hours-minutes-seconds, not calendar days.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Calculate the average first and last rounds of races missed by drivers each year. Only include drivers who missed fewer than three races annually and switched teams between their first and last missed races", "schema": "CREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE circuits (\n circuit_id INT(11), -- example: [1, 2]\n circuit_ref VARCHAR(255), -- example: ['albert_park', 'sepang']\n name VARCHAR(255), -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location VARCHAR(255), -- example: ['Melbourne', 'Kuala Lumpur']\n country VARCHAR(255), -- example: ['Australia', 'Malaysia']\n lat FLOAT, -- example: [-37.8497, 2.76083]\n lng FLOAT, -- example: [144.968, 101.738]\n alt INT(11), -- example: [10, 18]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n PRIMARY KEY (circuit_id)\n);\n\nCREATE TABLE constructor_results (\n constructor_results_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n status VARCHAR(255), -- example: ['D']\n PRIMARY KEY (constructor_results_id)\n);\n\nCREATE TABLE constructor_standings (\n constructor_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n constructor_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [14.0, 8.0]\n `position` INT(11), -- example: [1, 3]\n position_text VARCHAR(255), -- example: ['1', '3']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (constructor_standings_id)\n);\n\nCREATE TABLE constructors (\n constructor_id INT(11), -- example: [1, 2]\n constructor_ref VARCHAR(255), -- example: ['mclaren', 'bmw_sauber']\n name VARCHAR(255), -- example: ['McLaren', 'BMW Sauber']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n PRIMARY KEY (constructor_id)\n);\n\nCREATE TABLE driver_standings (\n driver_standings_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n wins INT(11), -- example: [1, 0]\n PRIMARY KEY (driver_standings_id)\n);\n\nCREATE TABLE drivers (\n driver_id INT(11), -- example: [1, 2]\n driver_ref VARCHAR(255), -- example: ['driver', 'hamilton', 'heidfeld']\n number INT(11), -- example: [44, 6]\n code VARCHAR(3), -- example: ['HAM', 'HEI']\n forename VARCHAR(255), -- example: ['Lewis', 'Nick']\n surname VARCHAR(255), -- example: ['Driver', 'Hamilton', 'Heidfeld']\n dob DATE, -- example: ['1985-01-07', '1977-05-10']\n nationality VARCHAR(255), -- example: ['British', 'German']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE lap_times (\n race_id INT(11), -- example: [1, 2]\n driver_id INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 2]\n `position` INT(11), -- example: [1, 3]\n `time` VARCHAR(255), -- example: ['1:38.109', '1:33.006']\n milliseconds INT(11), -- example: [98109, 93006]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE pit_stops (\n race_id INT(11), -- example: [841, 842]\n driver_id INT(11), -- example: [1, 2]\n stop INT(11), -- example: [1, 2]\n lap INT(11), -- example: [1, 11]\n `time` TIME, -- example: ['17:05:23', '17:05:52']\n duration VARCHAR(255), -- example: ['26.898', '25.021']\n milliseconds INT(11), -- example: [26898, 25021]\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE qualifying (\n qualify_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 9]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 4]\n `position` INT(11), -- example: [1, 2]\n q1 VARCHAR(255), -- example: ['1:26.572', '1:26.103']\n q2 VARCHAR(255), -- example: ['1:25.187', '1:25.315']\n q3 VARCHAR(255), -- example: ['1:26.714', '1:26.869']\n PRIMARY KEY (qualify_id)\n);\n\nCREATE TABLE races (\n race_id INT(11), -- example: [1, 2]\n `year` INT(11), -- example: [2009, 2008]\n round INT(11), -- example: [1, 2]\n circuit_id INT(11), -- example: [1, 2]\n name VARCHAR(255), -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` DATE, -- example: ['2009-03-29', '2009-04-05']\n `time` TIME, -- example: ['06:00:00', '09:00:00']\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp1_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n fp2_date VARCHAR(255), -- example: ['2021-04-16', '2022-03-18']\n fp2_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n fp3_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n fp3_time VARCHAR(255), -- example: ['12:00:00', '14:00:00']\n quali_date VARCHAR(255), -- example: ['2021-04-17', '2022-03-19']\n quali_time VARCHAR(255), -- example: ['15:00:00', '17:00:00']\n sprint_date VARCHAR(255), -- example: ['2021-07-17', '2021-09-11']\n sprint_time VARCHAR(255), -- example: ['14:30:00', '19:30:00']\n PRIMARY KEY (race_id)\n);\n\nCREATE TABLE results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [18, 19]\n driver_id INT(11), -- example: [1, 2]\n constructor_id INT(11), -- example: [1, 2]\n number INT(11), -- example: [22, 3]\n grid INT(11), -- example: [1, 5]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [10.0, 8.0]\n laps INT(11), -- example: [58, 57]\n `time` VARCHAR(255), -- example: ['1:34:50.616', '+5.478']\n milliseconds INT(11), -- example: [5690616, 5696094]\n fastest_lap INT(11), -- example: [39, 41]\n rank INT(11), -- example: [2, 3]\n fastest_lap_time VARCHAR(255), -- example: ['1:27.452', '1:27.739']\n fastest_lap_speed VARCHAR(255), -- example: ['218.300', '217.586']\n status_id INT(11), -- example: [1, 11]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE seasons (\n `year` INT(11), -- example: [1950, 1951]\n url VARCHAR(255), -- example: ['http://en.wikipedia.org/wiki/2009_Formul', 'http://en.wikipedia.org/wiki/2008_Formul']\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE status (\n status_id INT(11), -- example: [1, 2]\n status VARCHAR(255), -- example: ['Finished', 'Disqualified']\n PRIMARY KEY (status_id)\n);\n\nCREATE TABLE sprint_results (\n result_id INT(11), -- example: [1, 2]\n race_id INT(11), -- example: [1061, 1065]\n driver_id INT(11), -- example: [830, 1]\n constructor_id INT(11), -- example: [9, 131]\n number INT(11), -- example: [33, 44]\n grid INT(11), -- example: [2, 1]\n `position` INT(11), -- example: [1, 2]\n position_text VARCHAR(255), -- example: ['1', '2']\n position_order INT(11), -- example: [1, 2]\n points FLOAT, -- example: [3.0, 2.0]\n laps INT(11), -- example: [17, 16]\n `time` VARCHAR(255), -- example: ['25:38.426', '+1.430']\n milliseconds INT(11), -- example: [1538426, 1539856]\n fastest_lap INT(11), -- example: [14, 17]\n fastest_lap_time VARCHAR(255), -- example: ['1:30.013', '1:29.937']\n fastest_lap_speed VARCHAR(255),\n status_id INT(11), -- example: [1, 76]\n PRIMARY KEY (result_id)\n);\n\nCREATE TABLE short_grand_prix_names (\n full_name VARCHAR(255), -- example: ['70th Anniversary Grand Prix', 'Abu Dhabi Grand Prix']\n short_name VARCHAR(255), -- example: ['Australia', 'Malaysia']\n PRIMARY KEY (full_name)\n);\n\nCREATE TABLE short_constructor_names (\n constructor_ref VARCHAR(255), -- example: ['alphatauri', 'alpine']\n short_name VARCHAR(255), -- example: ['Alpha Tauri', 'Alpine']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE liveries (\n constructor_ref VARCHAR(255), -- example: ['alfa', 'alphatauri']\n start_year INT(11), -- example: [2019, 2020]\n end_year INT(11), -- example: [2002, 2005]\n primary_hex_code VARCHAR(255), -- example: ['#900000', '#000000']\n PRIMARY KEY (constructor_ref)\n);\n\nCREATE TABLE tdr_overrides (\n `year` INT(11), -- example: [2004, 2007]\n constructor_ref VARCHAR(255), -- example: ['toyota', 'mclaren']\n driver_ref VARCHAR(255), -- example: ['matta', 'panis']\n team_driver_rank INT(11), -- example: [1, 2]\n PRIMARY KEY (`year`)\n);\n\nCREATE TABLE circuits_ext (\n circuit_id INT, -- example: [1, 2]\n circuit_ref TEXT, -- example: ['albert_park', 'sepang']\n name TEXT, -- example: ['Albert Park Grand Prix Circuit', 'Sepang International Circuit']\n location TEXT, -- example: ['Melbourne', 'Kuala Lumpur']\n country TEXT, -- example: ['Australia', 'Malaysia']\n lat REAL, -- example: [-37.8497, 2.76083]\n lng REAL, -- example: [144.968, 101.738]\n alt INT, -- example: [10, 18]\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Melbourne_G', 'http://en.wikipedia.org/wiki/Sepang_Inte']\n last_race_year TEXT, -- example: [2024, 2017]\n number_of_races TEXT, -- example: [27, 19]\n);\n\nCREATE TABLE constructors_ext (\n constructor_id INT, -- example: [1, 2]\n constructor_ref TEXT, -- example: ['mclaren', 'bmw_sauber']\n name TEXT, -- example: ['McLaren', 'BMW Sauber']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber']\n short_name TEXT, -- example: ['McLaren', 'BMW Sauber']\n);\n\nCREATE TABLE drivers_ext (\n driver_id INT, -- example: [1, 2]\n driver_ref TEXT, -- example: ['driver', 'hamilton', 'heidfeld']\n number INT, -- example: [44, 6]\n code TEXT, -- example: ['HAM', 'HEI']\n forename TEXT, -- example: ['Lewis', 'Nick']\n surname TEXT, -- example: ['Driver', 'Hamilton', 'Heidfeld']\n full_name TEXT, -- example: ['Lewis Hamilton', 'Nick Heidfeld']\n dob NUM, -- example: ['1985-01-07', '1977-05-10']\n nationality TEXT, -- example: ['British', 'German']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/Lewis_Hamil', 'http://en.wikipedia.org/wiki/Nick_Heidfe']\n);\n\nCREATE TABLE driver_standings_ext (\n driver_standings_id INT, -- example: [1, 2]\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [1, 2]\n points REAL, -- example: [10.0, 8.0]\n `position` INT, -- example: [1, 2]\n position_text TEXT, -- example: ['1', '2']\n wins INT, -- example: [1, 0]\n);\n\nCREATE TABLE lap_times_ext (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [1, 2]\n `position` INT, -- example: [13, 12]\n `time` TEXT, -- example: ['1:49.088', '1:33.740']\n milliseconds INT, -- example: [109088, 93740]\n seconds REAL, -- example: [109.088, 93.74]\n running_milliseconds TEXT, -- example: [109088, 202828]\n);\n\nCREATE TABLE lap_time_stats (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n avg_milliseconds TEXT, -- example: [97563.75862068965, 97635.6724137931]\n avg_seconds TEXT, -- example: [97.56375862068965, 97.63567241379309]\n stdev_milliseconds TEXT, -- example: [15927.054702406851, 14152.06249911631]\n stdev_seconds TEXT, -- example: [15.927054702406851, 14.152062499116306]\n);\n\nCREATE TABLE races_ext (\n race_id INT, -- example: [1, 2]\n `year` INT, -- example: [2009, 2008]\n round INT, -- example: [1, 2]\n circuit_id INT, -- example: [1, 2]\n name TEXT, -- example: ['Australian Grand Prix', 'Malaysian Grand Prix']\n `date` NUM, -- example: ['2009-03-29', '2009-04-05']\n `time` NUM, -- example: ['06:00:00', '09:00:00']\n url TEXT, -- example: ['http://en.wikipedia.org/wiki/2009_Austra', 'http://en.wikipedia.org/wiki/2009_Malays']\n fp1_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp1_time TEXT, -- example: ['12:00:00', '14:00:00']\n fp2_date TEXT, -- example: ['2021-11-19', '2021-03-26']\n fp2_time TEXT, -- example: ['15:00:00', '17:00:00']\n fp3_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n fp3_time TEXT, -- example: ['12:00:00', '14:00:00']\n quali_date TEXT, -- example: ['2021-11-20', '2021-03-27']\n quali_time TEXT, -- example: ['15:00:00', '17:00:00']\n sprint_date TEXT, -- example: ['2021-07-17', '2021-09-11']\n sprint_time TEXT, -- example: ['14:30:00', '19:30:00']\n is_pit_data_available TEXT, -- example: [0, 1]\n short_name TEXT, -- example: ['Australia', 'Malaysia']\n has_sprint TEXT, -- example: [0, 1]\n max_points TEXT, -- example: [10, 9]\n);\n\nCREATE TABLE team_driver_ranks (\n `year` INT, -- example: [1950, 1951]\n constructor_id INT, -- example: [6, 51]\n constructor_ref TEXT, -- example: ['ferrari', 'alfa']\n driver_id INT, -- example: [647, 687]\n driver_ref TEXT, -- example: ['driver', 'ascari', 'whitehead']\n team_driver_rank TEXT, -- example: [1, 2]\n);\n\nCREATE TABLE drives (\n `year` INT, -- example: [1950, 1951]\n driver_id INT, -- example: [427, 498]\n drive_id TEXT, -- example: [1, 2]\n constructor_id INT, -- example: [141, 105]\n first_round INT, -- example: [2, 4]\n last_round INT, -- example: [7, 6]\n is_first_drive_of_season TEXT, -- example: [1, 0]\n is_final_drive_of_season TEXT, -- example: [1, 0]\n);\n\nCREATE TABLE retirements (\n race_id INT, -- example: [18, 19]\n driver_id INT, -- example: [7, 8]\n lap TEXT, -- example: [56, 54]\n position_order INT, -- example: [7, 8]\n status_id INT, -- example: [5, 4]\n retirement_type TEXT, -- example: ['Retirement (Mechanical Problem)', 'Retirement (Driver Error)']\n);\n\nCREATE TABLE lap_positions (\n race_id INT, -- example: [1, 2]\n driver_id INT, -- example: [1, 2]\n lap INT, -- example: [0, 1]\n `position` INT, -- example: [18, 13]\n lap_type TEXT, -- example: ['Race', 'Starting Position - Grid Drop']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCalculate the average first and last rounds of races missed by drivers each year. Only include drivers who missed fewer than three races annually and switched teams between their first and last missed races\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which state has the highest number of female legislators whose term end dates fall on December 31st, and what is that count? Please provide state name abbreviation.", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Fall', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['please', 'count', 'state', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['female', 'non-binary']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['December', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'has', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Please', 'Count', 'State', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Female', 'Agender']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Fall', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['please', 'count', 'state', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['female', 'non-binary']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['December', 'January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['date', 'has', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Please', 'Count', 'State', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Female', 'Agender']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich state has the highest number of female legislators whose term end dates fall on December 31st, and what is that count? Please provide state name abbreviation.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the annual retention rate for Colorado legislators who started their first term between 1917 and 1999, tracked up to 20 years later?", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Colorado', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Colorado', 'Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['starte', 'start', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['colorado', 'ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['colorado', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Colorado', 'Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Starte', 'Start', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Between', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Colorado', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Colorado', 'Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['starte', 'start', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['colorado', 'ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['colorado', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Colorado', 'Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['Starte', 'Start', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Between', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the annual retention rate for Colorado legislators who started their first term between 1917 and 1999, tracked up to 20 years later?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you analyze the yearly average cost of Bitcoin purchases by region, excluding the first year's data? Rank the regions based on these averages each year and calculate the annual percentage change in cost.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['purchase', 'deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Purchase', 'Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['purchase', 'deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Purchase', 'Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you analyze the yearly average cost of Bitcoin purchases by region, excluding the first year's data? Rank the regions based on these averages each year and calculate the annual percentage change in cost.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "List the bowlers, match number, game number, handicap score, tournament date, and location for only those bowlers who won their game with a handicap score of 190 or less at Thunderbird Lanes, Totem Lanes, and Bolero Lanes.", "schema": "CREATE TABLE Bowler_Scores (\n MatchID int, -- example: [1, 2]\n GameNumber smallint, -- example: [1, 2]\n BowlerID int, -- example: [1, 2]\n RawScore smallint, -- example: [146, 166]\n HandiCapScore smallint, -- example: [192, 205]\n WonGame BOOLEAN, -- example: [0, 1]\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_bowler_scores_matchid FOREIGN KEY (MatchID) REFERENCES Match_Games (MatchID),\n CONSTRAINT fk_bowler_scores_gamenumber FOREIGN KEY (GameNumber) REFERENCES Match_Games (GameNumber),\n CONSTRAINT fk_bowler_scores_bowlerid FOREIGN KEY (BowlerID) REFERENCES Bowlers (BowlerID)\n);\n\nCREATE TABLE Bowler_Scores_Archive (\n MatchID int,\n GameNumber smallint,\n BowlerID int,\n RawScore smallint,\n HandiCapScore smallint,\n WonGame BOOLEAN,\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_bowler_scores_archive_matchid FOREIGN KEY (MatchID) REFERENCES Match_Games_Archive (MatchID),\n CONSTRAINT fk_bowler_scores_archive_gamenumber FOREIGN KEY (GameNumber) REFERENCES Match_Games_Archive (GameNumber)\n);\n\nCREATE TABLE Bowlers (\n BowlerID INTEGER, -- example: [1, 2]\n BowlerLastName TEXT, -- example: ['Black', 'Clothier']\n BowlerFirstName TEXT, -- example: ['Barbara', 'David']\n BowlerMiddleInit TEXT, -- example: ['A', 'J']\n BowlerAddress TEXT, -- example: ['67 Willow Drive', '2957 W 33rd']\n BowlerCity TEXT, -- example: ['Bothell', 'Ballard']\n BowlerState TEXT, -- example: ['WA']\n BowlerZip TEXT, -- example: ['98014', '98154']\n BowlerPhoneNumber TEXT, -- example: ['(206) 555-9876', '(206) 555-7854']\n TeamID int, -- example: [1, 2]\n BowlerTotalPins int, -- example: [5790, 6152]\n BowlerGamesBowled int, -- example: [39, 0]\n BowlerCurrentAverage smallint, -- example: [148, 158]\n BowlerCurrentHcp smallint, -- example: [47, 38]\n PRIMARY KEY (BowlerID),\n CONSTRAINT fk_bowlers_teamid FOREIGN KEY (TeamID) REFERENCES Teams (TeamID)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Tournaments', 'Bowlers']\n seq TEXT, -- example: [20, 34]\n);\n\nCREATE TABLE Match_Games (\n MatchID int, -- example: [1, 2]\n GameNumber smallint, -- example: [1, 2]\n WinningTeamID int, -- example: [1, 2]\n PRIMARY KEY (MatchID)\n);\n\nCREATE TABLE Match_Games_Archive (\n MatchID int,\n GameNumber smallint,\n WinningTeamID int,\n PRIMARY KEY (MatchID)\n);\n\nCREATE TABLE Teams (\n TeamID INTEGER, -- example: [1, 2]\n TeamName TEXT, -- example: ['Marlins', 'Sharks']\n CaptainID int, -- example: [2, 5]\n PRIMARY KEY (TeamID)\n);\n\nCREATE TABLE Tournaments (\n TourneyID INTEGER, -- example: [1, 2]\n TourneyDate DATE, -- example: ['2017-09-04', '2017-09-11']\n TourneyLocation TEXT, -- example: ['Thunderbird Lanes', 'Bolero Lanes', 'Totem Lanes', 'Red Rooster Lanes']\n PRIMARY KEY (TourneyID)\n);\n\nCREATE TABLE Tournaments_Archive (\n TourneyID int,\n TourneyDate DATE,\n TourneyLocation TEXT,\n PRIMARY KEY (TourneyID)\n);\n\nCREATE TABLE Tourney_Matches (\n MatchID INTEGER, -- example: [1, 2]\n TourneyID int, -- example: [1, 2]\n Lanes TEXT, -- example: ['01-02', '03-04']\n OddLaneTeamID int, -- example: [1, 2]\n EvenLaneTeamID int, -- example: [1, 2]\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_tourney_matches_tourneyid FOREIGN KEY (TourneyID) REFERENCES Tournaments (TourneyID),\n CONSTRAINT fk_tourney_matches_oddlaneteamid FOREIGN KEY (OddLaneTeamID) REFERENCES Teams (TeamID),\n CONSTRAINT fk_tourney_matches_evenlaneteamid FOREIGN KEY (EvenLaneTeamID) REFERENCES Teams (TeamID)\n);\n\nCREATE TABLE Tourney_Matches_Archive (\n MatchID int,\n TourneyID int,\n Lanes TEXT,\n OddLaneTeamID int,\n EvenLaneTeamID int,\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_tourney_matches_archive_tourneyid FOREIGN KEY (TourneyID) REFERENCES Tournaments_Archive (TourneyID)\n);\n\nCREATE TABLE WAZips (\n ZIP TEXT, -- example: ['98001', '98002']\n City TEXT, -- example: ['Auburn', 'Federal Way']\n State TEXT, -- example: ['WA']\n PRIMARY KEY (ZIP)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Bowler_Scores (\n MatchID int, -- example: [1, 2]\n GameNumber smallint, -- example: [1, 2]\n BowlerID int, -- example: [1, 2]\n RawScore smallint, -- example: [146, 166]\n HandiCapScore smallint, -- example: [192, 205]\n WonGame BOOLEAN, -- example: [0, 1]\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_bowler_scores_matchid FOREIGN KEY (MatchID) REFERENCES Match_Games (MatchID),\n CONSTRAINT fk_bowler_scores_gamenumber FOREIGN KEY (GameNumber) REFERENCES Match_Games (GameNumber),\n CONSTRAINT fk_bowler_scores_bowlerid FOREIGN KEY (BowlerID) REFERENCES Bowlers (BowlerID)\n);\n\nCREATE TABLE Bowler_Scores_Archive (\n MatchID int,\n GameNumber smallint,\n BowlerID int,\n RawScore smallint,\n HandiCapScore smallint,\n WonGame BOOLEAN,\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_bowler_scores_archive_matchid FOREIGN KEY (MatchID) REFERENCES Match_Games_Archive (MatchID),\n CONSTRAINT fk_bowler_scores_archive_gamenumber FOREIGN KEY (GameNumber) REFERENCES Match_Games_Archive (GameNumber)\n);\n\nCREATE TABLE Bowlers (\n BowlerID INTEGER, -- example: [1, 2]\n BowlerLastName TEXT, -- example: ['Black', 'Clothier']\n BowlerFirstName TEXT, -- example: ['Barbara', 'David']\n BowlerMiddleInit TEXT, -- example: ['A', 'J']\n BowlerAddress TEXT, -- example: ['67 Willow Drive', '2957 W 33rd']\n BowlerCity TEXT, -- example: ['Bothell', 'Ballard']\n BowlerState TEXT, -- example: ['WA']\n BowlerZip TEXT, -- example: ['98014', '98154']\n BowlerPhoneNumber TEXT, -- example: ['(206) 555-9876', '(206) 555-7854']\n TeamID int, -- example: [1, 2]\n BowlerTotalPins int, -- example: [5790, 6152]\n BowlerGamesBowled int, -- example: [39, 0]\n BowlerCurrentAverage smallint, -- example: [148, 158]\n BowlerCurrentHcp smallint, -- example: [47, 38]\n PRIMARY KEY (BowlerID),\n CONSTRAINT fk_bowlers_teamid FOREIGN KEY (TeamID) REFERENCES Teams (TeamID)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Tournaments', 'Bowlers']\n seq TEXT, -- example: [20, 34]\n);\n\nCREATE TABLE Match_Games (\n MatchID int, -- example: [1, 2]\n GameNumber smallint, -- example: [1, 2]\n WinningTeamID int, -- example: [1, 2]\n PRIMARY KEY (MatchID)\n);\n\nCREATE TABLE Match_Games_Archive (\n MatchID int,\n GameNumber smallint,\n WinningTeamID int,\n PRIMARY KEY (MatchID)\n);\n\nCREATE TABLE Teams (\n TeamID INTEGER, -- example: [1, 2]\n TeamName TEXT, -- example: ['Marlins', 'Sharks']\n CaptainID int, -- example: [2, 5]\n PRIMARY KEY (TeamID)\n);\n\nCREATE TABLE Tournaments (\n TourneyID INTEGER, -- example: [1, 2]\n TourneyDate DATE, -- example: ['2017-09-04', '2017-09-11']\n TourneyLocation TEXT, -- example: ['Thunderbird Lanes', 'Bolero Lanes', 'Totem Lanes', 'Red Rooster Lanes']\n PRIMARY KEY (TourneyID)\n);\n\nCREATE TABLE Tournaments_Archive (\n TourneyID int,\n TourneyDate DATE,\n TourneyLocation TEXT,\n PRIMARY KEY (TourneyID)\n);\n\nCREATE TABLE Tourney_Matches (\n MatchID INTEGER, -- example: [1, 2]\n TourneyID int, -- example: [1, 2]\n Lanes TEXT, -- example: ['01-02', '03-04']\n OddLaneTeamID int, -- example: [1, 2]\n EvenLaneTeamID int, -- example: [1, 2]\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_tourney_matches_tourneyid FOREIGN KEY (TourneyID) REFERENCES Tournaments (TourneyID),\n CONSTRAINT fk_tourney_matches_oddlaneteamid FOREIGN KEY (OddLaneTeamID) REFERENCES Teams (TeamID),\n CONSTRAINT fk_tourney_matches_evenlaneteamid FOREIGN KEY (EvenLaneTeamID) REFERENCES Teams (TeamID)\n);\n\nCREATE TABLE Tourney_Matches_Archive (\n MatchID int,\n TourneyID int,\n Lanes TEXT,\n OddLaneTeamID int,\n EvenLaneTeamID int,\n PRIMARY KEY (MatchID),\n CONSTRAINT fk_tourney_matches_archive_tourneyid FOREIGN KEY (TourneyID) REFERENCES Tournaments_Archive (TourneyID)\n);\n\nCREATE TABLE WAZips (\n ZIP TEXT, -- example: ['98001', '98002']\n City TEXT, -- example: ['Auburn', 'Federal Way']\n State TEXT, -- example: ['WA']\n PRIMARY KEY (ZIP)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList the bowlers, match number, game number, handicap score, tournament date, and location for only those bowlers who won their game with a handicap score of 190 or less at Thunderbird Lanes, Totem Lanes, and Bolero Lanes.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Calculate the total income from Meat Lovers pizzas priced at $12 and Vegetarian pizzas at $10. Include any extra toppings charged at $1 each. Ensure that canceled orders are filtered out. How much money has Pizza Runner earned in total?", "schema": "CREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Vegetarian', 'Meatlovers']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['vegetarian', 'calculate', 'filtered', 'canceled', 'toppings', 'charged']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Vegetarian', 'Meatlovers']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['vegetarian', 'calculate', 'filtered', 'canceled', 'toppings', 'charged']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCalculate the total income from Meat Lovers pizzas priced at $12 and Vegetarian pizzas at $10. Include any extra toppings charged at $1 each. Ensure that canceled orders are filtered out. How much money has Pizza Runner earned in total?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "I'm interested in knowing the proportion of films that had exclusively female actors for each year. Show the proportion of female-actor-only films and the total number of all films for each of those years.", "schema": "CREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Female', 'Male']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Female', 'Male']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nI'm interested in knowing the proportion of films that had exclusively female actors for each year. Show the proportion of female-actor-only films and the total number of all films for each of those years.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you segment Italian customers into ten profitability buckets for December 2021, using equal profit intervals, and calculate the following for each bucket in December 2021: the number of customers, maximum profit, and minimum profit?", "schema": "CREATE TABLE countries (\n country_id INTEGER, -- example: [52769, 52770]\n country_iso_code CHAR(2), -- example: ['US', 'SG', 'IT']\n country_name TEXT, -- example: ['Singapore', 'Italy']\n country_subregion TEXT, -- example: ['Asia', 'Western Europe']\n country_subregion_id INTEGER, -- example: [52793, 52799]\n country_region TEXT, -- example: ['Asia', 'Europe']\n country_region_id INTEGER, -- example: [52802, 52803]\n country_total TEXT, -- example: ['World total']\n country_total_id INTEGER, -- example: [52806]\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE customers (\n cust_id INTEGER, -- example: [1, 2]\n cust_first_name TEXT, -- example: ['Abigail', 'Anne']\n cust_last_name TEXT, -- example: ['Kessel', 'Koch']\n cust_gender CHAR(1), -- example: ['M', 'F']\n cust_year_of_birth INTEGER, -- example: [1957, 1968]\n cust_marital_status TEXT, -- example: ['single', 'married']\n cust_street_address TEXT, -- example: ['7 South 3rd Circle', '7 South Airway Circle']\n cust_postal_code TEXT, -- example: ['30828', '86319']\n cust_city TEXT, -- example: ['Downham Market', 'Salamanca']\n cust_city_id INTEGER, -- example: [51396, 52286]\n cust_state_province TEXT, -- example: ['England - Norfolk', 'Salamanca']\n cust_state_province_id INTEGER, -- example: [52591, 52733]\n country_id INTEGER, -- example: [52789, 52778]\n cust_main_phone_number TEXT, -- example: ['127-379-8954', '680-327-1419']\n cust_income_level TEXT, -- example: ['G: 130,000 - 149,999', 'I: 170,000 - 189,999']\n cust_credit_limit REAL, -- example: [9000.0, 10000.0]\n cust_email TEXT, -- example: ['Kessel@company.example.com', 'Koch@company.example.com']\n cust_total TEXT, -- example: ['Customer total']\n cust_total_id INTEGER, -- example: [52772]\n cust_src_id INTEGER,\n cust_eff_from DATE, -- example: ['2019-01-01']\n cust_eff_to DATE,\n cust_valid CHAR(1), -- example: ['I', 'A']\n PRIMARY KEY (cust_id),\n CONSTRAINT fk_customers_country_id FOREIGN KEY (country_id) REFERENCES countries (country_id)\n);\n\nCREATE TABLE promotions (\n promo_id INTEGER, -- example: [33, 34]\n promo_name TEXT, -- example: ['post promotion #20-33', 'newspaper promotion #19-34']\n promo_subcategory TEXT, -- example: ['downtown billboard', 'coupon news']\n promo_subcategory_id INTEGER, -- example: [20, 19]\n promo_category TEXT, -- example: ['post', 'newspaper']\n promo_category_id INTEGER, -- example: [9, 8]\n promo_cost REAL, -- example: [77200.0, 22400.0]\n promo_begin_date DATE, -- example: ['2019-09-15', '2019-07-16']\n promo_end_date DATE, -- example: ['2019-11-15', '2019-09-16']\n promo_total TEXT, -- example: ['Promotion total']\n promo_total_id INTEGER, -- example: [1]\n PRIMARY KEY (promo_id)\n);\n\nCREATE TABLE products (\n prod_id INTEGER, -- example: [14, 19]\n prod_name TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket Bat Bag']\n prod_desc TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket bat bag']\n prod_subcategory TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_subcategory_id INTEGER, -- example: [2035, 2051]\n prod_subcategory_desc TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_category TEXT, -- example: ['Baseball', 'Cricket']\n prod_category_id INTEGER, -- example: [203, 205]\n prod_category_desc TEXT, -- example: ['Baseball', 'Cricket']\n prod_weight_class INTEGER, -- example: [1]\n prod_unit_of_measure TEXT, -- example: ['U']\n prod_pack_size TEXT, -- example: ['P']\n supplier_id INTEGER, -- example: [1]\n prod_status TEXT, -- example: ['STATUS']\n prod_list_price REAL, -- example: [999.99, 55.99]\n prod_min_price REAL, -- example: [999.99, 55.99]\n prod_total TEXT, -- example: ['TOTAL']\n prod_total_id INTEGER, -- example: [1]\n prod_src_id INTEGER,\n prod_eff_from DATE, -- example: ['2019-01-01 00:00:00']\n prod_eff_to DATE,\n prod_valid CHAR(1), -- example: ['A']\n PRIMARY KEY (prod_id)\n);\n\nCREATE TABLE times (\n time_id DATE, -- example: ['2019-01-01', '2019-01-02']\n day_name TEXT, -- example: ['Friday', 'Saturday']\n day_number_in_week INTEGER, -- example: [5, 6]\n day_number_in_month INTEGER, -- example: [31, 1]\n calendar_week_number INTEGER, -- example: [22, 23]\n fiscal_week_number INTEGER, -- example: [22, 23]\n week_ending_day DATE, -- example: ['2019-06-02', '2019-06-09']\n week_ending_day_id INTEGER, -- example: [1670, 1506]\n calendar_month_number INTEGER, -- example: [5, 6]\n fiscal_month_number INTEGER, -- example: [5, 6]\n calendar_month_desc TEXT, -- example: ['2019-05', '2019-06']\n calendar_month_id INTEGER, -- example: [1676, 1677]\n fiscal_month_desc TEXT, -- example: ['2019-05', '2019-06']\n fiscal_month_id INTEGER, -- example: [1724, 1725]\n days_in_cal_month INTEGER, -- example: [31, 30]\n days_in_fis_month INTEGER, -- example: [35, 28]\n end_of_cal_month DATE, -- example: ['2019-05-31', '2019-06-30']\n end_of_fis_month DATE, -- example: ['2019-05-31', '2019-06-28']\n calendar_month_name TEXT, -- example: ['December', 'May', 'June']\n fiscal_month_name TEXT, -- example: ['December', 'May', 'June']\n calendar_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n calendar_quarter_id INTEGER, -- example: [1770, 1771]\n fiscal_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n fiscal_quarter_id INTEGER, -- example: [1786, 1787]\n days_in_cal_quarter INTEGER, -- example: [91, 92]\n days_in_fis_quarter INTEGER, -- example: [91, 88]\n end_of_cal_quarter DATE, -- example: ['2019-06-30', '2019-09-30']\n end_of_fis_quarter DATE, -- example: ['2019-06-28', '2019-09-27']\n calendar_quarter_number INTEGER, -- example: [2, 3]\n fiscal_quarter_number INTEGER, -- example: [2, 3]\n calendar_year INTEGER, -- example: [2019, 2020]\n calendar_year_id INTEGER, -- example: [1802, 1803]\n fiscal_year INTEGER, -- example: [2019, 2020]\n fiscal_year_id INTEGER, -- example: [1806, 1807]\n days_in_cal_year INTEGER, -- example: [365, 366]\n days_in_fis_year INTEGER, -- example: [361, 364]\n end_of_cal_year DATE, -- example: ['2019-12-31', '2020-12-31']\n end_of_fis_year DATE, -- example: ['2019-12-27', '2020-12-26']\n PRIMARY KEY (time_id)\n);\n\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [2, 3]\n channel_desc TEXT, -- example: ['Partners', 'Direct Sales']\n channel_class TEXT, -- example: ['Others', 'Direct']\n channel_class_id INTEGER, -- example: [14, 12]\n channel_total TEXT, -- example: ['Channel total']\n channel_total_id INTEGER, -- example: [1]\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE sales (\n prod_id INTEGER, -- example: [13, 14]\n cust_id INTEGER, -- example: [987, 1660]\n time_id DATE, -- example: ['2019-01-10', '2019-01-20']\n channel_id INTEGER, -- example: [3, 2]\n promo_id INTEGER, -- example: [999, 33]\n quantity_sold INTEGER, -- example: [1]\n amount_sold REAL, -- example: [1232.16, 1205.99]\n CONSTRAINT fk_sales_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_sales_cust_id FOREIGN KEY (cust_id) REFERENCES customers (cust_id),\n CONSTRAINT fk_sales_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_sales_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id),\n CONSTRAINT fk_sales_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id)\n);\n\nCREATE TABLE costs (\n prod_id INTEGER, -- example: [13, 14]\n time_id DATE, -- example: ['2019-02-10', '2019-01-19']\n promo_id INTEGER, -- example: [350, 351]\n channel_id INTEGER, -- example: [2, 3]\n unit_cost REAL, -- example: [813.07, 886.45]\n unit_price REAL, -- example: [1237.31, 1108.99]\n CONSTRAINT fk_costs_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_costs_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_costs_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id),\n CONSTRAINT fk_costs_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id)\n);\n\nCREATE TABLE supplementary_demographics (\n cust_id INTEGER, -- example: [100001, 100002]\n education TEXT, -- example: ['< Bach.', 'Bach.']\n occupation TEXT, -- example: ['Exec.', 'Prof.']\n household_size TEXT, -- example: ['2', '3']\n yrs_residence INTEGER, -- example: [3, 4]\n affinity_card INTEGER, -- example: [0, 1]\n cricket INTEGER, -- example: [0, 1]\n baseball INTEGER, -- example: [0, 1]\n tennis INTEGER, -- example: [1, 0]\n soccer INTEGER, -- example: [1, 0]\n golf INTEGER, -- example: [1]\n `unknown` INTEGER, -- example: [0, 1]\n misc INTEGER, -- example: [0, 1]\n comments TEXT, -- example: ['Thanks a lot for my new affinity card. I', 'The more times that I shop at your store']\n PRIMARY KEY (cust_id)\n);\n\nCREATE TABLE currency (\n country TEXT, -- example: ['Singapore', 'Italy']\n `year` INTEGER, -- example: [2019, 2020]\n `month` INTEGER, -- example: [5, 6]\n to_us REAL, -- example: [1.0, 0.74]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE countries (\n country_id INTEGER, -- example: [52769, 52770]\n country_iso_code CHAR(2), -- example: ['US', 'SG', 'IT']\n country_name TEXT, -- example: ['Singapore', 'Italy']\n country_subregion TEXT, -- example: ['Asia', 'Western Europe']\n country_subregion_id INTEGER, -- example: [52793, 52799]\n country_region TEXT, -- example: ['Asia', 'Europe']\n country_region_id INTEGER, -- example: [52802, 52803]\n country_total TEXT, -- example: ['World total']\n country_total_id INTEGER, -- example: [52806]\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE customers (\n cust_id INTEGER, -- example: [1, 2]\n cust_first_name TEXT, -- example: ['Abigail', 'Anne']\n cust_last_name TEXT, -- example: ['Kessel', 'Koch']\n cust_gender CHAR(1), -- example: ['M', 'F']\n cust_year_of_birth INTEGER, -- example: [1957, 1968]\n cust_marital_status TEXT, -- example: ['single', 'married']\n cust_street_address TEXT, -- example: ['7 South 3rd Circle', '7 South Airway Circle']\n cust_postal_code TEXT, -- example: ['30828', '86319']\n cust_city TEXT, -- example: ['Downham Market', 'Salamanca']\n cust_city_id INTEGER, -- example: [51396, 52286]\n cust_state_province TEXT, -- example: ['England - Norfolk', 'Salamanca']\n cust_state_province_id INTEGER, -- example: [52591, 52733]\n country_id INTEGER, -- example: [52789, 52778]\n cust_main_phone_number TEXT, -- example: ['127-379-8954', '680-327-1419']\n cust_income_level TEXT, -- example: ['G: 130,000 - 149,999', 'I: 170,000 - 189,999']\n cust_credit_limit REAL, -- example: [9000.0, 10000.0]\n cust_email TEXT, -- example: ['Kessel@company.example.com', 'Koch@company.example.com']\n cust_total TEXT, -- example: ['Customer total']\n cust_total_id INTEGER, -- example: [52772]\n cust_src_id INTEGER,\n cust_eff_from DATE, -- example: ['2019-01-01']\n cust_eff_to DATE,\n cust_valid CHAR(1), -- example: ['I', 'A']\n PRIMARY KEY (cust_id),\n CONSTRAINT fk_customers_country_id FOREIGN KEY (country_id) REFERENCES countries (country_id)\n);\n\nCREATE TABLE promotions (\n promo_id INTEGER, -- example: [33, 34]\n promo_name TEXT, -- example: ['post promotion #20-33', 'newspaper promotion #19-34']\n promo_subcategory TEXT, -- example: ['downtown billboard', 'coupon news']\n promo_subcategory_id INTEGER, -- example: [20, 19]\n promo_category TEXT, -- example: ['post', 'newspaper']\n promo_category_id INTEGER, -- example: [9, 8]\n promo_cost REAL, -- example: [77200.0, 22400.0]\n promo_begin_date DATE, -- example: ['2019-09-15', '2019-07-16']\n promo_end_date DATE, -- example: ['2019-11-15', '2019-09-16']\n promo_total TEXT, -- example: ['Promotion total']\n promo_total_id INTEGER, -- example: [1]\n PRIMARY KEY (promo_id)\n);\n\nCREATE TABLE products (\n prod_id INTEGER, -- example: [14, 19]\n prod_name TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket Bat Bag']\n prod_desc TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket bat bag']\n prod_subcategory TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_subcategory_id INTEGER, -- example: [2035, 2051]\n prod_subcategory_desc TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_category TEXT, -- example: ['Baseball', 'Cricket']\n prod_category_id INTEGER, -- example: [203, 205]\n prod_category_desc TEXT, -- example: ['Baseball', 'Cricket']\n prod_weight_class INTEGER, -- example: [1]\n prod_unit_of_measure TEXT, -- example: ['U']\n prod_pack_size TEXT, -- example: ['P']\n supplier_id INTEGER, -- example: [1]\n prod_status TEXT, -- example: ['STATUS']\n prod_list_price REAL, -- example: [999.99, 55.99]\n prod_min_price REAL, -- example: [999.99, 55.99]\n prod_total TEXT, -- example: ['TOTAL']\n prod_total_id INTEGER, -- example: [1]\n prod_src_id INTEGER,\n prod_eff_from DATE, -- example: ['2019-01-01 00:00:00']\n prod_eff_to DATE,\n prod_valid CHAR(1), -- example: ['A']\n PRIMARY KEY (prod_id)\n);\n\nCREATE TABLE times (\n time_id DATE, -- example: ['2019-01-01', '2019-01-02']\n day_name TEXT, -- example: ['Friday', 'Saturday']\n day_number_in_week INTEGER, -- example: [5, 6]\n day_number_in_month INTEGER, -- example: [31, 1]\n calendar_week_number INTEGER, -- example: [22, 23]\n fiscal_week_number INTEGER, -- example: [22, 23]\n week_ending_day DATE, -- example: ['2019-06-02', '2019-06-09']\n week_ending_day_id INTEGER, -- example: [1670, 1506]\n calendar_month_number INTEGER, -- example: [5, 6]\n fiscal_month_number INTEGER, -- example: [5, 6]\n calendar_month_desc TEXT, -- example: ['2019-05', '2019-06']\n calendar_month_id INTEGER, -- example: [1676, 1677]\n fiscal_month_desc TEXT, -- example: ['2019-05', '2019-06']\n fiscal_month_id INTEGER, -- example: [1724, 1725]\n days_in_cal_month INTEGER, -- example: [31, 30]\n days_in_fis_month INTEGER, -- example: [35, 28]\n end_of_cal_month DATE, -- example: ['2019-05-31', '2019-06-30']\n end_of_fis_month DATE, -- example: ['2019-05-31', '2019-06-28']\n calendar_month_name TEXT, -- example: ['December', 'May', 'June']\n fiscal_month_name TEXT, -- example: ['December', 'May', 'June']\n calendar_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n calendar_quarter_id INTEGER, -- example: [1770, 1771]\n fiscal_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n fiscal_quarter_id INTEGER, -- example: [1786, 1787]\n days_in_cal_quarter INTEGER, -- example: [91, 92]\n days_in_fis_quarter INTEGER, -- example: [91, 88]\n end_of_cal_quarter DATE, -- example: ['2019-06-30', '2019-09-30']\n end_of_fis_quarter DATE, -- example: ['2019-06-28', '2019-09-27']\n calendar_quarter_number INTEGER, -- example: [2, 3]\n fiscal_quarter_number INTEGER, -- example: [2, 3]\n calendar_year INTEGER, -- example: [2019, 2020]\n calendar_year_id INTEGER, -- example: [1802, 1803]\n fiscal_year INTEGER, -- example: [2019, 2020]\n fiscal_year_id INTEGER, -- example: [1806, 1807]\n days_in_cal_year INTEGER, -- example: [365, 366]\n days_in_fis_year INTEGER, -- example: [361, 364]\n end_of_cal_year DATE, -- example: ['2019-12-31', '2020-12-31']\n end_of_fis_year DATE, -- example: ['2019-12-27', '2020-12-26']\n PRIMARY KEY (time_id)\n);\n\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [2, 3]\n channel_desc TEXT, -- example: ['Partners', 'Direct Sales']\n channel_class TEXT, -- example: ['Others', 'Direct']\n channel_class_id INTEGER, -- example: [14, 12]\n channel_total TEXT, -- example: ['Channel total']\n channel_total_id INTEGER, -- example: [1]\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE sales (\n prod_id INTEGER, -- example: [13, 14]\n cust_id INTEGER, -- example: [987, 1660]\n time_id DATE, -- example: ['2019-01-10', '2019-01-20']\n channel_id INTEGER, -- example: [3, 2]\n promo_id INTEGER, -- example: [999, 33]\n quantity_sold INTEGER, -- example: [1]\n amount_sold REAL, -- example: [1232.16, 1205.99]\n CONSTRAINT fk_sales_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_sales_cust_id FOREIGN KEY (cust_id) REFERENCES customers (cust_id),\n CONSTRAINT fk_sales_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_sales_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id),\n CONSTRAINT fk_sales_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id)\n);\n\nCREATE TABLE costs (\n prod_id INTEGER, -- example: [13, 14]\n time_id DATE, -- example: ['2019-02-10', '2019-01-19']\n promo_id INTEGER, -- example: [350, 351]\n channel_id INTEGER, -- example: [2, 3]\n unit_cost REAL, -- example: [813.07, 886.45]\n unit_price REAL, -- example: [1237.31, 1108.99]\n CONSTRAINT fk_costs_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_costs_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_costs_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id),\n CONSTRAINT fk_costs_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id)\n);\n\nCREATE TABLE supplementary_demographics (\n cust_id INTEGER, -- example: [100001, 100002]\n education TEXT, -- example: ['< Bach.', 'Bach.']\n occupation TEXT, -- example: ['Exec.', 'Prof.']\n household_size TEXT, -- example: ['2', '3']\n yrs_residence INTEGER, -- example: [3, 4]\n affinity_card INTEGER, -- example: [0, 1]\n cricket INTEGER, -- example: [0, 1]\n baseball INTEGER, -- example: [0, 1]\n tennis INTEGER, -- example: [1, 0]\n soccer INTEGER, -- example: [1, 0]\n golf INTEGER, -- example: [1]\n `unknown` INTEGER, -- example: [0, 1]\n misc INTEGER, -- example: [0, 1]\n comments TEXT, -- example: ['Thanks a lot for my new affinity card. I', 'The more times that I shop at your store']\n PRIMARY KEY (cust_id)\n);\n\nCREATE TABLE currency (\n country TEXT, -- example: ['Singapore', 'Italy']\n `year` INTEGER, -- example: [2019, 2020]\n `month` INTEGER, -- example: [5, 6]\n to_us REAL, -- example: [1.0, 0.74]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you segment Italian customers into ten profitability buckets for December 2021, using equal profit intervals, and calculate the following for each bucket in December 2021: the number of customers, maximum profit, and minimum profit?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you tell me the first names of customers who spent less than $1 on albums by the best-selling artist, along with the amounts they spent?", "schema": "CREATE TABLE albums (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_albums_artistid FOREIGN KEY (ArtistId) REFERENCES artists (ArtistId)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['genres', 'media_types']\n seq TEXT, -- example: [25, 5]\n);\n\nCREATE TABLE artists (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE customers (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customers_supportrepid FOREIGN KEY (SupportRepId) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE employees (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employees_reportsto FOREIGN KEY (ReportsTo) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE genres (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE invoices (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoices_customerid FOREIGN KEY (CustomerId) REFERENCES customers (CustomerId)\n);\n\nCREATE TABLE invoice_items (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoice_items_invoiceid FOREIGN KEY (InvoiceId) REFERENCES invoices (InvoiceId),\n CONSTRAINT fk_invoice_items_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE media_types (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE playlists (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE playlist_track (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlist_track_playlistid FOREIGN KEY (PlaylistId) REFERENCES playlists (PlaylistId),\n CONSTRAINT fk_playlist_track_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE tracks (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_tracks_albumid FOREIGN KEY (AlbumId) REFERENCES albums (AlbumId),\n CONSTRAINT fk_tracks_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES media_types (MediaTypeId),\n CONSTRAINT fk_tracks_genreid FOREIGN KEY (GenreId) REFERENCES genres (GenreId)\n);\n\nCREATE TABLE sqlite_stat1 (\n tbl TEXT, -- example: ['customers', 'albums', 'artists', 'tracks', 'playlist_track']\n idx TEXT, -- example: ['IFK_TrackMediaTypeId', 'IFK_TrackGenreId']\n stat TEXT, -- example: ['3503 701', '3503 141']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE albums (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_albums_artistid FOREIGN KEY (ArtistId) REFERENCES artists (ArtistId)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['genres', 'media_types']\n seq TEXT, -- example: [25, 5]\n);\n\nCREATE TABLE artists (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE customers (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customers_supportrepid FOREIGN KEY (SupportRepId) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE employees (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employees_reportsto FOREIGN KEY (ReportsTo) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE genres (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE invoices (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoices_customerid FOREIGN KEY (CustomerId) REFERENCES customers (CustomerId)\n);\n\nCREATE TABLE invoice_items (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoice_items_invoiceid FOREIGN KEY (InvoiceId) REFERENCES invoices (InvoiceId),\n CONSTRAINT fk_invoice_items_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE media_types (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE playlists (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE playlist_track (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlist_track_playlistid FOREIGN KEY (PlaylistId) REFERENCES playlists (PlaylistId),\n CONSTRAINT fk_playlist_track_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE tracks (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_tracks_albumid FOREIGN KEY (AlbumId) REFERENCES albums (AlbumId),\n CONSTRAINT fk_tracks_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES media_types (MediaTypeId),\n CONSTRAINT fk_tracks_genreid FOREIGN KEY (GenreId) REFERENCES genres (GenreId)\n);\n\nCREATE TABLE sqlite_stat1 (\n tbl TEXT, -- example: ['customers', 'albums', 'artists', 'tracks', 'playlist_track']\n idx TEXT, -- example: ['IFK_TrackMediaTypeId', 'IFK_TrackGenreId']\n stat TEXT, -- example: ['3503 701', '3503 141']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you tell me the first names of customers who spent less than $1 on albums by the best-selling artist, along with the amounts they spent?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For each player, list their ID, name, most frequent role across all matches, batting hand, bowling skill, total runs scored, total matches played, total dismissals, batting average, highest score in a single match, number of matches where their score exceeded 30, 50, and 100, total balls faced in their career, strike rate, total wickets taken, economy rate, and their best performance in a single match (most wickets taken, in the format \"wickets taken-runs given\"). Ignore the extra runs data.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['bowled', 'caught']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['bowled', 'caught']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Special Words Definition\n\n## Batting Average\n- Batting average is a measure of a batsman's performance, calculated by dividing the total number of runs scored by the number of times they have been dismissed. A higher batting average indicates a more consistent and successful batsman.\n- Batting Average = Total Runs ÷ Total Dismissals\n\n## Strike Rate\n- In batting, strike rate indicates the scoring rate of a batsman, showing the average number of runs scored per 100 balls faced. A higher strike rate reflects an aggressive and fast-scoring batsman.\n- Strike Rate = (Total Runs ÷ Balls Faced) × 100\n\n## Wickets Taken\n- Wickets taken refers to the total number of times a bowler has successfully dismissed an opposing batsman. This statistic is a core measure of a bowler's effectiveness and impact on the game.\n\n## Economy Rate\n- Economy rate measures a bowler's efficiency by indicating the average number of runs conceded per over (6 balls) bowled. A lower economy rate shows greater control and efficiency in restricting the opposition's scoring.\n- Economy Rate = (Total Runs Conceded ÷ Balls Bowled) × 6\n\n## Wickets Taken\n- The number of times a bowler successfully dismisses a batsman in a single match. This metric is a direct indicator of the bowler's effectiveness, showing how many players they were able to remove from play.\n\n## Runs Given\n- The total number of runs scored by the batting side off a particular bowler’s deliveries in a single match. This value reflects the runs the bowler has conceded to the batting team, and a lower runs-given value is typically favorable for the bowler's performance.\nFor each player, list their ID, name, most frequent role across all matches, batting hand, bowling skill, total runs scored, total matches played, total dismissals, batting average, highest score in a single match, number of matches where their score exceeded 30, 50, and 100, total balls faced in their career, strike rate, total wickets taken, economy rate, and their best performance in a single match (most wickets taken, in the format \"wickets taken-runs given\"). Ignore the extra runs data.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Special Words Definition\n\n## Batting Average\n- Batting average is a measure of a batsman's performance, calculated by dividing the total number of runs scored by the number of times they have been dismissed. A higher batting average indicates a more consistent and successful batsman.\n- Batting Average = Total Runs ÷ Total Dismissals\n\n## Strike Rate\n- In batting, strike rate indicates the scoring rate of a batsman, showing the average number of runs scored per 100 balls faced. A higher strike rate reflects an aggressive and fast-scoring batsman.\n- Strike Rate = (Total Runs ÷ Balls Faced) × 100\n\n## Wickets Taken\n- Wickets taken refers to the total number of times a bowler has successfully dismissed an opposing batsman. This statistic is a core measure of a bowler's effectiveness and impact on the game.\n\n## Economy Rate\n- Economy rate measures a bowler's efficiency by indicating the average number of runs conceded per over (6 balls) bowled. A lower economy rate shows greater control and efficiency in restricting the opposition's scoring.\n- Economy Rate = (Total Runs Conceded ÷ Balls Bowled) × 6\n\n## Wickets Taken\n- The number of times a bowler successfully dismisses a batsman in a single match. This metric is a direct indicator of the bowler's effectiveness, showing how many players they were able to remove from play.\n\n## Runs Given\n- The total number of runs scored by the batting side off a particular bowler’s deliveries in a single match. This value reflects the runs the bowler has conceded to the batting team, and a lower runs-given value is typically favorable for the bowler's performance." }, { "question": "I'd like to know how many actors have managed to avoid long breaks in their careers. Could you check our records to see how many actors haven't been out of work for more than three years at any point?", "schema": "CREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nI'd like to know how many actors have managed to avoid long breaks in their careers. Could you check our records to see how many actors haven't been out of work for more than three years at any point?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you help me find the actor who appeared most in English G or PG-rated children's movies no longer than 2 hours, released between 2000 and 2010?Give me a full name.", "schema": "CREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Children', 'Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Children', 'Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you help me find the actor who appeared most in English G or PG-rated children's movies no longer than 2 hours, released between 2000 and 2010?Give me a full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you help me calculate the average single career span value in years for all baseball players? Please precise the result as a float number. If it's a full year, we count it as one year. If it's less than a full year but full months, we consider 12 months as one year. If it's less than a month, we consider 365 days as one year.", "schema": "CREATE TABLE all_star (\n player_id TEXT, -- example: ['gomezle01', 'ferreri01']\n `year` INTEGER, -- example: [1933, 1934]\n game_num INTEGER, -- example: [0, 2]\n game_id TEXT, -- example: ['ALS193307060', 'NLS193407100']\n team_id TEXT, -- example: ['NYA', 'BOS']\n league_id TEXT, -- example: ['AL', 'NL']\n gp NUMERIC, -- example: [1, 0]\n starting_pos NUMERIC, -- example: [1, 2]\n);\n\nCREATE TABLE appearances (\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n player_id TEXT, -- example: ['barnero01', 'barrofr01']\n g_all NUMERIC, -- example: [31, 18]\n gs NUMERIC, -- example: [89, 0]\n g_batting INTEGER, -- example: [31, 18]\n g_defense NUMERIC, -- example: [31, 18]\n g_p INTEGER, -- example: [0, 31]\n g_c INTEGER, -- example: [0, 7]\n g_1b INTEGER, -- example: [0, 30]\n g_2b INTEGER, -- example: [16, 1]\n g_3b INTEGER, -- example: [0, 1]\n g_ss INTEGER, -- example: [15, 0]\n g_lf INTEGER, -- example: [0, 13]\n g_cf INTEGER, -- example: [0, 1]\n g_rf INTEGER, -- example: [0, 4]\n g_of INTEGER, -- example: [0, 17]\n g_dh NUMERIC, -- example: [0, 3]\n g_ph NUMERIC, -- example: [23, 0]\n g_pr NUMERIC, -- example: [0, 18]\n);\n\nCREATE TABLE manager_award (\n player_id TEXT, -- example: ['larusto01', 'lasorto01']\n award_id TEXT, -- example: ['BBWAA Manager of the year', 'TSN Manager of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n tie TEXT, -- example: ['Y']\n notes NUMERIC\n);\n\nCREATE TABLE player_award (\n player_id TEXT, -- example: ['bondto01', 'hinespa01']\n award_id TEXT, -- example: ['Pitching Triple Crown', 'Triple Crown']\n `year` INTEGER, -- example: [1877, 1878]\n league_id TEXT, -- example: ['NL', 'AA']\n tie TEXT, -- example: ['Y']\n notes TEXT, -- example: ['1B', '2B']\n);\n\nCREATE TABLE manager_award_vote (\n award_id TEXT, -- example: ['Mgr of the year', 'Mgr of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n player_id TEXT, -- example: ['altobjo01', 'coxbo01']\n points_won INTEGER, -- example: [7, 4]\n points_max INTEGER, -- example: [28, 24]\n votes_first INTEGER, -- example: [7, 4]\n);\n\nCREATE TABLE player_award_vote (\n award_id TEXT, -- example: ['Cy Young', 'MVP']\n `year` INTEGER, -- example: [1956, 1957]\n league_id TEXT, -- example: ['ML', 'AL']\n player_id TEXT, -- example: ['fordwh01', 'maglisa01']\n points_won NUMERIC, -- example: [1, 4]\n points_max INTEGER, -- example: [16, 18]\n votes_first NUMERIC, -- example: [1, 4]\n);\n\nCREATE TABLE batting (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n g INTEGER, -- example: [1, 25]\n ab NUMERIC, -- example: [4, 118]\n r NUMERIC, -- example: [0, 30]\n h NUMERIC, -- example: [0, 32]\n `double` NUMERIC, -- example: [0, 6]\n triple NUMERIC, -- example: [0, 5]\n hr NUMERIC, -- example: [0, 2]\n rbi NUMERIC, -- example: [0, 13]\n sb NUMERIC, -- example: [0, 8]\n cs NUMERIC, -- example: [0, 1]\n bb NUMERIC, -- example: [0, 4]\n so NUMERIC, -- example: [0, 5]\n ibb NUMERIC, -- example: [0, 5]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 5]\n sf NUMERIC, -- example: [0, 4]\n g_idp NUMERIC, -- example: [0, 2]\n);\n\nCREATE TABLE batting_postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n player_id TEXT, -- example: ['becanbu01', 'bradyst01']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n g INTEGER, -- example: [1, 3]\n ab INTEGER, -- example: [2, 10]\n r INTEGER, -- example: [0, 1]\n h INTEGER, -- example: [1, 0]\n `double` INTEGER, -- example: [0, 1]\n triple INTEGER, -- example: [0, 1]\n hr INTEGER, -- example: [0, 1]\n rbi INTEGER, -- example: [0, 1]\n sb INTEGER, -- example: [0, 1]\n cs NUMERIC, -- example: [0, 1]\n bb INTEGER, -- example: [0, 1]\n so INTEGER, -- example: [0, 1]\n ibb NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 1]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [1, 0]\n);\n\nCREATE TABLE player_college (\n player_id TEXT, -- example: ['aardsda01', 'abadan01']\n college_id TEXT, -- example: ['pennst', 'rice']\n `year` INTEGER, -- example: [2001, 2002]\n);\n\nCREATE TABLE fielding (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n pos TEXT, -- example: ['SS', '2B']\n g INTEGER, -- example: [1, 22]\n gs NUMERIC, -- example: [102, 113]\n inn_outs NUMERIC, -- example: [2773, 3093]\n po NUMERIC, -- example: [1, 67]\n a NUMERIC, -- example: [3, 72]\n e NUMERIC, -- example: [2, 42]\n dp NUMERIC, -- example: [0, 5]\n pb NUMERIC, -- example: [0, 12]\n wp NUMERIC, -- example: [19, 6]\n sb NUMERIC, -- example: [23, 32]\n cs NUMERIC, -- example: [16, 15]\n zr NUMERIC, -- example: [5, 0]\n);\n\nCREATE TABLE fielding_outfield (\n player_id TEXT, -- example: ['allisar01', 'ansonca01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n glf NUMERIC, -- example: [0, 1]\n gcf NUMERIC, -- example: [29, 0]\n grf NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE fielding_postseason (\n player_id TEXT, -- example: ['colliji01', 'crigelo01']\n `year` INTEGER, -- example: [1903, 1905]\n team_id TEXT, -- example: ['BOS', 'PIT']\n league_id TEXT, -- example: ['AL', 'NL']\n round TEXT, -- example: ['WS', 'ALCS']\n pos TEXT, -- example: ['3B', 'C']\n g INTEGER, -- example: [8, 4]\n gs NUMERIC, -- example: [8, 4]\n inn_outs NUMERIC, -- example: [213, 105]\n po INTEGER, -- example: [9, 54]\n a INTEGER, -- example: [18, 7]\n e INTEGER, -- example: [1, 3]\n dp INTEGER, -- example: [1, 2]\n tp INTEGER, -- example: [0, 1]\n pb NUMERIC, -- example: [0, 3]\n sb NUMERIC, -- example: [9, 6]\n cs NUMERIC, -- example: [3, 1]\n);\n\nCREATE TABLE hall_of_fame (\n player_id TEXT, -- example: ['cobbty01', 'ruthba01']\n yearid INTEGER, -- example: [1936, 1937]\n votedby TEXT, -- example: ['BBWAA', 'Veterans']\n ballots NUMERIC, -- example: [226, 78]\n needed NUMERIC, -- example: [170, 59]\n votes NUMERIC, -- example: [222, 215]\n inducted TEXT, -- example: ['Y', 'N']\n category TEXT, -- example: ['Player', 'Manager']\n needed_note TEXT, -- example: ['Top 20', '1st']\n);\n\nCREATE TABLE home_game (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n park_id TEXT, -- example: ['BOS01', 'NYC01']\n span_first TEXT, -- example: ['1871-05-16', '1871-05-27']\n span_last TEXT, -- example: ['1871-10-07', '1871-05-27']\n games INTEGER, -- example: [16, 1]\n openings INTEGER, -- example: [16, 1]\n attendance INTEGER, -- example: [32600, 3000]\n);\n\nCREATE TABLE manager (\n player_id TEXT, -- example: ['wrighha01', 'woodji01']\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n inseason INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [31, 28]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n rank NUMERIC, -- example: [3, 2]\n plyr_mgr TEXT, -- example: ['Y', 'N']\n);\n\nCREATE TABLE manager_half (\n player_id TEXT, -- example: ['hanlone01', 'vanhage01']\n `year` INTEGER, -- example: [1892, 1981]\n team_id TEXT, -- example: ['BLN', 'BRO']\n league_id TEXT, -- example: ['NL', 'AL']\n inseason INTEGER, -- example: [3, 1]\n half INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [56, 77]\n w INTEGER, -- example: [17, 26]\n l INTEGER, -- example: [39, 46]\n rank INTEGER, -- example: [12, 10]\n);\n\nCREATE TABLE player (\n player_id TEXT, -- example: ['aardsda01', 'aaronha01']\n birth_year NUMERIC, -- example: [1981, 1934]\n birth_month NUMERIC, -- example: [12, 2]\n birth_day NUMERIC, -- example: [27, 5]\n birth_country TEXT, -- example: ['USA', 'D.R.']\n birth_state TEXT, -- example: ['ME', 'CO', 'AL']\n birth_city TEXT, -- example: ['Denver', 'Mobile']\n death_year NUMERIC, -- example: [1984, 1905]\n death_month NUMERIC, -- example: [8, 5]\n death_day NUMERIC, -- example: [16, 17]\n death_country TEXT, -- example: ['USA', 'Cuba']\n death_state TEXT, -- example: ['ME', 'GA', 'NJ']\n death_city TEXT, -- example: ['Atlanta', 'Pemberton']\n name_first TEXT, -- example: ['Count', 'David', 'Hank']\n name_last TEXT, -- example: ['Span', 'Day', 'Aardsma', 'Aaron']\n name_given TEXT, -- example: ['David Allan', 'Henry Louis']\n weight NUMERIC, -- example: [220, 180]\n height NUMERIC, -- example: [75, 72]\n bats TEXT, -- example: ['R', 'L']\n throws TEXT, -- example: ['R', 'L']\n debut TEXT, -- example: ['2004-04-06', '1954-04-13']\n final_game TEXT, -- example: ['2015-08-23', '1976-10-03']\n retro_id TEXT, -- example: ['aardd001', 'aaroh101']\n bbref_id TEXT, -- example: ['aardsda01', 'aaronha01']\n);\n\nCREATE TABLE park (\n park_id TEXT, -- example: ['ALB01', 'ALT01']\n park_name TEXT, -- example: ['Riverside Park', 'Columbia Park']\n park_alias TEXT, -- example: ['Edison Field; Anaheim Stadium', 'The Ballpark in Arlington; Ameriquest Fi']\n city TEXT, -- example: ['Albany', 'Altoona']\n state TEXT, -- example: ['NY', 'PA']\n country TEXT, -- example: ['US', 'MX']\n);\n\nCREATE TABLE pitching (\n player_id TEXT, -- example: ['bechtge01', 'brainas01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['PH1', 'WS3']\n league_id TEXT, -- example: ['NL', 'AA']\n w INTEGER, -- example: [1, 12]\n l INTEGER, -- example: [2, 15]\n g INTEGER, -- example: [3, 30]\n gs INTEGER, -- example: [3, 30]\n cg INTEGER, -- example: [2, 30]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts NUMERIC, -- example: [78, 792]\n h INTEGER, -- example: [43, 361]\n er INTEGER, -- example: [23, 132]\n hr INTEGER, -- example: [0, 4]\n bb INTEGER, -- example: [11, 37]\n so INTEGER, -- example: [1, 13]\n baopp NUMERIC, -- example: [0.53, 0.15]\n era NUMERIC, -- example: [7.96, 4.5]\n ibb NUMERIC, -- example: [1, 0]\n wp NUMERIC, -- example: [0, 8]\n hbp NUMERIC, -- example: [0, 10]\n bk INTEGER, -- example: [0, 2]\n bfp NUMERIC, -- example: [13, 14]\n gf NUMERIC, -- example: [0, 1]\n r INTEGER, -- example: [42, 292]\n sh NUMERIC, -- example: [1, 3]\n sf NUMERIC, -- example: [4, 1]\n g_idp NUMERIC, -- example: [6, 1]\n);\n\nCREATE TABLE pitching_postseason (\n player_id TEXT, -- example: ['becanbu01', 'keefeti01']\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n w INTEGER, -- example: [0, 3]\n l INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [1, 2]\n gs INTEGER, -- example: [1, 2]\n cg INTEGER, -- example: [1, 2]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts INTEGER, -- example: [18, 45]\n h INTEGER, -- example: [9, 10]\n er INTEGER, -- example: [7, 6]\n hr INTEGER, -- example: [0, 1]\n bb INTEGER, -- example: [2, 3]\n so INTEGER, -- example: [1, 12]\n baopp TEXT, -- example: ['0.23', '0.4']\n era NUMERIC, -- example: [10.5, 3.6]\n ibb NUMERIC, -- example: [0, 1]\n wp NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n bk NUMERIC, -- example: [0, 1]\n bfp NUMERIC, -- example: [134, 12]\n gf INTEGER, -- example: [0, 1]\n r INTEGER, -- example: [12, 9]\n sh NUMERIC, -- example: [0, 3]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE salary (\n `year` INTEGER, -- example: [1985, 1986]\n team_id TEXT, -- example: ['ATL', 'BAL']\n league_id TEXT, -- example: ['NL', 'AL']\n player_id TEXT, -- example: ['barkele01', 'bedrost01']\n salary INTEGER, -- example: [870000, 550000]\n);\n\nCREATE TABLE college (\n college_id TEXT, -- example: ['abilchrist', 'adelphi']\n name_full TEXT, -- example: ['Abilene Christian University', 'Adelphi University']\n city TEXT, -- example: ['Abilene', 'Garden City']\n state TEXT, -- example: ['ME', 'TX', 'NY']\n country TEXT, -- example: ['USA']\n);\n\nCREATE TABLE postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id_winner TEXT, -- example: ['PRO', 'CHC']\n league_id_winner TEXT, -- example: ['NL', 'AA']\n team_id_loser TEXT, -- example: ['NYP', 'STL']\n league_id_loser TEXT, -- example: ['AA', 'NL']\n wins INTEGER, -- example: [3, 4]\n losses INTEGER, -- example: [0, 3]\n ties INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE team (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n franchise_id TEXT, -- example: ['BNA', 'CNA']\n div_id TEXT, -- example: ['W', 'E']\n rank INTEGER, -- example: [3, 2]\n g INTEGER, -- example: [31, 28]\n ghome NUMERIC, -- example: [66, 69]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n div_win TEXT, -- example: ['Y', 'N']\n wc_win TEXT, -- example: ['N', 'Y']\n lg_win TEXT, -- example: ['N', 'Y']\n ws_win TEXT, -- example: ['N', 'Y']\n r INTEGER, -- example: [401, 302]\n ab INTEGER, -- example: [1372, 1196]\n h INTEGER, -- example: [426, 323]\n `double` INTEGER, -- example: [70, 52]\n triple INTEGER, -- example: [37, 21]\n hr INTEGER, -- example: [3, 10]\n bb INTEGER, -- example: [60, 26]\n so NUMERIC, -- example: [19, 22]\n sb NUMERIC, -- example: [73, 69]\n cs NUMERIC, -- example: [15, 4]\n hbp NUMERIC, -- example: [47, 59]\n sf NUMERIC, -- example: [43, 58]\n ra INTEGER, -- example: [303, 241]\n er INTEGER, -- example: [109, 77]\n era NUMERIC, -- example: [3.55, 2.76]\n cg INTEGER, -- example: [22, 25]\n sho INTEGER, -- example: [1, 0]\n sv INTEGER, -- example: [3, 1]\n ipouts INTEGER, -- example: [828, 753]\n ha INTEGER, -- example: [367, 308]\n hra INTEGER, -- example: [2, 6]\n bba INTEGER, -- example: [42, 28]\n soa INTEGER, -- example: [23, 22]\n e INTEGER, -- example: [225, 218]\n dp NUMERIC, -- example: [42, 33]\n fp NUMERIC, -- example: [0.83, 0.82]\n name TEXT, -- example: ['Boston Red Stockings', 'Chicago White Stockings']\n park TEXT, -- example: ['South End Grounds I', 'Union Base-Ball Grounds']\n attendance NUMERIC, -- example: [121412, 147539]\n bpf INTEGER, -- example: [103, 104]\n ppf INTEGER, -- example: [98, 102]\n team_id_br TEXT, -- example: ['BOS', 'CHI']\n team_id_lahman45 TEXT, -- example: ['BS1', 'CH1']\n team_id_retro TEXT, -- example: ['BS1', 'CH1']\n);\n\nCREATE TABLE team_franchise (\n franchise_id TEXT, -- example: ['ALT', 'ANA']\n franchise_name TEXT, -- example: ['Altoona Mountain City', 'Los Angeles Angels of Anaheim']\n active TEXT, -- example: ['N', 'Y']\n na_assoc TEXT, -- example: ['PNA', 'BNA']\n);\n\nCREATE TABLE team_half (\n `year` INTEGER, -- example: [1981]\n league_id TEXT, -- example: ['NL', 'AL']\n team_id TEXT, -- example: ['ATL', 'BAL']\n half INTEGER, -- example: [1, 2]\n div_id TEXT, -- example: ['W', 'E']\n div_win TEXT, -- example: ['N']\n rank INTEGER, -- example: [4, 5]\n g INTEGER, -- example: [54, 52]\n w INTEGER, -- example: [25, 31]\n l INTEGER, -- example: [29, 27]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE all_star (\n player_id TEXT, -- example: ['gomezle01', 'ferreri01']\n `year` INTEGER, -- example: [1933, 1934]\n game_num INTEGER, -- example: [0, 2]\n game_id TEXT, -- example: ['ALS193307060', 'NLS193407100']\n team_id TEXT, -- example: ['NYA', 'BOS']\n league_id TEXT, -- example: ['AL', 'NL']\n gp NUMERIC, -- example: [1, 0]\n starting_pos NUMERIC, -- example: [1, 2]\n);\n\nCREATE TABLE appearances (\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n player_id TEXT, -- example: ['barnero01', 'barrofr01']\n g_all NUMERIC, -- example: [31, 18]\n gs NUMERIC, -- example: [89, 0]\n g_batting INTEGER, -- example: [31, 18]\n g_defense NUMERIC, -- example: [31, 18]\n g_p INTEGER, -- example: [0, 31]\n g_c INTEGER, -- example: [0, 7]\n g_1b INTEGER, -- example: [0, 30]\n g_2b INTEGER, -- example: [16, 1]\n g_3b INTEGER, -- example: [0, 1]\n g_ss INTEGER, -- example: [15, 0]\n g_lf INTEGER, -- example: [0, 13]\n g_cf INTEGER, -- example: [0, 1]\n g_rf INTEGER, -- example: [0, 4]\n g_of INTEGER, -- example: [0, 17]\n g_dh NUMERIC, -- example: [0, 3]\n g_ph NUMERIC, -- example: [23, 0]\n g_pr NUMERIC, -- example: [0, 18]\n);\n\nCREATE TABLE manager_award (\n player_id TEXT, -- example: ['larusto01', 'lasorto01']\n award_id TEXT, -- example: ['BBWAA Manager of the year', 'TSN Manager of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n tie TEXT, -- example: ['Y']\n notes NUMERIC\n);\n\nCREATE TABLE player_award (\n player_id TEXT, -- example: ['bondto01', 'hinespa01']\n award_id TEXT, -- example: ['Pitching Triple Crown', 'Triple Crown']\n `year` INTEGER, -- example: [1877, 1878]\n league_id TEXT, -- example: ['NL', 'AA']\n tie TEXT, -- example: ['Y']\n notes TEXT, -- example: ['1B', '2B']\n);\n\nCREATE TABLE manager_award_vote (\n award_id TEXT, -- example: ['Mgr of the year', 'Mgr of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n player_id TEXT, -- example: ['altobjo01', 'coxbo01']\n points_won INTEGER, -- example: [7, 4]\n points_max INTEGER, -- example: [28, 24]\n votes_first INTEGER, -- example: [7, 4]\n);\n\nCREATE TABLE player_award_vote (\n award_id TEXT, -- example: ['Cy Young', 'MVP']\n `year` INTEGER, -- example: [1956, 1957]\n league_id TEXT, -- example: ['ML', 'AL']\n player_id TEXT, -- example: ['fordwh01', 'maglisa01']\n points_won NUMERIC, -- example: [1, 4]\n points_max INTEGER, -- example: [16, 18]\n votes_first NUMERIC, -- example: [1, 4]\n);\n\nCREATE TABLE batting (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n g INTEGER, -- example: [1, 25]\n ab NUMERIC, -- example: [4, 118]\n r NUMERIC, -- example: [0, 30]\n h NUMERIC, -- example: [0, 32]\n `double` NUMERIC, -- example: [0, 6]\n triple NUMERIC, -- example: [0, 5]\n hr NUMERIC, -- example: [0, 2]\n rbi NUMERIC, -- example: [0, 13]\n sb NUMERIC, -- example: [0, 8]\n cs NUMERIC, -- example: [0, 1]\n bb NUMERIC, -- example: [0, 4]\n so NUMERIC, -- example: [0, 5]\n ibb NUMERIC, -- example: [0, 5]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 5]\n sf NUMERIC, -- example: [0, 4]\n g_idp NUMERIC, -- example: [0, 2]\n);\n\nCREATE TABLE batting_postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n player_id TEXT, -- example: ['becanbu01', 'bradyst01']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n g INTEGER, -- example: [1, 3]\n ab INTEGER, -- example: [2, 10]\n r INTEGER, -- example: [0, 1]\n h INTEGER, -- example: [1, 0]\n `double` INTEGER, -- example: [0, 1]\n triple INTEGER, -- example: [0, 1]\n hr INTEGER, -- example: [0, 1]\n rbi INTEGER, -- example: [0, 1]\n sb INTEGER, -- example: [0, 1]\n cs NUMERIC, -- example: [0, 1]\n bb INTEGER, -- example: [0, 1]\n so INTEGER, -- example: [0, 1]\n ibb NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 1]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [1, 0]\n);\n\nCREATE TABLE player_college (\n player_id TEXT, -- example: ['aardsda01', 'abadan01']\n college_id TEXT, -- example: ['pennst', 'rice']\n `year` INTEGER, -- example: [2001, 2002]\n);\n\nCREATE TABLE fielding (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n pos TEXT, -- example: ['SS', '2B']\n g INTEGER, -- example: [1, 22]\n gs NUMERIC, -- example: [102, 113]\n inn_outs NUMERIC, -- example: [2773, 3093]\n po NUMERIC, -- example: [1, 67]\n a NUMERIC, -- example: [3, 72]\n e NUMERIC, -- example: [2, 42]\n dp NUMERIC, -- example: [0, 5]\n pb NUMERIC, -- example: [0, 12]\n wp NUMERIC, -- example: [19, 6]\n sb NUMERIC, -- example: [23, 32]\n cs NUMERIC, -- example: [16, 15]\n zr NUMERIC, -- example: [5, 0]\n);\n\nCREATE TABLE fielding_outfield (\n player_id TEXT, -- example: ['allisar01', 'ansonca01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n glf NUMERIC, -- example: [0, 1]\n gcf NUMERIC, -- example: [29, 0]\n grf NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE fielding_postseason (\n player_id TEXT, -- example: ['colliji01', 'crigelo01']\n `year` INTEGER, -- example: [1903, 1905]\n team_id TEXT, -- example: ['BOS', 'PIT']\n league_id TEXT, -- example: ['AL', 'NL']\n round TEXT, -- example: ['WS', 'ALCS']\n pos TEXT, -- example: ['3B', 'C']\n g INTEGER, -- example: [8, 4]\n gs NUMERIC, -- example: [8, 4]\n inn_outs NUMERIC, -- example: [213, 105]\n po INTEGER, -- example: [9, 54]\n a INTEGER, -- example: [18, 7]\n e INTEGER, -- example: [1, 3]\n dp INTEGER, -- example: [1, 2]\n tp INTEGER, -- example: [0, 1]\n pb NUMERIC, -- example: [0, 3]\n sb NUMERIC, -- example: [9, 6]\n cs NUMERIC, -- example: [3, 1]\n);\n\nCREATE TABLE hall_of_fame (\n player_id TEXT, -- example: ['cobbty01', 'ruthba01']\n yearid INTEGER, -- example: [1936, 1937]\n votedby TEXT, -- example: ['BBWAA', 'Veterans']\n ballots NUMERIC, -- example: [226, 78]\n needed NUMERIC, -- example: [170, 59]\n votes NUMERIC, -- example: [222, 215]\n inducted TEXT, -- example: ['Y', 'N']\n category TEXT, -- example: ['Player', 'Manager']\n needed_note TEXT, -- example: ['Top 20', '1st']\n);\n\nCREATE TABLE home_game (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n park_id TEXT, -- example: ['BOS01', 'NYC01']\n span_first TEXT, -- example: ['1871-05-16', '1871-05-27']\n span_last TEXT, -- example: ['1871-10-07', '1871-05-27']\n games INTEGER, -- example: [16, 1]\n openings INTEGER, -- example: [16, 1]\n attendance INTEGER, -- example: [32600, 3000]\n);\n\nCREATE TABLE manager (\n player_id TEXT, -- example: ['wrighha01', 'woodji01']\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n inseason INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [31, 28]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n rank NUMERIC, -- example: [3, 2]\n plyr_mgr TEXT, -- example: ['Y', 'N']\n);\n\nCREATE TABLE manager_half (\n player_id TEXT, -- example: ['hanlone01', 'vanhage01']\n `year` INTEGER, -- example: [1892, 1981]\n team_id TEXT, -- example: ['BLN', 'BRO']\n league_id TEXT, -- example: ['NL', 'AL']\n inseason INTEGER, -- example: [3, 1]\n half INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [56, 77]\n w INTEGER, -- example: [17, 26]\n l INTEGER, -- example: [39, 46]\n rank INTEGER, -- example: [12, 10]\n);\n\nCREATE TABLE player (\n player_id TEXT, -- example: ['aardsda01', 'aaronha01']\n birth_year NUMERIC, -- example: [1981, 1934]\n birth_month NUMERIC, -- example: [12, 2]\n birth_day NUMERIC, -- example: [27, 5]\n birth_country TEXT, -- example: ['USA', 'D.R.']\n birth_state TEXT, -- example: ['ME', 'CO', 'AL']\n birth_city TEXT, -- example: ['Denver', 'Mobile']\n death_year NUMERIC, -- example: [1984, 1905]\n death_month NUMERIC, -- example: [8, 5]\n death_day NUMERIC, -- example: [16, 17]\n death_country TEXT, -- example: ['USA', 'Cuba']\n death_state TEXT, -- example: ['ME', 'GA', 'NJ']\n death_city TEXT, -- example: ['Atlanta', 'Pemberton']\n name_first TEXT, -- example: ['Count', 'David', 'Hank']\n name_last TEXT, -- example: ['Span', 'Day', 'Aardsma', 'Aaron']\n name_given TEXT, -- example: ['David Allan', 'Henry Louis']\n weight NUMERIC, -- example: [220, 180]\n height NUMERIC, -- example: [75, 72]\n bats TEXT, -- example: ['R', 'L']\n throws TEXT, -- example: ['R', 'L']\n debut TEXT, -- example: ['2004-04-06', '1954-04-13']\n final_game TEXT, -- example: ['2015-08-23', '1976-10-03']\n retro_id TEXT, -- example: ['aardd001', 'aaroh101']\n bbref_id TEXT, -- example: ['aardsda01', 'aaronha01']\n);\n\nCREATE TABLE park (\n park_id TEXT, -- example: ['ALB01', 'ALT01']\n park_name TEXT, -- example: ['Riverside Park', 'Columbia Park']\n park_alias TEXT, -- example: ['Edison Field; Anaheim Stadium', 'The Ballpark in Arlington; Ameriquest Fi']\n city TEXT, -- example: ['Albany', 'Altoona']\n state TEXT, -- example: ['NY', 'PA']\n country TEXT, -- example: ['US', 'MX']\n);\n\nCREATE TABLE pitching (\n player_id TEXT, -- example: ['bechtge01', 'brainas01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['PH1', 'WS3']\n league_id TEXT, -- example: ['NL', 'AA']\n w INTEGER, -- example: [1, 12]\n l INTEGER, -- example: [2, 15]\n g INTEGER, -- example: [3, 30]\n gs INTEGER, -- example: [3, 30]\n cg INTEGER, -- example: [2, 30]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts NUMERIC, -- example: [78, 792]\n h INTEGER, -- example: [43, 361]\n er INTEGER, -- example: [23, 132]\n hr INTEGER, -- example: [0, 4]\n bb INTEGER, -- example: [11, 37]\n so INTEGER, -- example: [1, 13]\n baopp NUMERIC, -- example: [0.53, 0.15]\n era NUMERIC, -- example: [7.96, 4.5]\n ibb NUMERIC, -- example: [1, 0]\n wp NUMERIC, -- example: [0, 8]\n hbp NUMERIC, -- example: [0, 10]\n bk INTEGER, -- example: [0, 2]\n bfp NUMERIC, -- example: [13, 14]\n gf NUMERIC, -- example: [0, 1]\n r INTEGER, -- example: [42, 292]\n sh NUMERIC, -- example: [1, 3]\n sf NUMERIC, -- example: [4, 1]\n g_idp NUMERIC, -- example: [6, 1]\n);\n\nCREATE TABLE pitching_postseason (\n player_id TEXT, -- example: ['becanbu01', 'keefeti01']\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n w INTEGER, -- example: [0, 3]\n l INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [1, 2]\n gs INTEGER, -- example: [1, 2]\n cg INTEGER, -- example: [1, 2]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts INTEGER, -- example: [18, 45]\n h INTEGER, -- example: [9, 10]\n er INTEGER, -- example: [7, 6]\n hr INTEGER, -- example: [0, 1]\n bb INTEGER, -- example: [2, 3]\n so INTEGER, -- example: [1, 12]\n baopp TEXT, -- example: ['0.23', '0.4']\n era NUMERIC, -- example: [10.5, 3.6]\n ibb NUMERIC, -- example: [0, 1]\n wp NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n bk NUMERIC, -- example: [0, 1]\n bfp NUMERIC, -- example: [134, 12]\n gf INTEGER, -- example: [0, 1]\n r INTEGER, -- example: [12, 9]\n sh NUMERIC, -- example: [0, 3]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE salary (\n `year` INTEGER, -- example: [1985, 1986]\n team_id TEXT, -- example: ['ATL', 'BAL']\n league_id TEXT, -- example: ['NL', 'AL']\n player_id TEXT, -- example: ['barkele01', 'bedrost01']\n salary INTEGER, -- example: [870000, 550000]\n);\n\nCREATE TABLE college (\n college_id TEXT, -- example: ['abilchrist', 'adelphi']\n name_full TEXT, -- example: ['Abilene Christian University', 'Adelphi University']\n city TEXT, -- example: ['Abilene', 'Garden City']\n state TEXT, -- example: ['ME', 'TX', 'NY']\n country TEXT, -- example: ['USA']\n);\n\nCREATE TABLE postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id_winner TEXT, -- example: ['PRO', 'CHC']\n league_id_winner TEXT, -- example: ['NL', 'AA']\n team_id_loser TEXT, -- example: ['NYP', 'STL']\n league_id_loser TEXT, -- example: ['AA', 'NL']\n wins INTEGER, -- example: [3, 4]\n losses INTEGER, -- example: [0, 3]\n ties INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE team (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n franchise_id TEXT, -- example: ['BNA', 'CNA']\n div_id TEXT, -- example: ['W', 'E']\n rank INTEGER, -- example: [3, 2]\n g INTEGER, -- example: [31, 28]\n ghome NUMERIC, -- example: [66, 69]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n div_win TEXT, -- example: ['Y', 'N']\n wc_win TEXT, -- example: ['N', 'Y']\n lg_win TEXT, -- example: ['N', 'Y']\n ws_win TEXT, -- example: ['N', 'Y']\n r INTEGER, -- example: [401, 302]\n ab INTEGER, -- example: [1372, 1196]\n h INTEGER, -- example: [426, 323]\n `double` INTEGER, -- example: [70, 52]\n triple INTEGER, -- example: [37, 21]\n hr INTEGER, -- example: [3, 10]\n bb INTEGER, -- example: [60, 26]\n so NUMERIC, -- example: [19, 22]\n sb NUMERIC, -- example: [73, 69]\n cs NUMERIC, -- example: [15, 4]\n hbp NUMERIC, -- example: [47, 59]\n sf NUMERIC, -- example: [43, 58]\n ra INTEGER, -- example: [303, 241]\n er INTEGER, -- example: [109, 77]\n era NUMERIC, -- example: [3.55, 2.76]\n cg INTEGER, -- example: [22, 25]\n sho INTEGER, -- example: [1, 0]\n sv INTEGER, -- example: [3, 1]\n ipouts INTEGER, -- example: [828, 753]\n ha INTEGER, -- example: [367, 308]\n hra INTEGER, -- example: [2, 6]\n bba INTEGER, -- example: [42, 28]\n soa INTEGER, -- example: [23, 22]\n e INTEGER, -- example: [225, 218]\n dp NUMERIC, -- example: [42, 33]\n fp NUMERIC, -- example: [0.83, 0.82]\n name TEXT, -- example: ['Boston Red Stockings', 'Chicago White Stockings']\n park TEXT, -- example: ['South End Grounds I', 'Union Base-Ball Grounds']\n attendance NUMERIC, -- example: [121412, 147539]\n bpf INTEGER, -- example: [103, 104]\n ppf INTEGER, -- example: [98, 102]\n team_id_br TEXT, -- example: ['BOS', 'CHI']\n team_id_lahman45 TEXT, -- example: ['BS1', 'CH1']\n team_id_retro TEXT, -- example: ['BS1', 'CH1']\n);\n\nCREATE TABLE team_franchise (\n franchise_id TEXT, -- example: ['ALT', 'ANA']\n franchise_name TEXT, -- example: ['Altoona Mountain City', 'Los Angeles Angels of Anaheim']\n active TEXT, -- example: ['N', 'Y']\n na_assoc TEXT, -- example: ['PNA', 'BNA']\n);\n\nCREATE TABLE team_half (\n `year` INTEGER, -- example: [1981]\n league_id TEXT, -- example: ['NL', 'AL']\n team_id TEXT, -- example: ['ATL', 'BAL']\n half INTEGER, -- example: [1, 2]\n div_id TEXT, -- example: ['W', 'E']\n div_win TEXT, -- example: ['N']\n rank INTEGER, -- example: [4, 5]\n g INTEGER, -- example: [54, 52]\n w INTEGER, -- example: [25, 31]\n l INTEGER, -- example: [29, 27]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you help me calculate the average single career span value in years for all baseball players? Please precise the result as a float number. If it's a full year, we count it as one year. If it's less than a full year but full months, we consider 12 months as one year. If it's less than a month, we consider 365 days as one year.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the distance of the longest route where Abakan is either the departure or destination city (in kilometers)?", "schema": "CREATE TABLE aircrafts_data (\n aircraft_code character(3), -- example: ['773', '763']\n model jsonb, -- example: ['{\"en\": \"Boeing 777-300\", \"ru\": \"Боинг 77', '{\"en\": \"Boeing 767-300\", \"ru\": \"Боинг 76']\n `range` integer, -- example: [11100, 7900]\n);\n\nCREATE TABLE airports_data (\n airport_code character(3), -- example: ['YKS', 'MJZ']\n airport_name jsonb, -- example: ['{\"en\": \"Yakutsk Airport\", \"ru\": \"Якутск\"', '{\"en\": \"Mirny Airport\", \"ru\": \"Мирный\"}']\n city jsonb, -- example: ['{\"en\": \"Yakutsk\", \"ru\": \"Якутск\"}', '{\"en\": \"Mirnyj\", \"ru\": \"Мирный\"}']\n coordinates point, -- example: ['(129.77099609375,62.0932998657226562)', '(114.03900146484375,62.534698486328125)']\n timezone text, -- example: ['Asia/Yakutsk', 'Asia/Vladivostok']\n);\n\nCREATE TABLE boarding_passes (\n ticket_no character(13), -- example: ['0005435212351', '0005435212386']\n flight_id integer, -- example: [30625, 24836]\n boarding_no integer, -- example: [1, 2]\n seat_no character varying(4), -- example: ['2D', '3G']\n);\n\nCREATE TABLE bookings (\n book_ref character(6), -- example: ['00000F', '000012']\n book_date timestamp with time zone, -- example: ['2017-07-05 03:12:00+03', '2017-07-14 09:02:00+03']\n total_amount numeric(10,2), -- example: [265700, 37900]\n);\n\nCREATE TABLE flights (\n flight_id integer, -- example: [1185, 3979]\n flight_no character(6), -- example: ['PG0134', 'PG0052']\n scheduled_departure timestamp with time zone, -- example: ['2017-09-10 09:50:00+03', '2017-08-25 14:50:00+03']\n scheduled_arrival timestamp with time zone, -- example: ['2017-09-10 14:55:00+03', '2017-08-25 17:35:00+03']\n departure_airport character(3), -- example: ['DME', 'VKO']\n arrival_airport character(3), -- example: ['BTK', 'HMA']\n status character varying(20), -- example: ['Scheduled', 'Cancelled']\n aircraft_code character(3), -- example: ['319', 'CR2']\n actual_departure timestamp with time zone, -- example: ['\\\\N', '2017-07-16 09:44:00+03']\n actual_arrival timestamp with time zone, -- example: ['\\\\N', '2017-07-16 10:39:00+03']\n);\n\nCREATE TABLE seats (\n aircraft_code character(3), -- example: ['319', '320']\n seat_no character varying(4), -- example: ['2A', '2C']\n fare_conditions character varying(10), -- example: ['Business', 'Economy']\n);\n\nCREATE TABLE ticket_flights (\n ticket_no character(13), -- example: ['0005432159776', '0005435212351']\n flight_id integer, -- example: [30625, 24836]\n fare_conditions character varying(10), -- example: ['Business', 'Comfort']\n amount numeric(10,2), -- example: [42100, 23900]\n);\n\nCREATE TABLE tickets (\n ticket_no character(13), -- example: ['0005432000987', '0005432000988']\n book_ref character(6), -- example: ['06B046', 'E170C3']\n passenger_id character varying(20), -- example: ['8149 604011', '8499 420203']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aircrafts_data (\n aircraft_code character(3), -- example: ['773', '763']\n model jsonb, -- example: ['{\"en\": \"Boeing 777-300\", \"ru\": \"Боинг 77', '{\"en\": \"Boeing 767-300\", \"ru\": \"Боинг 76']\n `range` integer, -- example: [11100, 7900]\n);\n\nCREATE TABLE airports_data (\n airport_code character(3), -- example: ['YKS', 'MJZ']\n airport_name jsonb, -- example: ['{\"en\": \"Yakutsk Airport\", \"ru\": \"Якутск\"', '{\"en\": \"Mirny Airport\", \"ru\": \"Мирный\"}']\n city jsonb, -- example: ['{\"en\": \"Yakutsk\", \"ru\": \"Якутск\"}', '{\"en\": \"Mirnyj\", \"ru\": \"Мирный\"}']\n coordinates point, -- example: ['(129.77099609375,62.0932998657226562)', '(114.03900146484375,62.534698486328125)']\n timezone text, -- example: ['Asia/Yakutsk', 'Asia/Vladivostok']\n);\n\nCREATE TABLE boarding_passes (\n ticket_no character(13), -- example: ['0005435212351', '0005435212386']\n flight_id integer, -- example: [30625, 24836]\n boarding_no integer, -- example: [1, 2]\n seat_no character varying(4), -- example: ['2D', '3G']\n);\n\nCREATE TABLE bookings (\n book_ref character(6), -- example: ['00000F', '000012']\n book_date timestamp with time zone, -- example: ['2017-07-05 03:12:00+03', '2017-07-14 09:02:00+03']\n total_amount numeric(10,2), -- example: [265700, 37900]\n);\n\nCREATE TABLE flights (\n flight_id integer, -- example: [1185, 3979]\n flight_no character(6), -- example: ['PG0134', 'PG0052']\n scheduled_departure timestamp with time zone, -- example: ['2017-09-10 09:50:00+03', '2017-08-25 14:50:00+03']\n scheduled_arrival timestamp with time zone, -- example: ['2017-09-10 14:55:00+03', '2017-08-25 17:35:00+03']\n departure_airport character(3), -- example: ['DME', 'VKO']\n arrival_airport character(3), -- example: ['BTK', 'HMA']\n status character varying(20), -- example: ['Scheduled', 'Cancelled']\n aircraft_code character(3), -- example: ['319', 'CR2']\n actual_departure timestamp with time zone, -- example: ['\\\\N', '2017-07-16 09:44:00+03']\n actual_arrival timestamp with time zone, -- example: ['\\\\N', '2017-07-16 10:39:00+03']\n);\n\nCREATE TABLE seats (\n aircraft_code character(3), -- example: ['319', '320']\n seat_no character varying(4), -- example: ['2A', '2C']\n fare_conditions character varying(10), -- example: ['Business', 'Economy']\n);\n\nCREATE TABLE ticket_flights (\n ticket_no character(13), -- example: ['0005432159776', '0005435212351']\n flight_id integer, -- example: [30625, 24836]\n fare_conditions character varying(10), -- example: ['Business', 'Comfort']\n amount numeric(10,2), -- example: [42100, 23900]\n);\n\nCREATE TABLE tickets (\n ticket_no character(13), -- example: ['0005432000987', '0005432000988']\n book_ref character(6), -- example: ['06B046', 'E170C3']\n passenger_id character varying(20), -- example: ['8149 604011', '8499 420203']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Flight Route Distance Calculation\n\n## Introduction\n\nThis document describes the method used to calculate the distance between two cities for flight routes. The calculation is based on the Haversine formula, which is commonly used to find the shortest distance between two points on a sphere given their latitude and longitude. This method is especially useful for determining flight distances between airports located in different cities around the world.\n\n## City and Coordinate Extraction\n\nFor each flight, the following data is obtained:\n\n- **Departure city** (referred to as `from_city`) and its geographical coordinates (longitude and latitude).\n- **Arrival city** (referred to as `to_city`) and its geographical coordinates (longitude and latitude).\n\nThe coordinates are extracted as decimal values, with longitude and latitude represented in degrees. This ensures that trigonometric operations can be applied during the distance calculation.\n\n## Haversine Formula\n\nThe Haversine formula is used to calculate the great-circle distance between two points on a sphere using their latitude and longitude. The formula is given as:\n\n\\[\nd = 2r \\cdot \\arcsin\\left(\\sqrt{\\sin^2\\left(\\frac{\\Delta \\phi}{2}\\right) + \\cos(\\phi_1) \\cdot \\cos(\\phi_2) \\cdot \\sin^2\\left(\\frac{\\Delta \\lambda}{2}\\right)}\\right)\n\\]\n\nWhere:\n\n- \\( d \\) is the distance between the two points (in kilometers).\n- \\( r \\) is the radius of the Earth (approximately 6371 km).\n- \\( \\phi_1 \\) and \\( \\phi_2 \\) are the latitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\phi = \\phi_2 - \\phi_1 \\) is the difference in latitudes.\n- \\( \\lambda_1 \\) and \\( \\lambda_2 \\) are the longitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\lambda = \\lambda_2 - \\lambda_1 \\) is the difference in longitudes.\n\n### Conversion to Radians\n\nSince the input coordinates are in degrees, they must be converted to radians before applying the Haversine formula. This conversion is done using the formula:\n\n\\[\n\\text{radians} = \\text{degrees} \\times \\frac{\\pi}{180}\n\\]\n\n## Symmetry of Routes\n\nTo identify unique flight routes between two cities, we standardize the order of cities in each route. Specifically, we ensure that the lexicographically smaller city name is always listed as the first city (`city1`), and the larger city is listed as the second city (`city2`). This ensures that a flight from City A to City B is treated the same as a flight from City B to City A.\n\n## Average Route Distance\n\nOnce the distances for all flights between two cities are computed, the average distance for each city pair is calculated by summing the distances and dividing by the total number of flights between those cities:\n\n\\[\n\\text{Average Distance} = \\frac{\\sum \\text{Flight Distances}}{\\text{Number of Flights}}\n\\]\n\n## Conclusion\n\nThis method of flight route distance calculation provides a reliable way to determine the great-circle distance between cities based on the coordinates of their respective airports. The use of the Haversine formula ensures accurate results for distances on the Earth's surface, making it ideal for aviation and travel analysis.\nWhat is the distance of the longest route where Abakan is either the departure or destination city (in kilometers)?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Flight Route Distance Calculation\n\n## Introduction\n\nThis document describes the method used to calculate the distance between two cities for flight routes. The calculation is based on the Haversine formula, which is commonly used to find the shortest distance between two points on a sphere given their latitude and longitude. This method is especially useful for determining flight distances between airports located in different cities around the world.\n\n## City and Coordinate Extraction\n\nFor each flight, the following data is obtained:\n\n- **Departure city** (referred to as `from_city`) and its geographical coordinates (longitude and latitude).\n- **Arrival city** (referred to as `to_city`) and its geographical coordinates (longitude and latitude).\n\nThe coordinates are extracted as decimal values, with longitude and latitude represented in degrees. This ensures that trigonometric operations can be applied during the distance calculation.\n\n## Haversine Formula\n\nThe Haversine formula is used to calculate the great-circle distance between two points on a sphere using their latitude and longitude. The formula is given as:\n\n\\[\nd = 2r \\cdot \\arcsin\\left(\\sqrt{\\sin^2\\left(\\frac{\\Delta \\phi}{2}\\right) + \\cos(\\phi_1) \\cdot \\cos(\\phi_2) \\cdot \\sin^2\\left(\\frac{\\Delta \\lambda}{2}\\right)}\\right)\n\\]\n\nWhere:\n\n- \\( d \\) is the distance between the two points (in kilometers).\n- \\( r \\) is the radius of the Earth (approximately 6371 km).\n- \\( \\phi_1 \\) and \\( \\phi_2 \\) are the latitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\phi = \\phi_2 - \\phi_1 \\) is the difference in latitudes.\n- \\( \\lambda_1 \\) and \\( \\lambda_2 \\) are the longitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\lambda = \\lambda_2 - \\lambda_1 \\) is the difference in longitudes.\n\n### Conversion to Radians\n\nSince the input coordinates are in degrees, they must be converted to radians before applying the Haversine formula. This conversion is done using the formula:\n\n\\[\n\\text{radians} = \\text{degrees} \\times \\frac{\\pi}{180}\n\\]\n\n## Symmetry of Routes\n\nTo identify unique flight routes between two cities, we standardize the order of cities in each route. Specifically, we ensure that the lexicographically smaller city name is always listed as the first city (`city1`), and the larger city is listed as the second city (`city2`). This ensures that a flight from City A to City B is treated the same as a flight from City B to City A.\n\n## Average Route Distance\n\nOnce the distances for all flights between two cities are computed, the average distance for each city pair is calculated by summing the distances and dividing by the total number of flights between those cities:\n\n\\[\n\\text{Average Distance} = \\frac{\\sum \\text{Flight Distances}}{\\text{Number of Flights}}\n\\]\n\n## Conclusion\n\nThis method of flight route distance calculation provides a reliable way to determine the great-circle distance between cities based on the coordinates of their respective airports. The use of the Haversine formula ensures accurate results for distances on the Earth's surface, making it ideal for aviation and travel analysis." }, { "question": "What is the highest monthly delivered orders volume in the year with the lowest annual delivered orders volume among 2016, 2017, and 2018?", "schema": "CREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the highest monthly delivered orders volume in the year with the lowest annual delivered orders volume among 2016, 2017, and 2018?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "I need you to look into the actor collaborations and tell me how many actors have made more films with Yash Chopra than with any other director. This will help us understand his influence on the industry better.", "schema": "CREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Help', 'Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Yash Chopra', 'Yash Chopra', ' Chopra', ' Yash', ' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Help', 'Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Yash Chopra', 'Yash Chopra', ' Chopra', ' Yash', ' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nI need you to look into the actor collaborations and tell me how many actors have made more films with Yash Chopra than with any other director. This will help us understand his influence on the industry better.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the difference in average spending between customers who bought albums from the best-selling artist and those who bought from the least-selling artist? If there is a tie for either best-selling or lowest-selling, choose the artist whose name comes first alphabetically.", "schema": "CREATE TABLE albums (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_albums_artistid FOREIGN KEY (ArtistId) REFERENCES artists (ArtistId)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['genres', 'media_types']\n seq TEXT, -- example: [25, 5]\n);\n\nCREATE TABLE artists (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE customers (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customers_supportrepid FOREIGN KEY (SupportRepId) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE employees (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employees_reportsto FOREIGN KEY (ReportsTo) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE genres (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE invoices (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoices_customerid FOREIGN KEY (CustomerId) REFERENCES customers (CustomerId)\n);\n\nCREATE TABLE invoice_items (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoice_items_invoiceid FOREIGN KEY (InvoiceId) REFERENCES invoices (InvoiceId),\n CONSTRAINT fk_invoice_items_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE media_types (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE playlists (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE playlist_track (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlist_track_playlistid FOREIGN KEY (PlaylistId) REFERENCES playlists (PlaylistId),\n CONSTRAINT fk_playlist_track_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE tracks (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_tracks_albumid FOREIGN KEY (AlbumId) REFERENCES albums (AlbumId),\n CONSTRAINT fk_tracks_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES media_types (MediaTypeId),\n CONSTRAINT fk_tracks_genreid FOREIGN KEY (GenreId) REFERENCES genres (GenreId)\n);\n\nCREATE TABLE sqlite_stat1 (\n tbl TEXT, -- example: ['customers', 'albums', 'artists', 'tracks', 'playlist_track']\n idx TEXT, -- example: ['IFK_TrackMediaTypeId', 'IFK_TrackGenreId']\n stat TEXT, -- example: ['3503 701', '3503 141']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE albums (\n AlbumId INTEGER, -- example: [1, 4]\n Title NVARCHAR(160), -- example: ['For Those About To Rock We Salute You', 'Balls to the Wall']\n ArtistId INTEGER, -- example: [1, 2]\n PRIMARY KEY (AlbumId),\n CONSTRAINT fk_albums_artistid FOREIGN KEY (ArtistId) REFERENCES artists (ArtistId)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['genres', 'media_types']\n seq TEXT, -- example: [25, 5]\n);\n\nCREATE TABLE artists (\n ArtistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['AC/DC', 'Accept']\n PRIMARY KEY (ArtistId)\n);\n\nCREATE TABLE customers (\n CustomerId INTEGER, -- example: [1, 3]\n FirstName NVARCHAR(40), -- example: ['Luís', 'Leonie']\n LastName NVARCHAR(20), -- example: ['Gonçalves', 'Köhler']\n Company NVARCHAR(80), -- example: ['Embraer - Empresa Brasileira de Aeronáut', 'JetBrains s.r.o.']\n Address NVARCHAR(70), -- example: ['Av. Brigadeiro Faria Lima, 2170', 'Theodor-Heuss-Straße 34']\n City NVARCHAR(40), -- example: ['São José dos Campos', 'Stuttgart']\n State NVARCHAR(40), -- example: ['SP', 'QC']\n Country NVARCHAR(40), -- example: ['Brazil', 'Germany']\n PostalCode NVARCHAR(10), -- example: ['12227-000', '70174']\n Phone NVARCHAR(24), -- example: ['+55 (12) 3923-5555', '+49 0711 2842222']\n Fax NVARCHAR(24), -- example: ['+55 (12) 3923-5566', '+420 2 4172 5555']\n Email NVARCHAR(60), -- example: ['luisg@embraer.com.br', 'leonekohler@surfeu.de']\n SupportRepId INTEGER, -- example: [3, 4]\n PRIMARY KEY (CustomerId),\n CONSTRAINT fk_customers_supportrepid FOREIGN KEY (SupportRepId) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE employees (\n EmployeeId INTEGER, -- example: [1, 2]\n LastName NVARCHAR(20), -- example: ['Adams', 'Edwards']\n FirstName NVARCHAR(20), -- example: ['Andrew', 'Nancy']\n Title NVARCHAR(30), -- example: ['General Manager', 'Sales Manager']\n ReportsTo INTEGER, -- example: [1, 2]\n BirthDate DATETIME, -- example: ['1962-02-18 00:00:00', '1958-12-08 00:00:00']\n HireDate DATETIME, -- example: ['2002-08-14 00:00:00', '2002-05-01 00:00:00']\n Address NVARCHAR(70), -- example: ['11120 Jasper Ave NW', '825 8 Ave SW']\n City NVARCHAR(40), -- example: ['Edmonton', 'Calgary']\n State NVARCHAR(40), -- example: ['AB']\n Country NVARCHAR(40), -- example: ['Canada']\n PostalCode NVARCHAR(10), -- example: ['T5K 2N1', 'T2P 2T3']\n Phone NVARCHAR(24), -- example: ['+1 (780) 428-9482', '+1 (403) 262-3443']\n Fax NVARCHAR(24), -- example: ['+1 (780) 428-3457', '+1 (403) 262-3322']\n Email NVARCHAR(60), -- example: ['andrew@chinookcorp.com', 'nancy@chinookcorp.com']\n PRIMARY KEY (EmployeeId),\n CONSTRAINT fk_employees_reportsto FOREIGN KEY (ReportsTo) REFERENCES employees (EmployeeId)\n);\n\nCREATE TABLE genres (\n GenreId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Rock', 'Jazz']\n PRIMARY KEY (GenreId)\n);\n\nCREATE TABLE invoices (\n InvoiceId INTEGER, -- example: [98, 121]\n CustomerId INTEGER, -- example: [1, 2]\n InvoiceDate DATETIME, -- example: ['2009-01-01 00:00:00', '2009-01-02 00:00:00']\n BillingAddress NVARCHAR(70), -- example: ['Theodor-Heuss-Straße 34', 'Ullevålsveien 14']\n BillingCity NVARCHAR(40), -- example: ['Stuttgart', 'Oslo']\n BillingState NVARCHAR(40), -- example: ['AB', 'MA']\n BillingCountry NVARCHAR(40), -- example: ['Germany', 'Norway']\n BillingPostalCode NVARCHAR(10), -- example: ['70174', '0171']\n Total NUMERIC(10,2), -- example: [1.98, 3.96]\n PRIMARY KEY (InvoiceId),\n CONSTRAINT fk_invoices_customerid FOREIGN KEY (CustomerId) REFERENCES customers (CustomerId)\n);\n\nCREATE TABLE invoice_items (\n InvoiceLineId INTEGER, -- example: [579, 1]\n InvoiceId INTEGER, -- example: [1, 2]\n TrackId INTEGER, -- example: [1, 2]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n Quantity INTEGER, -- example: [1]\n PRIMARY KEY (InvoiceLineId),\n CONSTRAINT fk_invoice_items_invoiceid FOREIGN KEY (InvoiceId) REFERENCES invoices (InvoiceId),\n CONSTRAINT fk_invoice_items_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE media_types (\n MediaTypeId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['MPEG audio file', 'Protected AAC audio file']\n PRIMARY KEY (MediaTypeId)\n);\n\nCREATE TABLE playlists (\n PlaylistId INTEGER, -- example: [1, 2]\n Name NVARCHAR(120), -- example: ['Music', 'Movies']\n PRIMARY KEY (PlaylistId)\n);\n\nCREATE TABLE playlist_track (\n PlaylistId INTEGER, -- example: [1, 3]\n TrackId INTEGER, -- example: [1, 2]\n PRIMARY KEY (PlaylistId),\n CONSTRAINT fk_playlist_track_playlistid FOREIGN KEY (PlaylistId) REFERENCES playlists (PlaylistId),\n CONSTRAINT fk_playlist_track_trackid FOREIGN KEY (TrackId) REFERENCES tracks (TrackId)\n);\n\nCREATE TABLE tracks (\n TrackId INTEGER, -- example: [1, 6]\n Name NVARCHAR(200), -- example: ['For Those About To Rock (We Salute You)', 'Balls to the Wall']\n AlbumId INTEGER, -- example: [1, 2]\n MediaTypeId INTEGER, -- example: [1, 2]\n GenreId INTEGER, -- example: [1, 2]\n Composer NVARCHAR(220), -- example: ['Angus Young, Malcolm Young, Brian Johnso', 'F. Baltes, S. Kaufman, U. Dirkscneider &']\n Milliseconds INTEGER, -- example: [343719, 342562]\n Bytes INTEGER, -- example: [11170334, 5510424]\n UnitPrice NUMERIC(10,2), -- example: [0.99, 1.99]\n PRIMARY KEY (TrackId),\n CONSTRAINT fk_tracks_albumid FOREIGN KEY (AlbumId) REFERENCES albums (AlbumId),\n CONSTRAINT fk_tracks_mediatypeid FOREIGN KEY (MediaTypeId) REFERENCES media_types (MediaTypeId),\n CONSTRAINT fk_tracks_genreid FOREIGN KEY (GenreId) REFERENCES genres (GenreId)\n);\n\nCREATE TABLE sqlite_stat1 (\n tbl TEXT, -- example: ['customers', 'albums', 'artists', 'tracks', 'playlist_track']\n idx TEXT, -- example: ['IFK_TrackMediaTypeId', 'IFK_TrackGenreId']\n stat TEXT, -- example: ['3503 701', '3503 141']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the difference in average spending between customers who bought albums from the best-selling artist and those who bought from the least-selling artist? If there is a tie for either best-selling or lowest-selling, choose the artist whose name comes first alphabetically.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What are the total wickets taken by each bowler, their economy rate, their strike rate, and their best performance in a single match (most wickets taken, in the format \"wickets-runs\")? Ignore the extra runs data.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['bowled', 'caught']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['bat', 'field']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Player', 'Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['bowled', 'caught']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Special Words Definition\n\n## Batting Average\n- Batting average is a measure of a batsman's performance, calculated by dividing the total number of runs scored by the number of times they have been dismissed. A higher batting average indicates a more consistent and successful batsman.\n- Batting Average = Total Runs ÷ Total Dismissals\n\n## Strike Rate\n- In batting, strike rate indicates the scoring rate of a batsman, showing the average number of runs scored per 100 balls faced. A higher strike rate reflects an aggressive and fast-scoring batsman.\n- Strike Rate = (Total Runs ÷ Balls Faced) × 100\n\n## Wickets Taken\n- Wickets taken refers to the total number of times a bowler has successfully dismissed an opposing batsman. This statistic is a core measure of a bowler's effectiveness and impact on the game.\n\n## Economy Rate\n- Economy rate measures a bowler's efficiency by indicating the average number of runs conceded per over (6 balls) bowled. A lower economy rate shows greater control and efficiency in restricting the opposition's scoring.\n- Economy Rate = (Total Runs Conceded ÷ Balls Bowled) × 6\n\n## Wickets Taken\n- The number of times a bowler successfully dismisses a batsman in a single match. This metric is a direct indicator of the bowler's effectiveness, showing how many players they were able to remove from play.\n\n## Runs Given\n- The total number of runs scored by the batting side off a particular bowler’s deliveries in a single match. This value reflects the runs the bowler has conceded to the batting team, and a lower runs-given value is typically favorable for the bowler's performance.\nWhat are the total wickets taken by each bowler, their economy rate, their strike rate, and their best performance in a single match (most wickets taken, in the format \"wickets-runs\")? Ignore the extra runs data.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Special Words Definition\n\n## Batting Average\n- Batting average is a measure of a batsman's performance, calculated by dividing the total number of runs scored by the number of times they have been dismissed. A higher batting average indicates a more consistent and successful batsman.\n- Batting Average = Total Runs ÷ Total Dismissals\n\n## Strike Rate\n- In batting, strike rate indicates the scoring rate of a batsman, showing the average number of runs scored per 100 balls faced. A higher strike rate reflects an aggressive and fast-scoring batsman.\n- Strike Rate = (Total Runs ÷ Balls Faced) × 100\n\n## Wickets Taken\n- Wickets taken refers to the total number of times a bowler has successfully dismissed an opposing batsman. This statistic is a core measure of a bowler's effectiveness and impact on the game.\n\n## Economy Rate\n- Economy rate measures a bowler's efficiency by indicating the average number of runs conceded per over (6 balls) bowled. A lower economy rate shows greater control and efficiency in restricting the opposition's scoring.\n- Economy Rate = (Total Runs Conceded ÷ Balls Bowled) × 6\n\n## Wickets Taken\n- The number of times a bowler successfully dismisses a batsman in a single match. This metric is a direct indicator of the bowler's effectiveness, showing how many players they were able to remove from play.\n\n## Runs Given\n- The total number of runs scored by the batting side off a particular bowler’s deliveries in a single match. This value reflects the runs the bowler has conceded to the batting team, and a lower runs-given value is typically favorable for the bowler's performance." }, { "question": "Which product has the smallest change in sales share for each product from the top 20% of products by total sales between Q4 in 2019 and 2020 in US without any promotion?", "schema": "CREATE TABLE countries (\n country_id INTEGER, -- example: [52769, 52770]\n country_iso_code CHAR(2), -- example: ['US', 'SG', 'IT']\n country_name TEXT, -- example: ['Singapore', 'Italy']\n country_subregion TEXT, -- example: ['Asia', 'Western Europe']\n country_subregion_id INTEGER, -- example: [52793, 52799]\n country_region TEXT, -- example: ['Asia', 'Europe']\n country_region_id INTEGER, -- example: [52802, 52803]\n country_total TEXT, -- example: ['World total']\n country_total_id INTEGER, -- example: [52806]\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE customers (\n cust_id INTEGER, -- example: [1, 2]\n cust_first_name TEXT, -- example: ['Abigail', 'Anne']\n cust_last_name TEXT, -- example: ['Chang', 'Kessel', 'Koch']\n cust_gender CHAR(1), -- example: ['M', 'F']\n cust_year_of_birth INTEGER, -- example: [1957, 1968]\n cust_marital_status TEXT, -- example: ['single', 'married']\n cust_street_address TEXT, -- example: ['7 South 3rd Circle', '7 South Airway Circle']\n cust_postal_code TEXT, -- example: ['30828', '86319']\n cust_city TEXT, -- example: ['Downham Market', 'Salamanca']\n cust_city_id INTEGER, -- example: [51396, 52286]\n cust_state_province TEXT, -- example: ['England - Norfolk', 'Salamanca']\n cust_state_province_id INTEGER, -- example: [52591, 52733]\n country_id INTEGER, -- example: [52789, 52778]\n cust_main_phone_number TEXT, -- example: ['127-379-8954', '680-327-1419']\n cust_income_level TEXT, -- example: ['G: 130,000 - 149,999', 'I: 170,000 - 189,999']\n cust_credit_limit REAL, -- example: [9000.0, 10000.0]\n cust_email TEXT, -- example: ['Kessel@company.example.com', 'Koch@company.example.com']\n cust_total TEXT, -- example: ['Customer total']\n cust_total_id INTEGER, -- example: [52772]\n cust_src_id INTEGER,\n cust_eff_from DATE, -- example: ['2019-01-01']\n cust_eff_to DATE,\n cust_valid CHAR(1), -- example: ['I', 'A']\n PRIMARY KEY (cust_id),\n CONSTRAINT fk_customers_country_id FOREIGN KEY (country_id) REFERENCES countries (country_id)\n);\n\nCREATE TABLE promotions (\n promo_id INTEGER, -- example: [33, 34]\n promo_name TEXT, -- example: ['post promotion #20-33', 'newspaper promotion #19-34']\n promo_subcategory TEXT, -- example: ['downtown billboard', 'coupon news']\n promo_subcategory_id INTEGER, -- example: [20, 19]\n promo_category TEXT, -- example: ['post', 'newspaper']\n promo_category_id INTEGER, -- example: [9, 8]\n promo_cost REAL, -- example: [77200.0, 22400.0]\n promo_begin_date DATE, -- example: ['2019-09-15', '2019-07-16']\n promo_end_date DATE, -- example: ['2019-11-15', '2019-09-16']\n promo_total TEXT, -- example: ['Promotion total']\n promo_total_id INTEGER, -- example: [1]\n PRIMARY KEY (promo_id)\n);\n\nCREATE TABLE products (\n prod_id INTEGER, -- example: [14, 19]\n prod_name TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket Bat Bag']\n prod_desc TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket bat bag']\n prod_subcategory TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_subcategory_id INTEGER, -- example: [2035, 2051]\n prod_subcategory_desc TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_category TEXT, -- example: ['Baseball', 'Cricket']\n prod_category_id INTEGER, -- example: [203, 205]\n prod_category_desc TEXT, -- example: ['Baseball', 'Cricket']\n prod_weight_class INTEGER, -- example: [1]\n prod_unit_of_measure TEXT, -- example: ['U']\n prod_pack_size TEXT, -- example: ['P']\n supplier_id INTEGER, -- example: [1]\n prod_status TEXT, -- example: ['STATUS']\n prod_list_price REAL, -- example: [999.99, 55.99]\n prod_min_price REAL, -- example: [999.99, 55.99]\n prod_total TEXT, -- example: ['TOTAL']\n prod_total_id INTEGER, -- example: [1]\n prod_src_id INTEGER,\n prod_eff_from DATE, -- example: ['2019-01-01 00:00:00']\n prod_eff_to DATE,\n prod_valid CHAR(1), -- example: ['A']\n PRIMARY KEY (prod_id)\n);\n\nCREATE TABLE times (\n time_id DATE, -- example: ['2019-01-01', '2019-01-02']\n day_name TEXT, -- example: ['Friday', 'Saturday']\n day_number_in_week INTEGER, -- example: [5, 6]\n day_number_in_month INTEGER, -- example: [31, 1]\n calendar_week_number INTEGER, -- example: [22, 23]\n fiscal_week_number INTEGER, -- example: [22, 23]\n week_ending_day DATE, -- example: ['2019-06-02', '2019-06-09']\n week_ending_day_id INTEGER, -- example: [1670, 1506]\n calendar_month_number INTEGER, -- example: [5, 6]\n fiscal_month_number INTEGER, -- example: [5, 6]\n calendar_month_desc TEXT, -- example: ['2019-05', '2019-06']\n calendar_month_id INTEGER, -- example: [1676, 1677]\n fiscal_month_desc TEXT, -- example: ['2019-05', '2019-06']\n fiscal_month_id INTEGER, -- example: [1724, 1725]\n days_in_cal_month INTEGER, -- example: [31, 30]\n days_in_fis_month INTEGER, -- example: [35, 28]\n end_of_cal_month DATE, -- example: ['2019-05-31', '2019-06-30']\n end_of_fis_month DATE, -- example: ['2019-05-31', '2019-06-28']\n calendar_month_name TEXT, -- example: ['May', 'June']\n fiscal_month_name TEXT, -- example: ['May', 'June']\n calendar_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n calendar_quarter_id INTEGER, -- example: [1770, 1771]\n fiscal_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n fiscal_quarter_id INTEGER, -- example: [1786, 1787]\n days_in_cal_quarter INTEGER, -- example: [91, 92]\n days_in_fis_quarter INTEGER, -- example: [91, 88]\n end_of_cal_quarter DATE, -- example: ['2019-06-30', '2019-09-30']\n end_of_fis_quarter DATE, -- example: ['2019-06-28', '2019-09-27']\n calendar_quarter_number INTEGER, -- example: [2, 3]\n fiscal_quarter_number INTEGER, -- example: [2, 3]\n calendar_year INTEGER, -- example: [2019, 2020]\n calendar_year_id INTEGER, -- example: [1802, 1803]\n fiscal_year INTEGER, -- example: [2019, 2020]\n fiscal_year_id INTEGER, -- example: [1806, 1807]\n days_in_cal_year INTEGER, -- example: [365, 366]\n days_in_fis_year INTEGER, -- example: [361, 364]\n end_of_cal_year DATE, -- example: ['2019-12-31', '2020-12-31']\n end_of_fis_year DATE, -- example: ['2019-12-27', '2020-12-26']\n PRIMARY KEY (time_id)\n);\n\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [2, 3]\n channel_desc TEXT, -- example: ['Partners', 'Direct Sales']\n channel_class TEXT, -- example: ['Others', 'Direct']\n channel_class_id INTEGER, -- example: [14, 12]\n channel_total TEXT, -- example: ['Channel total']\n channel_total_id INTEGER, -- example: [1]\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE sales (\n prod_id INTEGER, -- example: [13, 14]\n cust_id INTEGER, -- example: [987, 1660]\n time_id DATE, -- example: ['2019-01-10', '2019-01-20']\n channel_id INTEGER, -- example: [3, 2]\n promo_id INTEGER, -- example: [999, 33]\n quantity_sold INTEGER, -- example: [1]\n amount_sold REAL, -- example: [1232.16, 1205.99]\n CONSTRAINT fk_sales_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_sales_cust_id FOREIGN KEY (cust_id) REFERENCES customers (cust_id),\n CONSTRAINT fk_sales_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_sales_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id),\n CONSTRAINT fk_sales_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id)\n);\n\nCREATE TABLE costs (\n prod_id INTEGER, -- example: [13, 14]\n time_id DATE, -- example: ['2019-02-10', '2019-01-19']\n promo_id INTEGER, -- example: [350, 351]\n channel_id INTEGER, -- example: [2, 3]\n unit_cost REAL, -- example: [813.07, 886.45]\n unit_price REAL, -- example: [1237.31, 1108.99]\n CONSTRAINT fk_costs_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_costs_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_costs_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id),\n CONSTRAINT fk_costs_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id)\n);\n\nCREATE TABLE supplementary_demographics (\n cust_id INTEGER, -- example: [100001, 100002]\n education TEXT, -- example: ['< Bach.', 'Bach.']\n occupation TEXT, -- example: ['Sales', 'Exec.', 'Prof.']\n household_size TEXT, -- example: ['2', '3']\n yrs_residence INTEGER, -- example: [3, 4]\n affinity_card INTEGER, -- example: [0, 1]\n cricket INTEGER, -- example: [0, 1]\n baseball INTEGER, -- example: [0, 1]\n tennis INTEGER, -- example: [1, 0]\n soccer INTEGER, -- example: [1, 0]\n golf INTEGER, -- example: [1]\n `unknown` INTEGER, -- example: [0, 1]\n misc INTEGER, -- example: [0, 1]\n comments TEXT, -- example: ['Thanks a lot for my new affinity card. I', 'The more times that I shop at your store']\n PRIMARY KEY (cust_id)\n);\n\nCREATE TABLE currency (\n country TEXT, -- example: ['Singapore', 'Italy']\n `year` INTEGER, -- example: [2019, 2020]\n `month` INTEGER, -- example: [5, 6]\n to_us REAL, -- example: [1.0, 0.74]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE countries (\n country_id INTEGER, -- example: [52769, 52770]\n country_iso_code CHAR(2), -- example: ['US', 'SG', 'IT']\n country_name TEXT, -- example: ['Singapore', 'Italy']\n country_subregion TEXT, -- example: ['Asia', 'Western Europe']\n country_subregion_id INTEGER, -- example: [52793, 52799]\n country_region TEXT, -- example: ['Asia', 'Europe']\n country_region_id INTEGER, -- example: [52802, 52803]\n country_total TEXT, -- example: ['World total']\n country_total_id INTEGER, -- example: [52806]\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE customers (\n cust_id INTEGER, -- example: [1, 2]\n cust_first_name TEXT, -- example: ['Abigail', 'Anne']\n cust_last_name TEXT, -- example: ['Chang', 'Kessel', 'Koch']\n cust_gender CHAR(1), -- example: ['M', 'F']\n cust_year_of_birth INTEGER, -- example: [1957, 1968]\n cust_marital_status TEXT, -- example: ['single', 'married']\n cust_street_address TEXT, -- example: ['7 South 3rd Circle', '7 South Airway Circle']\n cust_postal_code TEXT, -- example: ['30828', '86319']\n cust_city TEXT, -- example: ['Downham Market', 'Salamanca']\n cust_city_id INTEGER, -- example: [51396, 52286]\n cust_state_province TEXT, -- example: ['England - Norfolk', 'Salamanca']\n cust_state_province_id INTEGER, -- example: [52591, 52733]\n country_id INTEGER, -- example: [52789, 52778]\n cust_main_phone_number TEXT, -- example: ['127-379-8954', '680-327-1419']\n cust_income_level TEXT, -- example: ['G: 130,000 - 149,999', 'I: 170,000 - 189,999']\n cust_credit_limit REAL, -- example: [9000.0, 10000.0]\n cust_email TEXT, -- example: ['Kessel@company.example.com', 'Koch@company.example.com']\n cust_total TEXT, -- example: ['Customer total']\n cust_total_id INTEGER, -- example: [52772]\n cust_src_id INTEGER,\n cust_eff_from DATE, -- example: ['2019-01-01']\n cust_eff_to DATE,\n cust_valid CHAR(1), -- example: ['I', 'A']\n PRIMARY KEY (cust_id),\n CONSTRAINT fk_customers_country_id FOREIGN KEY (country_id) REFERENCES countries (country_id)\n);\n\nCREATE TABLE promotions (\n promo_id INTEGER, -- example: [33, 34]\n promo_name TEXT, -- example: ['post promotion #20-33', 'newspaper promotion #19-34']\n promo_subcategory TEXT, -- example: ['downtown billboard', 'coupon news']\n promo_subcategory_id INTEGER, -- example: [20, 19]\n promo_category TEXT, -- example: ['post', 'newspaper']\n promo_category_id INTEGER, -- example: [9, 8]\n promo_cost REAL, -- example: [77200.0, 22400.0]\n promo_begin_date DATE, -- example: ['2019-09-15', '2019-07-16']\n promo_end_date DATE, -- example: ['2019-11-15', '2019-09-16']\n promo_total TEXT, -- example: ['Promotion total']\n promo_total_id INTEGER, -- example: [1]\n PRIMARY KEY (promo_id)\n);\n\nCREATE TABLE products (\n prod_id INTEGER, -- example: [14, 19]\n prod_name TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket Bat Bag']\n prod_desc TEXT, -- example: ['Pitching Machine and Batting Cage Combo', 'Cricket bat bag']\n prod_subcategory TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_subcategory_id INTEGER, -- example: [2035, 2051]\n prod_subcategory_desc TEXT, -- example: ['Training Aids and Equipment', 'Cricket Bat']\n prod_category TEXT, -- example: ['Baseball', 'Cricket']\n prod_category_id INTEGER, -- example: [203, 205]\n prod_category_desc TEXT, -- example: ['Baseball', 'Cricket']\n prod_weight_class INTEGER, -- example: [1]\n prod_unit_of_measure TEXT, -- example: ['U']\n prod_pack_size TEXT, -- example: ['P']\n supplier_id INTEGER, -- example: [1]\n prod_status TEXT, -- example: ['STATUS']\n prod_list_price REAL, -- example: [999.99, 55.99]\n prod_min_price REAL, -- example: [999.99, 55.99]\n prod_total TEXT, -- example: ['TOTAL']\n prod_total_id INTEGER, -- example: [1]\n prod_src_id INTEGER,\n prod_eff_from DATE, -- example: ['2019-01-01 00:00:00']\n prod_eff_to DATE,\n prod_valid CHAR(1), -- example: ['A']\n PRIMARY KEY (prod_id)\n);\n\nCREATE TABLE times (\n time_id DATE, -- example: ['2019-01-01', '2019-01-02']\n day_name TEXT, -- example: ['Friday', 'Saturday']\n day_number_in_week INTEGER, -- example: [5, 6]\n day_number_in_month INTEGER, -- example: [31, 1]\n calendar_week_number INTEGER, -- example: [22, 23]\n fiscal_week_number INTEGER, -- example: [22, 23]\n week_ending_day DATE, -- example: ['2019-06-02', '2019-06-09']\n week_ending_day_id INTEGER, -- example: [1670, 1506]\n calendar_month_number INTEGER, -- example: [5, 6]\n fiscal_month_number INTEGER, -- example: [5, 6]\n calendar_month_desc TEXT, -- example: ['2019-05', '2019-06']\n calendar_month_id INTEGER, -- example: [1676, 1677]\n fiscal_month_desc TEXT, -- example: ['2019-05', '2019-06']\n fiscal_month_id INTEGER, -- example: [1724, 1725]\n days_in_cal_month INTEGER, -- example: [31, 30]\n days_in_fis_month INTEGER, -- example: [35, 28]\n end_of_cal_month DATE, -- example: ['2019-05-31', '2019-06-30']\n end_of_fis_month DATE, -- example: ['2019-05-31', '2019-06-28']\n calendar_month_name TEXT, -- example: ['May', 'June']\n fiscal_month_name TEXT, -- example: ['May', 'June']\n calendar_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n calendar_quarter_id INTEGER, -- example: [1770, 1771]\n fiscal_quarter_desc CHAR(7), -- example: ['2019-02', '2019-03']\n fiscal_quarter_id INTEGER, -- example: [1786, 1787]\n days_in_cal_quarter INTEGER, -- example: [91, 92]\n days_in_fis_quarter INTEGER, -- example: [91, 88]\n end_of_cal_quarter DATE, -- example: ['2019-06-30', '2019-09-30']\n end_of_fis_quarter DATE, -- example: ['2019-06-28', '2019-09-27']\n calendar_quarter_number INTEGER, -- example: [2, 3]\n fiscal_quarter_number INTEGER, -- example: [2, 3]\n calendar_year INTEGER, -- example: [2019, 2020]\n calendar_year_id INTEGER, -- example: [1802, 1803]\n fiscal_year INTEGER, -- example: [2019, 2020]\n fiscal_year_id INTEGER, -- example: [1806, 1807]\n days_in_cal_year INTEGER, -- example: [365, 366]\n days_in_fis_year INTEGER, -- example: [361, 364]\n end_of_cal_year DATE, -- example: ['2019-12-31', '2020-12-31']\n end_of_fis_year DATE, -- example: ['2019-12-27', '2020-12-26']\n PRIMARY KEY (time_id)\n);\n\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [2, 3]\n channel_desc TEXT, -- example: ['Partners', 'Direct Sales']\n channel_class TEXT, -- example: ['Others', 'Direct']\n channel_class_id INTEGER, -- example: [14, 12]\n channel_total TEXT, -- example: ['Channel total']\n channel_total_id INTEGER, -- example: [1]\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE sales (\n prod_id INTEGER, -- example: [13, 14]\n cust_id INTEGER, -- example: [987, 1660]\n time_id DATE, -- example: ['2019-01-10', '2019-01-20']\n channel_id INTEGER, -- example: [3, 2]\n promo_id INTEGER, -- example: [999, 33]\n quantity_sold INTEGER, -- example: [1]\n amount_sold REAL, -- example: [1232.16, 1205.99]\n CONSTRAINT fk_sales_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_sales_cust_id FOREIGN KEY (cust_id) REFERENCES customers (cust_id),\n CONSTRAINT fk_sales_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_sales_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id),\n CONSTRAINT fk_sales_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id)\n);\n\nCREATE TABLE costs (\n prod_id INTEGER, -- example: [13, 14]\n time_id DATE, -- example: ['2019-02-10', '2019-01-19']\n promo_id INTEGER, -- example: [350, 351]\n channel_id INTEGER, -- example: [2, 3]\n unit_cost REAL, -- example: [813.07, 886.45]\n unit_price REAL, -- example: [1237.31, 1108.99]\n CONSTRAINT fk_costs_prod_id FOREIGN KEY (prod_id) REFERENCES products (prod_id),\n CONSTRAINT fk_costs_time_id FOREIGN KEY (time_id) REFERENCES times (time_id),\n CONSTRAINT fk_costs_promo_id FOREIGN KEY (promo_id) REFERENCES promotions (promo_id),\n CONSTRAINT fk_costs_channel_id FOREIGN KEY (channel_id) REFERENCES channels (channel_id)\n);\n\nCREATE TABLE supplementary_demographics (\n cust_id INTEGER, -- example: [100001, 100002]\n education TEXT, -- example: ['< Bach.', 'Bach.']\n occupation TEXT, -- example: ['Sales', 'Exec.', 'Prof.']\n household_size TEXT, -- example: ['2', '3']\n yrs_residence INTEGER, -- example: [3, 4]\n affinity_card INTEGER, -- example: [0, 1]\n cricket INTEGER, -- example: [0, 1]\n baseball INTEGER, -- example: [0, 1]\n tennis INTEGER, -- example: [1, 0]\n soccer INTEGER, -- example: [1, 0]\n golf INTEGER, -- example: [1]\n `unknown` INTEGER, -- example: [0, 1]\n misc INTEGER, -- example: [0, 1]\n comments TEXT, -- example: ['Thanks a lot for my new affinity card. I', 'The more times that I shop at your store']\n PRIMARY KEY (cust_id)\n);\n\nCREATE TABLE currency (\n country TEXT, -- example: ['Singapore', 'Italy']\n `year` INTEGER, -- example: [2019, 2020]\n `month` INTEGER, -- example: [5, 6]\n to_us REAL, -- example: [1.0, 0.74]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich product has the smallest change in sales share for each product from the top 20% of products by total sales between Q4 in 2019 and 2020 in US without any promotion?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you analyze our data and identify which any consecutive ten-year period had the largest number of films? Only output the start year and the total count for that specific period.", "schema": "CREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Movie (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n title TEXT, -- example: ['Mowgli', \"Ocean's Eight\"]\n `year` TEXT, -- example: ['2018', '2012']\n rating REAL, -- example: [6.6, 6.2]\n num_votes INTEGER, -- example: [21967, 110861]\n);\n\nCREATE TABLE Genre (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Adventure, Drama, Fantasy ', 'Action, Comedy, Crime ']\n GID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE `Language` (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['English', 'Marathi']\n LAID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Country (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['UK', 'USA']\n CID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Location (\n `index` INTEGER, -- example: [0, 1]\n Name TEXT, -- example: ['Durban, South Africa', 'New York City, New York, USA']\n LID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Location (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Country (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n CID REAL, -- example: [0.0, 1.0]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Language (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n LAID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Genre (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n GID INTEGER, -- example: [0, 1]\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE Person (\n `index` INTEGER, -- example: [0, 1]\n PID TEXT, -- example: ['nm0000288', 'nm0000949']\n Name TEXT, -- example: [' Christian Bale', ' Cate Blanchett']\n Gender TEXT, -- example: ['Male', 'Female']\n);\n\nCREATE TABLE M_Producer (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0057655', ' nm0147080']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Director (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: ['nm0785227', 'nm0002657']\n ID INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE M_Cast (\n `index` INTEGER, -- example: [0, 1]\n MID TEXT, -- example: ['tt2388771', 'tt5164214']\n PID TEXT, -- example: [' nm0000288', ' nm0000949']\n ID INTEGER, -- example: [0, 1]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you analyze our data and identify which any consecutive ten-year period had the largest number of films? Only output the start year and the total count for that specific period.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the difference in average month-end balance between the month with the most and the month with the fewest customers having a positive balance in 2020?", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the difference in average month-end balance between the month with the most and the month with the fewest customers having a positive balance in 2020?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the average total quantity across all final packaging combinations, considering all items contained within each combination?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the average total quantity across all final packaging combinations, considering all items contained within each combination?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For alien data, how many of the top 10 states by alien population have a higher percentage of friendly aliens than hostile aliens, with an average alien age exceeding 200?", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['top', 'afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['ag', 'tyrus', 'ealasaid']\n last_name TEXT, -- example: ['state', 'have', 'top', 'how', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['friendly', 'than', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['ag', 'jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Ag', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['State', 'Have', 'Top', 'How', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['top', 'afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Brown', 'Cantwell']\n middle_name TEXT, -- example: ['L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['ag', 'tyrus', 'ealasaid']\n last_name TEXT, -- example: ['state', 'have', 'top', 'how', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['friendly', 'than', 'tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['ag', 'jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Ag', 'Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['State', 'Have', 'Top', 'How', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['ag', 'af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor alien data, how many of the top 10 states by alien population have a higher percentage of friendly aliens than hostile aliens, with an average alien age exceeding 200?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you find the average payments and order counts for the five cities with the lowest total payments from delivered orders?", "schema": "CREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you find the average payments and order counts for the five cities with the lowest total payments from delivered orders?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "I would like to know the given names of baseball players who have achieved the highest value of games played, runs, hits, and home runs, with their corresponding score values.", "schema": "CREATE TABLE all_star (\n player_id TEXT, -- example: ['gomezle01', 'ferreri01']\n `year` INTEGER, -- example: [1933, 1934]\n game_num INTEGER, -- example: [0, 2]\n game_id TEXT, -- example: ['ALS193307060', 'NLS193407100']\n team_id TEXT, -- example: ['NYA', 'BOS']\n league_id TEXT, -- example: ['AL', 'NL']\n gp NUMERIC, -- example: [1, 0]\n starting_pos NUMERIC, -- example: [1, 2]\n);\n\nCREATE TABLE appearances (\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n player_id TEXT, -- example: ['barnero01', 'barrofr01']\n g_all NUMERIC, -- example: [31, 18]\n gs NUMERIC, -- example: [89, 0]\n g_batting INTEGER, -- example: [31, 18]\n g_defense NUMERIC, -- example: [31, 18]\n g_p INTEGER, -- example: [0, 31]\n g_c INTEGER, -- example: [0, 7]\n g_1b INTEGER, -- example: [0, 30]\n g_2b INTEGER, -- example: [16, 1]\n g_3b INTEGER, -- example: [0, 1]\n g_ss INTEGER, -- example: [15, 0]\n g_lf INTEGER, -- example: [0, 13]\n g_cf INTEGER, -- example: [0, 1]\n g_rf INTEGER, -- example: [0, 4]\n g_of INTEGER, -- example: [0, 17]\n g_dh NUMERIC, -- example: [0, 3]\n g_ph NUMERIC, -- example: [23, 0]\n g_pr NUMERIC, -- example: [0, 18]\n);\n\nCREATE TABLE manager_award (\n player_id TEXT, -- example: ['larusto01', 'lasorto01']\n award_id TEXT, -- example: ['BBWAA Manager of the year', 'TSN Manager of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n tie TEXT, -- example: ['Y']\n notes NUMERIC\n);\n\nCREATE TABLE player_award (\n player_id TEXT, -- example: ['bondto01', 'hinespa01']\n award_id TEXT, -- example: ['Pitching Triple Crown', 'Triple Crown']\n `year` INTEGER, -- example: [1877, 1878]\n league_id TEXT, -- example: ['NL', 'AA']\n tie TEXT, -- example: ['Y']\n notes TEXT, -- example: ['1B', '2B']\n);\n\nCREATE TABLE manager_award_vote (\n award_id TEXT, -- example: ['Mgr of the year', 'Mgr of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n player_id TEXT, -- example: ['altobjo01', 'coxbo01']\n points_won INTEGER, -- example: [7, 4]\n points_max INTEGER, -- example: [28, 24]\n votes_first INTEGER, -- example: [7, 4]\n);\n\nCREATE TABLE player_award_vote (\n award_id TEXT, -- example: ['Cy Young', 'MVP']\n `year` INTEGER, -- example: [1956, 1957]\n league_id TEXT, -- example: ['ML', 'AL']\n player_id TEXT, -- example: ['fordwh01', 'maglisa01']\n points_won NUMERIC, -- example: [1, 4]\n points_max INTEGER, -- example: [16, 18]\n votes_first NUMERIC, -- example: [1, 4]\n);\n\nCREATE TABLE batting (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n g INTEGER, -- example: [1, 25]\n ab NUMERIC, -- example: [4, 118]\n r NUMERIC, -- example: [0, 30]\n h NUMERIC, -- example: [0, 32]\n `double` NUMERIC, -- example: [0, 6]\n triple NUMERIC, -- example: [0, 5]\n hr NUMERIC, -- example: [0, 2]\n rbi NUMERIC, -- example: [0, 13]\n sb NUMERIC, -- example: [0, 8]\n cs NUMERIC, -- example: [0, 1]\n bb NUMERIC, -- example: [0, 4]\n so NUMERIC, -- example: [0, 5]\n ibb NUMERIC, -- example: [0, 5]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 5]\n sf NUMERIC, -- example: [0, 4]\n g_idp NUMERIC, -- example: [0, 2]\n);\n\nCREATE TABLE batting_postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n player_id TEXT, -- example: ['becanbu01', 'bradyst01']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n g INTEGER, -- example: [1, 3]\n ab INTEGER, -- example: [2, 10]\n r INTEGER, -- example: [0, 1]\n h INTEGER, -- example: [1, 0]\n `double` INTEGER, -- example: [0, 1]\n triple INTEGER, -- example: [0, 1]\n hr INTEGER, -- example: [0, 1]\n rbi INTEGER, -- example: [0, 1]\n sb INTEGER, -- example: [0, 1]\n cs NUMERIC, -- example: [0, 1]\n bb INTEGER, -- example: [0, 1]\n so INTEGER, -- example: [0, 1]\n ibb NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 1]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [1, 0]\n);\n\nCREATE TABLE player_college (\n player_id TEXT, -- example: ['aardsda01', 'abadan01']\n college_id TEXT, -- example: ['pennst', 'rice']\n `year` INTEGER, -- example: [2001, 2002]\n);\n\nCREATE TABLE fielding (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n pos TEXT, -- example: ['SS', '2B']\n g INTEGER, -- example: [1, 22]\n gs NUMERIC, -- example: [102, 113]\n inn_outs NUMERIC, -- example: [2773, 3093]\n po NUMERIC, -- example: [1, 67]\n a NUMERIC, -- example: [3, 72]\n e NUMERIC, -- example: [2, 42]\n dp NUMERIC, -- example: [0, 5]\n pb NUMERIC, -- example: [0, 12]\n wp NUMERIC, -- example: [19, 6]\n sb NUMERIC, -- example: [23, 32]\n cs NUMERIC, -- example: [16, 15]\n zr NUMERIC, -- example: [5, 0]\n);\n\nCREATE TABLE fielding_outfield (\n player_id TEXT, -- example: ['allisar01', 'ansonca01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n glf NUMERIC, -- example: [0, 1]\n gcf NUMERIC, -- example: [29, 0]\n grf NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE fielding_postseason (\n player_id TEXT, -- example: ['colliji01', 'crigelo01']\n `year` INTEGER, -- example: [1903, 1905]\n team_id TEXT, -- example: ['BOS', 'PIT']\n league_id TEXT, -- example: ['AL', 'NL']\n round TEXT, -- example: ['WS', 'ALCS']\n pos TEXT, -- example: ['3B', 'C']\n g INTEGER, -- example: [8, 4]\n gs NUMERIC, -- example: [8, 4]\n inn_outs NUMERIC, -- example: [213, 105]\n po INTEGER, -- example: [9, 54]\n a INTEGER, -- example: [18, 7]\n e INTEGER, -- example: [1, 3]\n dp INTEGER, -- example: [1, 2]\n tp INTEGER, -- example: [0, 1]\n pb NUMERIC, -- example: [0, 3]\n sb NUMERIC, -- example: [9, 6]\n cs NUMERIC, -- example: [3, 1]\n);\n\nCREATE TABLE hall_of_fame (\n player_id TEXT, -- example: ['cobbty01', 'ruthba01']\n yearid INTEGER, -- example: [1936, 1937]\n votedby TEXT, -- example: ['BBWAA', 'Veterans']\n ballots NUMERIC, -- example: [226, 78]\n needed NUMERIC, -- example: [170, 59]\n votes NUMERIC, -- example: [222, 215]\n inducted TEXT, -- example: ['Y', 'N']\n category TEXT, -- example: ['Player', 'Manager']\n needed_note TEXT, -- example: ['Top 20', '1st']\n);\n\nCREATE TABLE home_game (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n park_id TEXT, -- example: ['BOS01', 'NYC01']\n span_first TEXT, -- example: ['1871-05-16', '1871-05-27']\n span_last TEXT, -- example: ['1871-10-07', '1871-05-27']\n games INTEGER, -- example: [16, 1]\n openings INTEGER, -- example: [16, 1]\n attendance INTEGER, -- example: [32600, 3000]\n);\n\nCREATE TABLE manager (\n player_id TEXT, -- example: ['wrighha01', 'woodji01']\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n inseason INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [31, 28]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n rank NUMERIC, -- example: [3, 2]\n plyr_mgr TEXT, -- example: ['Y', 'N']\n);\n\nCREATE TABLE manager_half (\n player_id TEXT, -- example: ['hanlone01', 'vanhage01']\n `year` INTEGER, -- example: [1892, 1981]\n team_id TEXT, -- example: ['BLN', 'BRO']\n league_id TEXT, -- example: ['NL', 'AL']\n inseason INTEGER, -- example: [3, 1]\n half INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [56, 77]\n w INTEGER, -- example: [17, 26]\n l INTEGER, -- example: [39, 46]\n rank INTEGER, -- example: [12, 10]\n);\n\nCREATE TABLE player (\n player_id TEXT, -- example: ['aardsda01', 'aaronha01']\n birth_year NUMERIC, -- example: [1981, 1934]\n birth_month NUMERIC, -- example: [12, 2]\n birth_day NUMERIC, -- example: [27, 5]\n birth_country TEXT, -- example: ['USA', 'D.R.']\n birth_state TEXT, -- example: ['CO', 'AL']\n birth_city TEXT, -- example: ['Denver', 'Mobile']\n death_year NUMERIC, -- example: [1984, 1905]\n death_month NUMERIC, -- example: [8, 5]\n death_day NUMERIC, -- example: [16, 17]\n death_country TEXT, -- example: ['USA', 'Cuba']\n death_state TEXT, -- example: ['GA', 'NJ']\n death_city TEXT, -- example: ['Atlanta', 'Pemberton']\n name_first TEXT, -- example: ['Home Run', 'David', 'Hank']\n name_last TEXT, -- example: ['Score', 'Aardsma', 'Aaron']\n name_given TEXT, -- example: ['David Allan', 'Henry Louis']\n weight NUMERIC, -- example: [220, 180]\n height NUMERIC, -- example: [75, 72]\n bats TEXT, -- example: ['R', 'L']\n throws TEXT, -- example: ['R', 'L']\n debut TEXT, -- example: ['2004-04-06', '1954-04-13']\n final_game TEXT, -- example: ['2015-08-23', '1976-10-03']\n retro_id TEXT, -- example: ['aardd001', 'aaroh101']\n bbref_id TEXT, -- example: ['aardsda01', 'aaronha01']\n);\n\nCREATE TABLE park (\n park_id TEXT, -- example: ['ALB01', 'ALT01']\n park_name TEXT, -- example: ['Riverside Park', 'Columbia Park']\n park_alias TEXT, -- example: ['Edison Field; Anaheim Stadium', 'The Ballpark in Arlington; Ameriquest Fi']\n city TEXT, -- example: ['Albany', 'Altoona']\n state TEXT, -- example: ['NY', 'PA']\n country TEXT, -- example: ['US', 'MX']\n);\n\nCREATE TABLE pitching (\n player_id TEXT, -- example: ['bechtge01', 'brainas01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['PH1', 'WS3']\n league_id TEXT, -- example: ['NL', 'AA']\n w INTEGER, -- example: [1, 12]\n l INTEGER, -- example: [2, 15]\n g INTEGER, -- example: [3, 30]\n gs INTEGER, -- example: [3, 30]\n cg INTEGER, -- example: [2, 30]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts NUMERIC, -- example: [78, 792]\n h INTEGER, -- example: [43, 361]\n er INTEGER, -- example: [23, 132]\n hr INTEGER, -- example: [0, 4]\n bb INTEGER, -- example: [11, 37]\n so INTEGER, -- example: [1, 13]\n baopp NUMERIC, -- example: [0.53, 0.15]\n era NUMERIC, -- example: [7.96, 4.5]\n ibb NUMERIC, -- example: [1, 0]\n wp NUMERIC, -- example: [0, 8]\n hbp NUMERIC, -- example: [0, 10]\n bk INTEGER, -- example: [0, 2]\n bfp NUMERIC, -- example: [13, 14]\n gf NUMERIC, -- example: [0, 1]\n r INTEGER, -- example: [42, 292]\n sh NUMERIC, -- example: [1, 3]\n sf NUMERIC, -- example: [4, 1]\n g_idp NUMERIC, -- example: [6, 1]\n);\n\nCREATE TABLE pitching_postseason (\n player_id TEXT, -- example: ['becanbu01', 'keefeti01']\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n w INTEGER, -- example: [0, 3]\n l INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [1, 2]\n gs INTEGER, -- example: [1, 2]\n cg INTEGER, -- example: [1, 2]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts INTEGER, -- example: [18, 45]\n h INTEGER, -- example: [9, 10]\n er INTEGER, -- example: [7, 6]\n hr INTEGER, -- example: [0, 1]\n bb INTEGER, -- example: [2, 3]\n so INTEGER, -- example: [1, 12]\n baopp TEXT, -- example: ['0.23', '0.4']\n era NUMERIC, -- example: [10.5, 3.6]\n ibb NUMERIC, -- example: [0, 1]\n wp NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n bk NUMERIC, -- example: [0, 1]\n bfp NUMERIC, -- example: [134, 12]\n gf INTEGER, -- example: [0, 1]\n r INTEGER, -- example: [12, 9]\n sh NUMERIC, -- example: [0, 3]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE salary (\n `year` INTEGER, -- example: [1985, 1986]\n team_id TEXT, -- example: ['ATL', 'BAL']\n league_id TEXT, -- example: ['NL', 'AL']\n player_id TEXT, -- example: ['barkele01', 'bedrost01']\n salary INTEGER, -- example: [870000, 550000]\n);\n\nCREATE TABLE college (\n college_id TEXT, -- example: ['abilchrist', 'adelphi']\n name_full TEXT, -- example: ['Abilene Christian University', 'Adelphi University']\n city TEXT, -- example: ['Abilene', 'Garden City']\n state TEXT, -- example: ['TX', 'NY']\n country TEXT, -- example: ['USA']\n);\n\nCREATE TABLE postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id_winner TEXT, -- example: ['PRO', 'CHC']\n league_id_winner TEXT, -- example: ['NL', 'AA']\n team_id_loser TEXT, -- example: ['NYP', 'STL']\n league_id_loser TEXT, -- example: ['AA', 'NL']\n wins INTEGER, -- example: [3, 4]\n losses INTEGER, -- example: [0, 3]\n ties INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE team (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n franchise_id TEXT, -- example: ['BNA', 'CNA']\n div_id TEXT, -- example: ['W', 'E']\n rank INTEGER, -- example: [3, 2]\n g INTEGER, -- example: [31, 28]\n ghome NUMERIC, -- example: [66, 69]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n div_win TEXT, -- example: ['Y', 'N']\n wc_win TEXT, -- example: ['N', 'Y']\n lg_win TEXT, -- example: ['N', 'Y']\n ws_win TEXT, -- example: ['N', 'Y']\n r INTEGER, -- example: [401, 302]\n ab INTEGER, -- example: [1372, 1196]\n h INTEGER, -- example: [426, 323]\n `double` INTEGER, -- example: [70, 52]\n triple INTEGER, -- example: [37, 21]\n hr INTEGER, -- example: [3, 10]\n bb INTEGER, -- example: [60, 26]\n so NUMERIC, -- example: [19, 22]\n sb NUMERIC, -- example: [73, 69]\n cs NUMERIC, -- example: [15, 4]\n hbp NUMERIC, -- example: [47, 59]\n sf NUMERIC, -- example: [43, 58]\n ra INTEGER, -- example: [303, 241]\n er INTEGER, -- example: [109, 77]\n era NUMERIC, -- example: [3.55, 2.76]\n cg INTEGER, -- example: [22, 25]\n sho INTEGER, -- example: [1, 0]\n sv INTEGER, -- example: [3, 1]\n ipouts INTEGER, -- example: [828, 753]\n ha INTEGER, -- example: [367, 308]\n hra INTEGER, -- example: [2, 6]\n bba INTEGER, -- example: [42, 28]\n soa INTEGER, -- example: [23, 22]\n e INTEGER, -- example: [225, 218]\n dp NUMERIC, -- example: [42, 33]\n fp NUMERIC, -- example: [0.83, 0.82]\n name TEXT, -- example: ['Boston Red Stockings', 'Chicago White Stockings']\n park TEXT, -- example: ['South End Grounds I', 'Union Base-Ball Grounds']\n attendance NUMERIC, -- example: [121412, 147539]\n bpf INTEGER, -- example: [103, 104]\n ppf INTEGER, -- example: [98, 102]\n team_id_br TEXT, -- example: ['BOS', 'CHI']\n team_id_lahman45 TEXT, -- example: ['BS1', 'CH1']\n team_id_retro TEXT, -- example: ['BS1', 'CH1']\n);\n\nCREATE TABLE team_franchise (\n franchise_id TEXT, -- example: ['ALT', 'ANA']\n franchise_name TEXT, -- example: ['Altoona Mountain City', 'Los Angeles Angels of Anaheim']\n active TEXT, -- example: ['N', 'Y']\n na_assoc TEXT, -- example: ['PNA', 'BNA']\n);\n\nCREATE TABLE team_half (\n `year` INTEGER, -- example: [1981]\n league_id TEXT, -- example: ['NL', 'AL']\n team_id TEXT, -- example: ['ATL', 'BAL']\n half INTEGER, -- example: [1, 2]\n div_id TEXT, -- example: ['W', 'E']\n div_win TEXT, -- example: ['N']\n rank INTEGER, -- example: [4, 5]\n g INTEGER, -- example: [54, 52]\n w INTEGER, -- example: [25, 31]\n l INTEGER, -- example: [29, 27]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE all_star (\n player_id TEXT, -- example: ['gomezle01', 'ferreri01']\n `year` INTEGER, -- example: [1933, 1934]\n game_num INTEGER, -- example: [0, 2]\n game_id TEXT, -- example: ['ALS193307060', 'NLS193407100']\n team_id TEXT, -- example: ['NYA', 'BOS']\n league_id TEXT, -- example: ['AL', 'NL']\n gp NUMERIC, -- example: [1, 0]\n starting_pos NUMERIC, -- example: [1, 2]\n);\n\nCREATE TABLE appearances (\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n player_id TEXT, -- example: ['barnero01', 'barrofr01']\n g_all NUMERIC, -- example: [31, 18]\n gs NUMERIC, -- example: [89, 0]\n g_batting INTEGER, -- example: [31, 18]\n g_defense NUMERIC, -- example: [31, 18]\n g_p INTEGER, -- example: [0, 31]\n g_c INTEGER, -- example: [0, 7]\n g_1b INTEGER, -- example: [0, 30]\n g_2b INTEGER, -- example: [16, 1]\n g_3b INTEGER, -- example: [0, 1]\n g_ss INTEGER, -- example: [15, 0]\n g_lf INTEGER, -- example: [0, 13]\n g_cf INTEGER, -- example: [0, 1]\n g_rf INTEGER, -- example: [0, 4]\n g_of INTEGER, -- example: [0, 17]\n g_dh NUMERIC, -- example: [0, 3]\n g_ph NUMERIC, -- example: [23, 0]\n g_pr NUMERIC, -- example: [0, 18]\n);\n\nCREATE TABLE manager_award (\n player_id TEXT, -- example: ['larusto01', 'lasorto01']\n award_id TEXT, -- example: ['BBWAA Manager of the year', 'TSN Manager of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n tie TEXT, -- example: ['Y']\n notes NUMERIC\n);\n\nCREATE TABLE player_award (\n player_id TEXT, -- example: ['bondto01', 'hinespa01']\n award_id TEXT, -- example: ['Pitching Triple Crown', 'Triple Crown']\n `year` INTEGER, -- example: [1877, 1878]\n league_id TEXT, -- example: ['NL', 'AA']\n tie TEXT, -- example: ['Y']\n notes TEXT, -- example: ['1B', '2B']\n);\n\nCREATE TABLE manager_award_vote (\n award_id TEXT, -- example: ['Mgr of the year', 'Mgr of the Year']\n `year` INTEGER, -- example: [1983, 1984]\n league_id TEXT, -- example: ['AL', 'NL']\n player_id TEXT, -- example: ['altobjo01', 'coxbo01']\n points_won INTEGER, -- example: [7, 4]\n points_max INTEGER, -- example: [28, 24]\n votes_first INTEGER, -- example: [7, 4]\n);\n\nCREATE TABLE player_award_vote (\n award_id TEXT, -- example: ['Cy Young', 'MVP']\n `year` INTEGER, -- example: [1956, 1957]\n league_id TEXT, -- example: ['ML', 'AL']\n player_id TEXT, -- example: ['fordwh01', 'maglisa01']\n points_won NUMERIC, -- example: [1, 4]\n points_max INTEGER, -- example: [16, 18]\n votes_first NUMERIC, -- example: [1, 4]\n);\n\nCREATE TABLE batting (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n g INTEGER, -- example: [1, 25]\n ab NUMERIC, -- example: [4, 118]\n r NUMERIC, -- example: [0, 30]\n h NUMERIC, -- example: [0, 32]\n `double` NUMERIC, -- example: [0, 6]\n triple NUMERIC, -- example: [0, 5]\n hr NUMERIC, -- example: [0, 2]\n rbi NUMERIC, -- example: [0, 13]\n sb NUMERIC, -- example: [0, 8]\n cs NUMERIC, -- example: [0, 1]\n bb NUMERIC, -- example: [0, 4]\n so NUMERIC, -- example: [0, 5]\n ibb NUMERIC, -- example: [0, 5]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 5]\n sf NUMERIC, -- example: [0, 4]\n g_idp NUMERIC, -- example: [0, 2]\n);\n\nCREATE TABLE batting_postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n player_id TEXT, -- example: ['becanbu01', 'bradyst01']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n g INTEGER, -- example: [1, 3]\n ab INTEGER, -- example: [2, 10]\n r INTEGER, -- example: [0, 1]\n h INTEGER, -- example: [1, 0]\n `double` INTEGER, -- example: [0, 1]\n triple INTEGER, -- example: [0, 1]\n hr INTEGER, -- example: [0, 1]\n rbi INTEGER, -- example: [0, 1]\n sb INTEGER, -- example: [0, 1]\n cs NUMERIC, -- example: [0, 1]\n bb INTEGER, -- example: [0, 1]\n so INTEGER, -- example: [0, 1]\n ibb NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n sh NUMERIC, -- example: [0, 1]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [1, 0]\n);\n\nCREATE TABLE player_college (\n player_id TEXT, -- example: ['aardsda01', 'abadan01']\n college_id TEXT, -- example: ['pennst', 'rice']\n `year` INTEGER, -- example: [2001, 2002]\n);\n\nCREATE TABLE fielding (\n player_id TEXT, -- example: ['abercda01', 'addybo01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['TRO', 'RC1']\n league_id TEXT, -- example: ['NL', 'AA']\n pos TEXT, -- example: ['SS', '2B']\n g INTEGER, -- example: [1, 22]\n gs NUMERIC, -- example: [102, 113]\n inn_outs NUMERIC, -- example: [2773, 3093]\n po NUMERIC, -- example: [1, 67]\n a NUMERIC, -- example: [3, 72]\n e NUMERIC, -- example: [2, 42]\n dp NUMERIC, -- example: [0, 5]\n pb NUMERIC, -- example: [0, 12]\n wp NUMERIC, -- example: [19, 6]\n sb NUMERIC, -- example: [23, 32]\n cs NUMERIC, -- example: [16, 15]\n zr NUMERIC, -- example: [5, 0]\n);\n\nCREATE TABLE fielding_outfield (\n player_id TEXT, -- example: ['allisar01', 'ansonca01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n glf NUMERIC, -- example: [0, 1]\n gcf NUMERIC, -- example: [29, 0]\n grf NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE fielding_postseason (\n player_id TEXT, -- example: ['colliji01', 'crigelo01']\n `year` INTEGER, -- example: [1903, 1905]\n team_id TEXT, -- example: ['BOS', 'PIT']\n league_id TEXT, -- example: ['AL', 'NL']\n round TEXT, -- example: ['WS', 'ALCS']\n pos TEXT, -- example: ['3B', 'C']\n g INTEGER, -- example: [8, 4]\n gs NUMERIC, -- example: [8, 4]\n inn_outs NUMERIC, -- example: [213, 105]\n po INTEGER, -- example: [9, 54]\n a INTEGER, -- example: [18, 7]\n e INTEGER, -- example: [1, 3]\n dp INTEGER, -- example: [1, 2]\n tp INTEGER, -- example: [0, 1]\n pb NUMERIC, -- example: [0, 3]\n sb NUMERIC, -- example: [9, 6]\n cs NUMERIC, -- example: [3, 1]\n);\n\nCREATE TABLE hall_of_fame (\n player_id TEXT, -- example: ['cobbty01', 'ruthba01']\n yearid INTEGER, -- example: [1936, 1937]\n votedby TEXT, -- example: ['BBWAA', 'Veterans']\n ballots NUMERIC, -- example: [226, 78]\n needed NUMERIC, -- example: [170, 59]\n votes NUMERIC, -- example: [222, 215]\n inducted TEXT, -- example: ['Y', 'N']\n category TEXT, -- example: ['Player', 'Manager']\n needed_note TEXT, -- example: ['Top 20', '1st']\n);\n\nCREATE TABLE home_game (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n park_id TEXT, -- example: ['BOS01', 'NYC01']\n span_first TEXT, -- example: ['1871-05-16', '1871-05-27']\n span_last TEXT, -- example: ['1871-10-07', '1871-05-27']\n games INTEGER, -- example: [16, 1]\n openings INTEGER, -- example: [16, 1]\n attendance INTEGER, -- example: [32600, 3000]\n);\n\nCREATE TABLE manager (\n player_id TEXT, -- example: ['wrighha01', 'woodji01']\n `year` INTEGER, -- example: [1871, 1872]\n team_id TEXT, -- example: ['BS1', 'CH1']\n league_id TEXT, -- example: ['NL', 'AA']\n inseason INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [31, 28]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n rank NUMERIC, -- example: [3, 2]\n plyr_mgr TEXT, -- example: ['Y', 'N']\n);\n\nCREATE TABLE manager_half (\n player_id TEXT, -- example: ['hanlone01', 'vanhage01']\n `year` INTEGER, -- example: [1892, 1981]\n team_id TEXT, -- example: ['BLN', 'BRO']\n league_id TEXT, -- example: ['NL', 'AL']\n inseason INTEGER, -- example: [3, 1]\n half INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [56, 77]\n w INTEGER, -- example: [17, 26]\n l INTEGER, -- example: [39, 46]\n rank INTEGER, -- example: [12, 10]\n);\n\nCREATE TABLE player (\n player_id TEXT, -- example: ['aardsda01', 'aaronha01']\n birth_year NUMERIC, -- example: [1981, 1934]\n birth_month NUMERIC, -- example: [12, 2]\n birth_day NUMERIC, -- example: [27, 5]\n birth_country TEXT, -- example: ['USA', 'D.R.']\n birth_state TEXT, -- example: ['CO', 'AL']\n birth_city TEXT, -- example: ['Denver', 'Mobile']\n death_year NUMERIC, -- example: [1984, 1905]\n death_month NUMERIC, -- example: [8, 5]\n death_day NUMERIC, -- example: [16, 17]\n death_country TEXT, -- example: ['USA', 'Cuba']\n death_state TEXT, -- example: ['GA', 'NJ']\n death_city TEXT, -- example: ['Atlanta', 'Pemberton']\n name_first TEXT, -- example: ['Home Run', 'David', 'Hank']\n name_last TEXT, -- example: ['Score', 'Aardsma', 'Aaron']\n name_given TEXT, -- example: ['David Allan', 'Henry Louis']\n weight NUMERIC, -- example: [220, 180]\n height NUMERIC, -- example: [75, 72]\n bats TEXT, -- example: ['R', 'L']\n throws TEXT, -- example: ['R', 'L']\n debut TEXT, -- example: ['2004-04-06', '1954-04-13']\n final_game TEXT, -- example: ['2015-08-23', '1976-10-03']\n retro_id TEXT, -- example: ['aardd001', 'aaroh101']\n bbref_id TEXT, -- example: ['aardsda01', 'aaronha01']\n);\n\nCREATE TABLE park (\n park_id TEXT, -- example: ['ALB01', 'ALT01']\n park_name TEXT, -- example: ['Riverside Park', 'Columbia Park']\n park_alias TEXT, -- example: ['Edison Field; Anaheim Stadium', 'The Ballpark in Arlington; Ameriquest Fi']\n city TEXT, -- example: ['Albany', 'Altoona']\n state TEXT, -- example: ['NY', 'PA']\n country TEXT, -- example: ['US', 'MX']\n);\n\nCREATE TABLE pitching (\n player_id TEXT, -- example: ['bechtge01', 'brainas01']\n `year` INTEGER, -- example: [1871, 1872]\n stint INTEGER, -- example: [1, 2]\n team_id TEXT, -- example: ['PH1', 'WS3']\n league_id TEXT, -- example: ['NL', 'AA']\n w INTEGER, -- example: [1, 12]\n l INTEGER, -- example: [2, 15]\n g INTEGER, -- example: [3, 30]\n gs INTEGER, -- example: [3, 30]\n cg INTEGER, -- example: [2, 30]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts NUMERIC, -- example: [78, 792]\n h INTEGER, -- example: [43, 361]\n er INTEGER, -- example: [23, 132]\n hr INTEGER, -- example: [0, 4]\n bb INTEGER, -- example: [11, 37]\n so INTEGER, -- example: [1, 13]\n baopp NUMERIC, -- example: [0.53, 0.15]\n era NUMERIC, -- example: [7.96, 4.5]\n ibb NUMERIC, -- example: [1, 0]\n wp NUMERIC, -- example: [0, 8]\n hbp NUMERIC, -- example: [0, 10]\n bk INTEGER, -- example: [0, 2]\n bfp NUMERIC, -- example: [13, 14]\n gf NUMERIC, -- example: [0, 1]\n r INTEGER, -- example: [42, 292]\n sh NUMERIC, -- example: [1, 3]\n sf NUMERIC, -- example: [4, 1]\n g_idp NUMERIC, -- example: [6, 1]\n);\n\nCREATE TABLE pitching_postseason (\n player_id TEXT, -- example: ['becanbu01', 'keefeti01']\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id TEXT, -- example: ['NY4', 'PRO']\n league_id TEXT, -- example: ['AA', 'NL']\n w INTEGER, -- example: [0, 3]\n l INTEGER, -- example: [1, 2]\n g INTEGER, -- example: [1, 2]\n gs INTEGER, -- example: [1, 2]\n cg INTEGER, -- example: [1, 2]\n sho INTEGER, -- example: [0, 1]\n sv INTEGER, -- example: [0, 1]\n ipouts INTEGER, -- example: [18, 45]\n h INTEGER, -- example: [9, 10]\n er INTEGER, -- example: [7, 6]\n hr INTEGER, -- example: [0, 1]\n bb INTEGER, -- example: [2, 3]\n so INTEGER, -- example: [1, 12]\n baopp TEXT, -- example: ['0.23', '0.4']\n era NUMERIC, -- example: [10.5, 3.6]\n ibb NUMERIC, -- example: [0, 1]\n wp NUMERIC, -- example: [0, 1]\n hbp NUMERIC, -- example: [0, 1]\n bk NUMERIC, -- example: [0, 1]\n bfp NUMERIC, -- example: [134, 12]\n gf INTEGER, -- example: [0, 1]\n r INTEGER, -- example: [12, 9]\n sh NUMERIC, -- example: [0, 3]\n sf NUMERIC, -- example: [0, 1]\n g_idp NUMERIC, -- example: [0, 1]\n);\n\nCREATE TABLE salary (\n `year` INTEGER, -- example: [1985, 1986]\n team_id TEXT, -- example: ['ATL', 'BAL']\n league_id TEXT, -- example: ['NL', 'AL']\n player_id TEXT, -- example: ['barkele01', 'bedrost01']\n salary INTEGER, -- example: [870000, 550000]\n);\n\nCREATE TABLE college (\n college_id TEXT, -- example: ['abilchrist', 'adelphi']\n name_full TEXT, -- example: ['Abilene Christian University', 'Adelphi University']\n city TEXT, -- example: ['Abilene', 'Garden City']\n state TEXT, -- example: ['TX', 'NY']\n country TEXT, -- example: ['USA']\n);\n\nCREATE TABLE postseason (\n `year` INTEGER, -- example: [1884, 1885]\n round TEXT, -- example: ['WS', 'CS']\n team_id_winner TEXT, -- example: ['PRO', 'CHC']\n league_id_winner TEXT, -- example: ['NL', 'AA']\n team_id_loser TEXT, -- example: ['NYP', 'STL']\n league_id_loser TEXT, -- example: ['AA', 'NL']\n wins INTEGER, -- example: [3, 4]\n losses INTEGER, -- example: [0, 3]\n ties INTEGER, -- example: [0, 1]\n);\n\nCREATE TABLE team (\n `year` INTEGER, -- example: [1871, 1872]\n league_id TEXT, -- example: ['NL', 'AA']\n team_id TEXT, -- example: ['BS1', 'CH1']\n franchise_id TEXT, -- example: ['BNA', 'CNA']\n div_id TEXT, -- example: ['W', 'E']\n rank INTEGER, -- example: [3, 2]\n g INTEGER, -- example: [31, 28]\n ghome NUMERIC, -- example: [66, 69]\n w INTEGER, -- example: [20, 19]\n l INTEGER, -- example: [10, 9]\n div_win TEXT, -- example: ['Y', 'N']\n wc_win TEXT, -- example: ['N', 'Y']\n lg_win TEXT, -- example: ['N', 'Y']\n ws_win TEXT, -- example: ['N', 'Y']\n r INTEGER, -- example: [401, 302]\n ab INTEGER, -- example: [1372, 1196]\n h INTEGER, -- example: [426, 323]\n `double` INTEGER, -- example: [70, 52]\n triple INTEGER, -- example: [37, 21]\n hr INTEGER, -- example: [3, 10]\n bb INTEGER, -- example: [60, 26]\n so NUMERIC, -- example: [19, 22]\n sb NUMERIC, -- example: [73, 69]\n cs NUMERIC, -- example: [15, 4]\n hbp NUMERIC, -- example: [47, 59]\n sf NUMERIC, -- example: [43, 58]\n ra INTEGER, -- example: [303, 241]\n er INTEGER, -- example: [109, 77]\n era NUMERIC, -- example: [3.55, 2.76]\n cg INTEGER, -- example: [22, 25]\n sho INTEGER, -- example: [1, 0]\n sv INTEGER, -- example: [3, 1]\n ipouts INTEGER, -- example: [828, 753]\n ha INTEGER, -- example: [367, 308]\n hra INTEGER, -- example: [2, 6]\n bba INTEGER, -- example: [42, 28]\n soa INTEGER, -- example: [23, 22]\n e INTEGER, -- example: [225, 218]\n dp NUMERIC, -- example: [42, 33]\n fp NUMERIC, -- example: [0.83, 0.82]\n name TEXT, -- example: ['Boston Red Stockings', 'Chicago White Stockings']\n park TEXT, -- example: ['South End Grounds I', 'Union Base-Ball Grounds']\n attendance NUMERIC, -- example: [121412, 147539]\n bpf INTEGER, -- example: [103, 104]\n ppf INTEGER, -- example: [98, 102]\n team_id_br TEXT, -- example: ['BOS', 'CHI']\n team_id_lahman45 TEXT, -- example: ['BS1', 'CH1']\n team_id_retro TEXT, -- example: ['BS1', 'CH1']\n);\n\nCREATE TABLE team_franchise (\n franchise_id TEXT, -- example: ['ALT', 'ANA']\n franchise_name TEXT, -- example: ['Altoona Mountain City', 'Los Angeles Angels of Anaheim']\n active TEXT, -- example: ['N', 'Y']\n na_assoc TEXT, -- example: ['PNA', 'BNA']\n);\n\nCREATE TABLE team_half (\n `year` INTEGER, -- example: [1981]\n league_id TEXT, -- example: ['NL', 'AL']\n team_id TEXT, -- example: ['ATL', 'BAL']\n half INTEGER, -- example: [1, 2]\n div_id TEXT, -- example: ['W', 'E']\n div_win TEXT, -- example: ['N']\n rank INTEGER, -- example: [4, 5]\n g INTEGER, -- example: [54, 52]\n w INTEGER, -- example: [25, 31]\n l INTEGER, -- example: [29, 27]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nI would like to know the given names of baseball players who have achieved the highest value of games played, runs, hits, and home runs, with their corresponding score values.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What are the top three product categories with the highest number of payments in single payment type, and how many payments were made in each category?", "schema": "CREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['top ', 'Top ', 'TOP', 'Top', 'top', 'Recebi bem antes do prazo estipulado.']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['top ', 'Top ', 'TOP', 'Top', 'top', 'Recebi bem antes do prazo estipulado.']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat are the top three product categories with the highest number of payments in single payment type, and how many payments were made in each category?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please help me find the film category with the highest total rental hours in cities where the city's name either starts with \"A\" or contains a hyphen. ", "schema": "CREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE actor (\n actor_id numeric, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['PENELOPE', 'NICK']\n last_name VARCHAR(45), -- example: ['AKROYD', 'ALLEN']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:59', '2021-03-06 15:52:00']\n PRIMARY KEY (actor_id)\n);\n\nCREATE TABLE country (\n country_id SMALLINT, -- example: [1, 2]\n country VARCHAR(50), -- example: ['Afghanistan', 'Algeria']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49']\n PRIMARY KEY (country_id)\n);\n\nCREATE TABLE city (\n city_id int, -- example: [1, 2]\n city VARCHAR(50), -- example: ['A Corua (La Corua)', 'Abha']\n country_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:49', '2021-03-06 15:51:50']\n PRIMARY KEY (city_id),\n CONSTRAINT fk_city_country_id FOREIGN KEY (country_id) REFERENCES country (country_id)\n);\n\nCREATE TABLE address (\n address_id int, -- example: [1, 2]\n address VARCHAR(50), -- example: ['47 MySakila Drive', '28 MySQL Boulevard']\n address2 VARCHAR(50),\n district VARCHAR(20), -- example: [' ']\n city_id INT, -- example: [1, 2]\n postal_code VARCHAR(10), -- example: ['35200', '17886']\n phone VARCHAR(20), -- example: [' ']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:54', '2021-03-06 15:51:55']\n PRIMARY KEY (address_id),\n CONSTRAINT fk_address_city_id FOREIGN KEY (city_id) REFERENCES city (city_id)\n);\n\nCREATE TABLE `language` (\n language_id SMALLINT, -- example: [1, 2]\n name CHAR(20), -- example: ['English', 'Italian']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:51:48']\n PRIMARY KEY (language_id)\n);\n\nCREATE TABLE category (\n category_id SMALLINT, -- example: [1, 2]\n name VARCHAR(25), -- example: ['Action', 'Animation']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (category_id)\n);\n\nCREATE TABLE customer (\n customer_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['MARY', 'PATRICIA']\n last_name VARCHAR(45), -- example: ['ABNEY', 'ADAM']\n email VARCHAR(50), -- example: ['MARY.SMITH@sakilacustomer.org', 'PATRICIA.JOHNSON@sakilacustomer.org']\n address_id INT, -- example: [5, 6]\n active CHAR(1), -- example: ['1', '0']\n create_date TIMESTAMP, -- example: ['2006-02-14 22:04:36.000', '2006-02-14 22:04:37.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:36', '2021-03-06 15:53:37']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_store_id FOREIGN KEY (store_id) REFERENCES store (store_id),\n CONSTRAINT fk_customer_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE film (\n film_id int, -- example: [1, 2]\n title VARCHAR(255), -- example: ['ACADEMY DINOSAUR', 'ACE GOLDFINGER']\n description BLOB SUB_TYPE TEXT, -- example: ['A Epic Drama of a Feminist And a Mad Sci', 'A Astounding Epistle of a Database Admin']\n release_year VARCHAR(4), -- example: ['2006']\n language_id SMALLINT, -- example: [1]\n original_language_id SMALLINT,\n rental_duration SMALLINT, -- example: [6, 3]\n rental_rate DECIMAL(4,2), -- example: [0.99, 4.99]\n length SMALLINT, -- example: [86, 48]\n replacement_cost DECIMAL(5,2), -- example: [20.99, 12.99]\n rating VARCHAR(10), -- example: ['PG', 'G']\n special_features VARCHAR(100), -- example: ['Deleted Scenes,Behind the Scenes', 'Trailers,Deleted Scenes']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00', '2021-03-06 15:52:01']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_language_id FOREIGN KEY (language_id) REFERENCES `language` (language_id),\n CONSTRAINT fk_film_original_language_id FOREIGN KEY (original_language_id) REFERENCES `language` (language_id)\n);\n\nCREATE TABLE film_actor (\n actor_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:45', '2021-03-06 15:52:46']\n PRIMARY KEY (actor_id),\n CONSTRAINT fk_film_actor_actor_id FOREIGN KEY (actor_id) REFERENCES actor (actor_id),\n CONSTRAINT fk_film_actor_film_id FOREIGN KEY (film_id) REFERENCES film (film_id)\n);\n\nCREATE TABLE film_category (\n film_id INT, -- example: [1, 2]\n category_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:28', '2021-03-06 15:53:29']\n PRIMARY KEY (film_id),\n CONSTRAINT fk_film_category_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_film_category_category_id FOREIGN KEY (category_id) REFERENCES category (category_id)\n);\n\nCREATE TABLE film_text (\n film_id SMALLINT,\n title VARCHAR(255),\n description BLOB SUB_TYPE TEXT,\n PRIMARY KEY (film_id)\n);\n\nCREATE TABLE inventory (\n inventory_id INT, -- example: [1, 2]\n film_id INT, -- example: [1, 2]\n store_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:08', '2021-03-06 15:52:09']\n PRIMARY KEY (inventory_id),\n CONSTRAINT fk_inventory_film_id FOREIGN KEY (film_id) REFERENCES film (film_id),\n CONSTRAINT fk_inventory_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE staff (\n staff_id SMALLINT, -- example: [1, 2]\n first_name VARCHAR(45), -- example: ['Mike', 'Jon']\n last_name VARCHAR(45), -- example: ['Hillyer', 'Stephens']\n address_id INT, -- example: [3, 4]\n picture BLOB,\n email VARCHAR(50), -- example: ['Mike.Hillyer@sakilastaff.com', 'Jon.Stephens@sakilastaff.com']\n store_id INT, -- example: [1, 2]\n active SMALLINT, -- example: [1]\n username VARCHAR(16), -- example: ['Mike', 'Jon']\n password VARCHAR(40), -- example: ['8cb2237d0679ca88db6464eac60da96345513964']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (staff_id),\n CONSTRAINT fk_staff_address_id FOREIGN KEY (address_id) REFERENCES address (address_id),\n CONSTRAINT fk_staff_store_id FOREIGN KEY (store_id) REFERENCES store (store_id)\n);\n\nCREATE TABLE store (\n store_id INT, -- example: [1, 2]\n manager_staff_id SMALLINT, -- example: [1, 2]\n address_id INT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:52:00']\n PRIMARY KEY (store_id),\n CONSTRAINT fk_store_manager_staff_id FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_store_address_id FOREIGN KEY (address_id) REFERENCES address (address_id)\n);\n\nCREATE TABLE payment (\n payment_id int, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n staff_id SMALLINT, -- example: [1, 2]\n rental_id INT, -- example: [76, 573]\n amount DECIMAL(5,2), -- example: [2.99, 0.99]\n payment_date TIMESTAMP, -- example: ['2005-05-25 11:30:37.000', '2005-05-28 10:35:23.000']\n last_update TIMESTAMP, -- example: ['2021-03-06 15:55:57', '2021-03-06 15:55:58']\n PRIMARY KEY (payment_id),\n CONSTRAINT fk_payment_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_payment_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id),\n CONSTRAINT fk_payment_rental_id FOREIGN KEY (rental_id) REFERENCES rental (rental_id)\n);\n\nCREATE TABLE rental (\n rental_id INT, -- example: [1, 2]\n rental_date TIMESTAMP, -- example: ['2005-05-24 22:53:30.000', '2005-05-24 22:54:33.000']\n inventory_id INT, -- example: [1, 2]\n customer_id INT, -- example: [1, 2]\n return_date TIMESTAMP, -- example: ['2005-05-26 22:04:30.000', '2005-05-28 19:40:33.000']\n staff_id SMALLINT, -- example: [1, 2]\n last_update TIMESTAMP, -- example: ['2021-03-06 15:53:41', '2021-03-06 15:53:42']\n PRIMARY KEY (rental_id),\n CONSTRAINT fk_rental_inventory_id FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),\n CONSTRAINT fk_rental_customer_id FOREIGN KEY (customer_id) REFERENCES customer (customer_id),\n CONSTRAINT fk_rental_staff_id FOREIGN KEY (staff_id) REFERENCES staff (staff_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease help me find the film category with the highest total rental hours in cities where the city's name either starts with \"A\" or contains a hyphen. \n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which packaging containers include items in quantities greater than 500, considering all items contained within each container?", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich packaging containers include items in quantities greater than 500, considering all items contained within each container?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you generate a summary of our items' loss rates? Include the average loss rate, and also break down the count of items that are below, above, and within one standard deviation from this average.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you generate a summary of our items' loss rates? Include the average loss rate, and also break down the count of items that are below, above, and within one standard deviation from this average.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Analyze our match data to identify the name, leagues, and countries of the champion team for each season. Include the total points accumulated by each team.", "schema": "CREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Team', 'Country']\n seq TEXT, -- example: [103916, 51958]\n);\n\nCREATE TABLE Player_Attributes (\n id INTEGER, -- example: [1, 2]\n player_fifa_api_id INTEGER, -- example: [218353, 189615]\n player_api_id INTEGER, -- example: [505942, 155782]\n `date` TEXT, -- example: ['2016-02-18 00:00:00', '2015-11-19 00:00:00']\n overall_rating INTEGER, -- example: [67, 62]\n potential INTEGER, -- example: [71, 66]\n preferred_foot TEXT, -- example: ['right', 'left']\n attacking_work_rate TEXT, -- example: ['medium', 'high']\n defensive_work_rate TEXT, -- example: ['medium', 'high']\n crossing INTEGER, -- example: [49, 48]\n finishing INTEGER, -- example: [44, 43]\n heading_accuracy INTEGER, -- example: [71, 70]\n short_passing INTEGER, -- example: [61, 60]\n volleys INTEGER, -- example: [44, 43]\n dribbling INTEGER, -- example: [51, 50]\n curve INTEGER, -- example: [45, 44]\n free_kick_accuracy INTEGER, -- example: [39, 38]\n long_passing INTEGER, -- example: [64, 63]\n ball_control INTEGER, -- example: [49, 48]\n acceleration INTEGER, -- example: [60, 79]\n sprint_speed INTEGER, -- example: [64, 78]\n agility INTEGER, -- example: [59, 78]\n reactions INTEGER, -- example: [47, 46]\n balance INTEGER, -- example: [65, 90]\n shot_power INTEGER, -- example: [55, 54]\n jumping INTEGER, -- example: [58, 85]\n stamina INTEGER, -- example: [54, 79]\n strength INTEGER, -- example: [76, 56]\n long_shots INTEGER, -- example: [35, 34]\n aggression INTEGER, -- example: [71, 63]\n interceptions INTEGER, -- example: [70, 41]\n positioning INTEGER, -- example: [45, 44]\n vision INTEGER, -- example: [54, 53]\n penalties INTEGER, -- example: [48, 47]\n marking INTEGER, -- example: [65, 62]\n standing_tackle INTEGER, -- example: [69, 66]\n sliding_tackle INTEGER, -- example: [69, 66]\n gk_diving INTEGER, -- example: [6, 5]\n gk_handling INTEGER, -- example: [11, 10]\n gk_kicking INTEGER, -- example: [10, 9]\n gk_positioning INTEGER, -- example: [8, 7]\n gk_reflexes INTEGER, -- example: [8, 7]\n PRIMARY KEY (id),\n CONSTRAINT fk_player_attributes_player_fifa_api_id FOREIGN KEY (player_fifa_api_id) REFERENCES Player (player_fifa_api_id),\n CONSTRAINT fk_player_attributes_player_api_id FOREIGN KEY (player_api_id) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE Player (\n id INTEGER, -- example: [3879, 401]\n player_api_id INTEGER, -- example: [2625, 2752]\n player_name TEXT, -- example: ['Aaron Appindangoye', 'Aaron Cresswell']\n player_fifa_api_id INTEGER, -- example: [2, 6]\n birthday TEXT, -- example: ['1992-02-29 00:00:00', '1989-12-15 00:00:00']\n height INTEGER, -- example: [182.88, 170.18]\n weight INTEGER, -- example: [187, 146]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE `Match` (\n id INTEGER, -- example: [4769, 4770]\n country_id INTEGER, -- example: [1, 1729]\n league_id INTEGER, -- example: [1, 1729]\n season TEXT, -- example: ['2008/2009', '2009/2010']\n stage INTEGER, -- example: [1, 10]\n `date` TEXT, -- example: ['2008-08-17 00:00:00', '2008-08-16 00:00:00']\n match_api_id INTEGER, -- example: [483129, 483130]\n home_team_api_id INTEGER, -- example: [9987, 10000]\n away_team_api_id INTEGER, -- example: [9993, 9994]\n home_team_goal INTEGER, -- example: [1, 0]\n away_team_goal INTEGER, -- example: [1, 0]\n home_player_X1 INTEGER, -- example: [1, 2]\n home_player_X2 INTEGER, -- example: [2, 4]\n home_player_X3 INTEGER, -- example: [4, 6]\n home_player_X4 INTEGER, -- example: [6, 8]\n home_player_X5 INTEGER, -- example: [8, 6]\n home_player_X6 INTEGER, -- example: [2, 6]\n home_player_X7 INTEGER, -- example: [4, 8]\n home_player_X8 INTEGER, -- example: [6, 2]\n home_player_X9 INTEGER, -- example: [8, 4]\n home_player_X10 INTEGER, -- example: [4, 6]\n home_player_X11 INTEGER, -- example: [6, 4]\n away_player_X1 INTEGER, -- example: [1, 2]\n away_player_X2 INTEGER, -- example: [2, 4]\n away_player_X3 INTEGER, -- example: [4, 6]\n away_player_X4 INTEGER, -- example: [6, 8]\n away_player_X5 INTEGER, -- example: [8, 6]\n away_player_X6 INTEGER, -- example: [2, 4]\n away_player_X7 INTEGER, -- example: [4, 6]\n away_player_X8 INTEGER, -- example: [6, 8]\n away_player_X9 INTEGER, -- example: [8, 2]\n away_player_X10 INTEGER, -- example: [4, 6]\n away_player_X11 INTEGER, -- example: [6, 4]\n home_player_Y1 INTEGER, -- example: [1, 3]\n home_player_Y2 INTEGER, -- example: [3, 0]\n home_player_Y3 INTEGER, -- example: [3, 5]\n home_player_Y4 INTEGER, -- example: [3, 5]\n home_player_Y5 INTEGER, -- example: [3, 7]\n home_player_Y6 INTEGER, -- example: [7, 3]\n home_player_Y7 INTEGER, -- example: [7, 6]\n home_player_Y8 INTEGER, -- example: [7, 8]\n home_player_Y9 INTEGER, -- example: [7, 10]\n home_player_Y10 INTEGER, -- example: [10, 7]\n home_player_Y11 INTEGER, -- example: [10, 11]\n away_player_Y1 INTEGER, -- example: [1, 3]\n away_player_Y2 INTEGER, -- example: [3]\n away_player_Y3 INTEGER, -- example: [3, 7]\n away_player_Y4 INTEGER, -- example: [3, 5]\n away_player_Y5 INTEGER, -- example: [3, 7]\n away_player_Y6 INTEGER, -- example: [7, 3]\n away_player_Y7 INTEGER, -- example: [7, 6]\n away_player_Y8 INTEGER, -- example: [7, 8]\n away_player_Y9 INTEGER, -- example: [7, 10]\n away_player_Y10 INTEGER, -- example: [10, 7]\n away_player_Y11 INTEGER, -- example: [10, 11]\n home_player_1 INTEGER, -- example: [39890, 38327]\n home_player_2 INTEGER, -- example: [67950, 39580]\n home_player_3 INTEGER, -- example: [38788, 67958]\n home_player_4 INTEGER, -- example: [38312, 67959]\n home_player_5 INTEGER, -- example: [26235, 37112]\n home_player_6 INTEGER, -- example: [36393, 46004]\n home_player_7 INTEGER, -- example: [148286, 164732]\n home_player_8 INTEGER, -- example: [67898, 39631]\n home_player_9 INTEGER, -- example: [26916, 164352]\n home_player_10 INTEGER, -- example: [38801, 38423]\n home_player_11 INTEGER, -- example: [94289, 26502]\n away_player_1 INTEGER, -- example: [34480, 37937]\n away_player_2 INTEGER, -- example: [38388, 38293]\n away_player_3 INTEGER, -- example: [26458, 148313]\n away_player_4 INTEGER, -- example: [13423, 104411]\n away_player_5 INTEGER, -- example: [38389, 148314]\n away_player_6 INTEGER, -- example: [38798, 37202]\n away_player_7 INTEGER, -- example: [30949, 43158]\n away_player_8 INTEGER, -- example: [38253, 9307]\n away_player_9 INTEGER, -- example: [106013, 42153]\n away_player_10 INTEGER, -- example: [38383, 32690]\n away_player_11 INTEGER, -- example: [46552, 38782]\n goal TEXT, -- example: ['n']\n shoton TEXT, -- example: ['11y', '']\n `cross` TEXT, -- example: ['1156', '65']\n B365H NUMERIC, -- example: [1.73, 1.95]\n B365D NUMERIC, -- example: [3.4, 3.2]\n B365A NUMERIC, -- example: [5, 3.6]\n BWH NUMERIC, -- example: [1.75, 1.8]\n BWD NUMERIC, -- example: [3.35, 3.3]\n BWA NUMERIC, -- example: [4.2, 3.95]\n IWH NUMERIC, -- example: [1.85, 1.9]\n IWD NUMERIC, -- example: [3.2, 3.1]\n IWA NUMERIC, -- example: [3.5, 2.3]\n LBH NUMERIC, -- example: [1.8, 1.9]\n LBD NUMERIC, -- example: [3.3, 3.2]\n LBA NUMERIC, -- example: [3.75, 3.5]\n PSH NUMERIC, -- example: [5.1, 2.48]\n PSD NUMERIC, -- example: [3.82, 3.52]\n PSA NUMERIC, -- example: [1.76, 2.96]\n WHH NUMERIC, -- example: [1.7, 1.83]\n WHD NUMERIC, -- example: [3.3, 3.25]\n WHA NUMERIC, -- example: [4.33, 3.6]\n SJH NUMERIC, -- example: [1.9, 1.95]\n SJD NUMERIC, -- example: [3.3, 4]\n SJA NUMERIC, -- example: [4, 3.8]\n VCH NUMERIC, -- example: [1.65, 2]\n VCD NUMERIC, -- example: [3.4, 3.25]\n VCA NUMERIC, -- example: [4.5, 3.25]\n GBH NUMERIC, -- example: [1.78, 1.85]\n GBD NUMERIC, -- example: [3.25, 3.2]\n GBA NUMERIC, -- example: [4, 3.75]\n BSH NUMERIC, -- example: [1.73, 1.91]\n BSD NUMERIC, -- example: [3.4, 3.25]\n BSA NUMERIC, -- example: [4.2, 3.6]\n PRIMARY KEY (id),\n CONSTRAINT fk_match_league_id FOREIGN KEY (league_id) REFERENCES League (id),\n CONSTRAINT fk_match_home_team_api_id FOREIGN KEY (home_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_away_team_api_id FOREIGN KEY (away_team_api_id) REFERENCES Team (team_api_id),\n CONSTRAINT fk_match_home_player_1 FOREIGN KEY (home_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_2 FOREIGN KEY (home_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_3 FOREIGN KEY (home_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_4 FOREIGN KEY (home_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_5 FOREIGN KEY (home_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_6 FOREIGN KEY (home_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_7 FOREIGN KEY (home_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_8 FOREIGN KEY (home_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_9 FOREIGN KEY (home_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_10 FOREIGN KEY (home_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_home_player_11 FOREIGN KEY (home_player_11) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_1 FOREIGN KEY (away_player_1) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_2 FOREIGN KEY (away_player_2) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_3 FOREIGN KEY (away_player_3) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_4 FOREIGN KEY (away_player_4) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_5 FOREIGN KEY (away_player_5) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_6 FOREIGN KEY (away_player_6) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_7 FOREIGN KEY (away_player_7) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_8 FOREIGN KEY (away_player_8) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_9 FOREIGN KEY (away_player_9) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_10 FOREIGN KEY (away_player_10) REFERENCES Player (player_api_id),\n CONSTRAINT fk_match_away_player_11 FOREIGN KEY (away_player_11) REFERENCES Player (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER, -- example: [1, 1729]\n country_id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium Jupiler League', 'England Premier League']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Country (\n id INTEGER, -- example: [1, 1729]\n name TEXT, -- example: ['Belgium', 'England']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team (\n id INTEGER, -- example: [31446, 1513]\n team_api_id INTEGER, -- example: [1601, 1773]\n team_fifa_api_id INTEGER, -- example: [673, 675]\n team_long_name TEXT, -- example: ['KRC Genk', 'Beerschot AC']\n team_short_name TEXT, -- example: ['GEN', 'BAC']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER, -- example: [1, 2]\n team_fifa_api_id INTEGER, -- example: [434, 77]\n team_api_id INTEGER, -- example: [9930, 8485]\n `date` TEXT, -- example: ['2010-02-22 00:00:00', '2014-09-19 00:00:00']\n buildUpPlaySpeed INTEGER, -- example: [60, 52]\n buildUpPlaySpeedClass TEXT, -- example: ['Balanced', 'Fast']\n buildUpPlayDribbling INTEGER, -- example: [48, 41]\n buildUpPlayDribblingClass TEXT, -- example: ['Little', 'Normal']\n buildUpPlayPassing INTEGER, -- example: [50, 56]\n buildUpPlayPassingClass TEXT, -- example: ['Mixed', 'Long']\n buildUpPlayPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n chanceCreationPassing INTEGER, -- example: [60, 54]\n chanceCreationPassingClass TEXT, -- example: ['Normal', 'Risky']\n chanceCreationCrossing INTEGER, -- example: [65, 63]\n chanceCreationCrossingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationShooting INTEGER, -- example: [55, 64]\n chanceCreationShootingClass TEXT, -- example: ['Normal', 'Lots']\n chanceCreationPositioningClass TEXT, -- example: ['Organised', 'Free Form']\n defencePressure INTEGER, -- example: [50, 47]\n defencePressureClass TEXT, -- example: ['Medium', 'Deep']\n defenceAggression INTEGER, -- example: [55, 44]\n defenceAggressionClass TEXT, -- example: ['Press', 'Double']\n defenceTeamWidth INTEGER, -- example: [45, 54]\n defenceTeamWidthClass TEXT, -- example: ['Normal', 'Wide']\n defenceDefenderLineClass TEXT, -- example: ['Cover', 'Offside Trap']\n PRIMARY KEY (id),\n CONSTRAINT fk_team_attributes_team_fifa_api_id FOREIGN KEY (team_fifa_api_id) REFERENCES Team (team_fifa_api_id),\n CONSTRAINT fk_team_attributes_team_api_id FOREIGN KEY (team_api_id) REFERENCES Team (team_api_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAnalyze our match data to identify the name, leagues, and countries of the champion team for each season. Include the total points accumulated by each team.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "What is the average forecasted annual sales for products 4160 and 7790 for 2018? Use a weighted regression model based on sales data from January 2016, focusing on the first 36 months, with sales adjusted for seasonality during time steps 7 to 30.", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Explanation of Metrics\n\n## 1. Sales-to-CMA Ratio\n- **Definition**: This ratio compares actual sales to the centered moving average (CMA) of sales.\n- **Calculation**:\n - **Centered Moving Average (CMA)**: The CMA is a smoothed value of sales calculated over a rolling 12-month period. It averages sales from the months before and after a given month, specifically using two overlapping windows (5 months before and 6 months after, and vice versa).\n - **Sales-to-CMA Ratio**: The ratio is computed by dividing the actual sales amount for a month by its corresponding CMA value. A ratio greater than 2 indicates that the actual sales are more than twice the smoothed average for that period, suggesting significantly higher-than-average sales.\n\n## 2. 12-Month Overlapping Windows\n- **Definition**: A method to smooth sales data over time by averaging values in a specified window.\n- **Calculation**:\n - **Window Size**: The window spans 12 months, with the specific approach involving overlapping periods. \n - **First Window**: For a given month, this window includes 5 months before and 6 months after.\n - **Second Window**: Another window includes 6 months before and 5 months after the given month.\n - **Averaging**: Sales data is averaged over these two overlapping windows to compute the CMA. This method smooths out fluctuations by considering both the past and future sales in the calculation.\n\n## 3. Restriction to the 7th and 30th Months\n- **Definition**: A filter applied to focus calculations within a specific range of months.\n- **Calculation**:\n - **Time Range**: Only the months between the 7th and 30th time steps (which correspond to specific periods) are considered for calculating the CMA and ratio.\n - **Purpose**: This restriction is used to avoid edge effects in the data where the moving average might be less reliable (e.g., at the very beginning or end of the available data). By focusing on these months, the calculations are more stable and meaningful.\nWhat is the average forecasted annual sales for products 4160 and 7790 for 2018? Use a weighted regression model based on sales data from January 2016, focusing on the first 36 months, with sales adjusted for seasonality during time steps 7 to 30.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Explanation of Metrics\n\n## 1. Sales-to-CMA Ratio\n- **Definition**: This ratio compares actual sales to the centered moving average (CMA) of sales.\n- **Calculation**:\n - **Centered Moving Average (CMA)**: The CMA is a smoothed value of sales calculated over a rolling 12-month period. It averages sales from the months before and after a given month, specifically using two overlapping windows (5 months before and 6 months after, and vice versa).\n - **Sales-to-CMA Ratio**: The ratio is computed by dividing the actual sales amount for a month by its corresponding CMA value. A ratio greater than 2 indicates that the actual sales are more than twice the smoothed average for that period, suggesting significantly higher-than-average sales.\n\n## 2. 12-Month Overlapping Windows\n- **Definition**: A method to smooth sales data over time by averaging values in a specified window.\n- **Calculation**:\n - **Window Size**: The window spans 12 months, with the specific approach involving overlapping periods. \n - **First Window**: For a given month, this window includes 5 months before and 6 months after.\n - **Second Window**: Another window includes 6 months before and 5 months after the given month.\n - **Averaging**: Sales data is averaged over these two overlapping windows to compute the CMA. This method smooths out fluctuations by considering both the past and future sales in the calculation.\n\n## 3. Restriction to the 7th and 30th Months\n- **Definition**: A filter applied to focus calculations within a specific range of months.\n- **Calculation**:\n - **Time Range**: Only the months between the 7th and 30th time steps (which correspond to specific periods) are considered for calculating the CMA and ratio.\n - **Purpose**: This restriction is used to avoid edge effects in the data where the moving average might be less reliable (e.g., at the very beginning or end of the available data). By focusing on these months, the calculations are more stable and meaningful." }, { "question": "Let's generate a report for each pizza order that lists the pizza name followed by \": \", then all the ingredients in alphabetical order. If any ingredient is ordered more than once, indicate it with '2x' directly in front of the ingredient without a space.", "schema": "CREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['alphabetical', 'ingredients', 'alphabetic', 'ingredient', 'directly', 'indicate']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pizza_names (\n pizza_id INTEGER, -- example: [1, 2]\n pizza_name TEXT, -- example: ['Meatlovers', 'Vegetarian']\n);\n\nCREATE TABLE companies_funding (\n company_id INTEGER, -- example: [548, 645]\n valuation INTEGER, -- example: [2000000000, 1000000000]\n funding INTEGER, -- example: [449000000, 188000000]\n select_investors TEXT, -- example: ['\"Accel Partners, Index Ventures, Insight', '\"Sequoia Capital China, China Life Inves']\n);\n\nCREATE TABLE pizza_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE pizza_toppings (\n topping_id INTEGER, -- example: [1, 2]\n topping_name TEXT, -- example: ['Bacon', 'BBQ Sauce']\n);\n\nCREATE TABLE trees (\n idx INTEGER, -- example: [199121, 32277]\n tree_id INTEGER, -- example: [414328, 155915]\n tree_dbh INTEGER, -- example: [4, 2]\n stump_diam INTEGER, -- example: [0, 4]\n status TEXT, -- example: ['Alive', 'Stump']\n health TEXT, -- example: ['Good', 'Fair']\n spc_latin TEXT, -- example: ['Ulmus americana', 'Eucommia ulmoides']\n spc_common TEXT, -- example: ['American elm', 'hardy rubber tree']\n address TEXT, -- example: ['1301 RYAWA AVENUE', '506 BEACH 69 STREET']\n zipcode INTEGER, -- example: [10474, 11692]\n borocode INTEGER, -- example: [2, 4]\n boroname TEXT, -- example: ['Bronx', 'Queens']\n nta_name TEXT, -- example: ['Hunts Point', 'Hammels-Arverne-Edgemere']\n state TEXT, -- example: ['New York']\n latitude REAL, -- example: [40.80504923, 40.5949501]\n longitude REAL, -- example: [-73.88385512, -73.79834048]\n);\n\nCREATE TABLE pizza_recipes (\n pizza_id INTEGER, -- example: [1, 2]\n toppings TEXT, -- example: ['1, 2, 3, 4, 5, 6, 8, 10', '4, 6, 7, 9, 11, 12']\n);\n\nCREATE TABLE statistics (\n `date` TEXT, -- example: ['2020-05-27 00:00:00', '2020-06-26 00:00:00']\n state TEXT, -- example: ['NC', 'CO']\n total_cases INTEGER, -- example: [24628, 58818]\n total_deaths INTEGER, -- example: [794, 1303]\n);\n\nCREATE TABLE income_trees (\n zipcode INTEGER, -- example: [11205, 11218]\n Estimate_Total INTEGER, -- example: [15198, 24909]\n Margin_of_Error_Total INTEGER, -- example: [353, 371]\n Estimate_Median_income INTEGER, -- example: [47575, 56120]\n Margin_of_Error_Median_income INTEGER, -- example: [3834, 3925]\n Estimate_Mean_income INTEGER, -- example: [73353, 78208]\n Margin_of_Error_Mean_income INTEGER, -- example: [3929, 3788]\n);\n\nCREATE TABLE pizza_clean_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance REAL, -- example: [20.0, 13.4]\n duration REAL, -- example: [32.0, 27.0]\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE pizza_runner_orders (\n order_id INTEGER, -- example: [1, 2]\n runner_id INTEGER, -- example: [1, 2]\n pickup_time TEXT, -- example: ['2021-01-01 18:15:34', '2021-01-01 19:10:54']\n distance TEXT, -- example: ['20km', '13.4km']\n duration TEXT, -- example: ['32 minutes', '27 minutes']\n cancellation TEXT, -- example: ['Restaurant Cancellation', 'Customer Cancellation']\n);\n\nCREATE TABLE word_list (\n words TEXT, -- example: ['alphabetical', 'ingredients', 'alphabetic', 'ingredient', 'directly', 'indicate']\n);\n\nCREATE TABLE companies_dates (\n company_id INTEGER, -- example: [109, 821]\n date_joined TEXT, -- example: ['2020-09-08T00:00:00.000', '2019-05-16T00:00:00.000']\n year_founded INTEGER, -- example: [2004, 2009]\n);\n\nCREATE TABLE pizza_get_extras (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [5, 7]\n extras INTEGER, -- example: [1, 5]\n extras_count INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE pizza_get_exclusions (\n row_id INTEGER, -- example: [1, 2]\n order_id INTEGER, -- example: [4, 9]\n exclusions INTEGER, -- example: [4, 2]\n total_exclusions INTEGER, -- example: [3, 1]\n);\n\nCREATE TABLE pizza_clean_customer_orders (\n order_id INTEGER, -- example: [1, 2]\n customer_id INTEGER, -- example: [101, 102]\n pizza_id INTEGER, -- example: [1, 2]\n exclusions TEXT, -- example: ['4', '2,6']\n extras TEXT, -- example: ['1', '1,5']\n order_time TEXT, -- example: ['2021-01-01 18:05:02', '2021-01-01 19:00:52']\n);\n\nCREATE TABLE companies_industries (\n company_id INTEGER, -- example: [316, 162]\n industry TEXT, -- example: ['Fintech', 'Internet software & services']\n);\n\nCREATE TABLE pizza_runners (\n runner_id INTEGER, -- example: [1, 2]\n registration_date TEXT, -- example: ['2021-01-01', '2021-01-03']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLet's generate a report for each pizza order that lists the pizza name followed by \": \", then all the ingredients in alphabetical order. If any ingredient is ordered more than once, indicate it with '2x' directly in front of the ingredient without a space.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For each product, provide the product_id, month in 2019, and the smallest difference between its ending inventory and minimum required level, based on a monthly inventory adjustment model that includes restocking when levels fall below the minimum.", "schema": "CREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE customers (\n id INTEGER, -- example: [50042, 50741]\n name TEXT, -- example: ['The White Hart', 'Hygge og Humle']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE conway_gen_zero (\n x INTEGER,\n y INTEGER,\n alive INTEGER,\n PRIMARY KEY (x)\n);\n\nCREATE TABLE web_devices (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n pc INTEGER, -- example: [1042, 967]\n tablet INTEGER, -- example: [812, 1102]\n phone INTEGER, -- example: [1610, 2159]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE web_demographics (\n `day` TEXT, -- example: ['2019-05-01', '2019-05-02']\n m_tw_cnt INTEGER, -- example: [1232, 1438]\n m_tw_qty INTEGER, -- example: [86, 142]\n m_fb_cnt INTEGER, -- example: [1017, 1198]\n m_fb_qty INTEGER, -- example: [64, 70]\n f_tw_cnt INTEGER, -- example: [651, 840]\n f_tw_qty INTEGER, -- example: [76, 92]\n f_fb_cnt INTEGER, -- example: [564, 752]\n f_fb_qty INTEGER, -- example: [68, 78]\n PRIMARY KEY (`day`)\n);\n\nCREATE TABLE channels_dim (\n id INTEGER, -- example: [42, 44]\n name TEXT, -- example: ['Twitter', 'Facebook']\n shortcut TEXT, -- example: ['tw', 'fb']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE gender_dim (\n letter TEXT, -- example: ['F', 'M']\n name TEXT, -- example: ['Female', 'Male']\n PRIMARY KEY (letter)\n);\n\nCREATE TABLE packaging (\n id INTEGER, -- example: [501, 502]\n name TEXT, -- example: ['Bottle 330cl', 'Bottle 500cl']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE packaging_relations (\n packaging_id INTEGER, -- example: [511, 521]\n contains_id INTEGER, -- example: [501, 502]\n qty INTEGER, -- example: [3, 2]\n PRIMARY KEY (packaging_id),\n CONSTRAINT fk_packaging_relations_packaging_id FOREIGN KEY (packaging_id) REFERENCES packaging (id),\n CONSTRAINT fk_packaging_relations_contains_id FOREIGN KEY (contains_id) REFERENCES packaging (id)\n);\n\nCREATE TABLE product_groups (\n id INTEGER, -- example: [142, 152]\n name TEXT, -- example: ['Stout', 'Belgian']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE products (\n id INTEGER, -- example: [4040, 4160]\n name TEXT, -- example: ['Coalminers Sweat', 'Reindeer Fuel']\n group_id INTEGER, -- example: [142, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_products_group_id FOREIGN KEY (group_id) REFERENCES product_groups (id)\n);\n\nCREATE TABLE monthly_sales (\n product_id INTEGER, -- example: [4040, 4160]\n mth TEXT, -- example: ['2016-01-01', '2016-02-01']\n qty INTEGER, -- example: [42, 37]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_sales_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE breweries (\n id INTEGER, -- example: [518, 523]\n name TEXT, -- example: ['Balthazar Brauerei', 'Happy Hoppy Hippo']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE purchases (\n id INTEGER, -- example: [601, 611]\n purchased TEXT, -- example: ['2016-01-01', '2016-01-03']\n brewery_id INTEGER, -- example: [518, 523]\n product_id INTEGER, -- example: [4040, 4160]\n qty INTEGER, -- example: [52, 17]\n cost REAL, -- example: [388.0, 122.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_purchases_brewery_id FOREIGN KEY (brewery_id) REFERENCES breweries (id),\n CONSTRAINT fk_purchases_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_alcohol (\n product_id INTEGER, -- example: [4040, 4160]\n sales_volume REAL, -- example: [330.0, 500.0]\n abv REAL, -- example: [8.5, 6.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_alcohol_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE customer_favorites (\n customer_id INTEGER, -- example: [50042, 50741]\n favorite_list TEXT, -- example: ['4040,5310', '5430,7790,7870']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_favorites_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE customer_reviews (\n customer_id INTEGER, -- example: [50042, 50741]\n review_list TEXT, -- example: ['4040:A,6600:C,7950:B', '4160:A']\n PRIMARY KEY (customer_id),\n CONSTRAINT fk_customer_reviews_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE locations (\n id INTEGER, -- example: [1, 2]\n warehouse INTEGER, -- example: [1, 2]\n aisle TEXT, -- example: ['A', 'B']\n `position` INTEGER, -- example: [1, 2]\n PRIMARY KEY (id)\n);\n\nCREATE TABLE inventory (\n id INTEGER, -- example: [1148, 1151]\n location_id INTEGER, -- example: [2, 3]\n product_id INTEGER, -- example: [4040, 4160]\n purchase_id INTEGER, -- example: [719, 720]\n qty REAL, -- example: [11.0, 48.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_inventory_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_inventory_product_id FOREIGN KEY (product_id) REFERENCES products (id),\n CONSTRAINT fk_inventory_purchase_id FOREIGN KEY (purchase_id) REFERENCES purchases (id)\n);\n\nCREATE TABLE orders (\n id INTEGER, -- example: [421, 427]\n customer_id INTEGER, -- example: [50042, 50741]\n ordered TEXT, -- example: ['2019-01-15', '2019-01-17']\n delivery TEXT,\n PRIMARY KEY (id),\n CONSTRAINT fk_orders_customer_id FOREIGN KEY (customer_id) REFERENCES customers (id)\n);\n\nCREATE TABLE orderlines (\n id INTEGER, -- example: [9120, 9122]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [110.0, 140.0]\n amount REAL, -- example: [2400.0, 2250.0]\n PRIMARY KEY (id),\n CONSTRAINT fk_orderlines_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_orderlines_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE monthly_budget (\n product_id INTEGER, -- example: [6520, 6600]\n mth TEXT, -- example: ['2018-01-01', '2018-02-01']\n qty REAL, -- example: [30.0, 40.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_monthly_budget_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE product_minimums (\n product_id INTEGER, -- example: [6520, 6600]\n qty_minimum REAL, -- example: [100.0, 30.0]\n qty_purchase REAL, -- example: [400.0, 100.0]\n PRIMARY KEY (product_id),\n CONSTRAINT fk_product_minimums_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE stock (\n symbol TEXT, -- example: ['BEER']\n company TEXT, -- example: ['Good Beer Trading Co']\n PRIMARY KEY (symbol)\n);\n\nCREATE TABLE ticker (\n symbol TEXT, -- example: ['BEER']\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n price REAL, -- example: [14.9, 14.2]\n PRIMARY KEY (symbol),\n CONSTRAINT fk_ticker_symbol FOREIGN KEY (symbol) REFERENCES stock (symbol)\n);\n\nCREATE TABLE web_apps (\n id INTEGER, -- example: [542]\n name TEXT, -- example: ['Webshop']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE web_pages (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n friendly_url TEXT, -- example: ['/Shop', '/Categories']\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_pages_app_id FOREIGN KEY (app_id) REFERENCES web_apps (id)\n);\n\nCREATE TABLE web_counter_hist (\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n `day` TEXT, -- example: ['2019-04-01', '2019-04-02']\n counter INTEGER, -- example: [5010, 5088]\n PRIMARY KEY (app_id),\n CONSTRAINT fk_web_counter_hist_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_counter_hist_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE server_heartbeat (\n server TEXT, -- example: ['10.0.0.100', '10.0.0.142']\n beat_time TEXT, -- example: ['2019-04-10 13:00', '2019-04-10 13:05']\n);\n\nCREATE TABLE web_page_visits (\n client_ip TEXT, -- example: ['104.130.89.12', '85.237.86.200']\n visit_time TEXT, -- example: ['2019-04-20 08:15:42', '2019-04-20 08:16:31']\n app_id INTEGER, -- example: [542]\n page_no INTEGER, -- example: [1, 2]\n CONSTRAINT fk_web_page_visits_app_id FOREIGN KEY (app_id) REFERENCES web_pages (app_id),\n CONSTRAINT fk_web_page_visits_page_no FOREIGN KEY (page_no) REFERENCES web_pages (page_no)\n);\n\nCREATE TABLE employees (\n id INTEGER, -- example: [142, 144]\n name TEXT, -- example: ['Harold King', 'Mogens Juel']\n title TEXT, -- example: ['Managing Director', 'IT Manager']\n supervisor_id INTEGER, -- example: [142, 143]\n PRIMARY KEY (id),\n CONSTRAINT fk_employees_supervisor_id FOREIGN KEY (supervisor_id) REFERENCES employees (id)\n);\n\nCREATE TABLE emp_hire_periods (\n emp_id INTEGER, -- example: [142, 143]\n start_ TEXT, -- example: ['2010-07-01', '2012-04-01']\n end_ TEXT, -- example: ['2012-04-01', '2014-01-01']\n title TEXT, -- example: ['Product Director', 'Managing Director']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_emp_hire_periods_emp_id FOREIGN KEY (emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_list (\n id INTEGER, -- example: [841, 842]\n created TEXT, -- example: ['2019-01-16 14:03:41', '2019-01-19 15:57:42']\n picker_emp_id INTEGER, -- example: [149, 152]\n PRIMARY KEY (id),\n CONSTRAINT fk_picking_list_picker_emp_id FOREIGN KEY (picker_emp_id) REFERENCES employees (id)\n);\n\nCREATE TABLE picking_line (\n picklist_id INTEGER, -- example: [841, 842]\n line_no INTEGER, -- example: [1, 2]\n location_id INTEGER, -- example: [16, 29]\n order_id INTEGER, -- example: [421, 422]\n product_id INTEGER, -- example: [4280, 6520]\n qty REAL, -- example: [42.0, 14.0]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_line_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_line_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_line_order_id FOREIGN KEY (order_id) REFERENCES orders (id),\n CONSTRAINT fk_picking_line_product_id FOREIGN KEY (product_id) REFERENCES products (id)\n);\n\nCREATE TABLE picking_log (\n picklist_id INTEGER, -- example: [841, 842]\n log_time TEXT, -- example: ['2019-01-16 14:05:11', '2019-01-16 14:05:44']\n activity TEXT, -- example: ['D', 'A']\n location_id INTEGER, -- example: [16, 29]\n pickline_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_line (picklist_id),\n CONSTRAINT fk_picking_log_picklist_id FOREIGN KEY (picklist_id) REFERENCES picking_list (id),\n CONSTRAINT fk_picking_log_location_id FOREIGN KEY (location_id) REFERENCES locations (id),\n CONSTRAINT fk_picking_log_pickline_no FOREIGN KEY (pickline_no) REFERENCES picking_line (line_no)\n);\n\nCREATE TABLE id_name_type (\n id INTEGER,\n name TEXT,\n PRIMARY KEY (id)\n);\n\nCREATE TABLE id_name_coll_type (\n collection_id INTEGER,\n PRIMARY KEY (collection_id)\n);\n\nCREATE TABLE id_name_coll_entries (\n collection_id INTEGER,\n id INTEGER,\n name TEXT,\n PRIMARY KEY (collection_id),\n CONSTRAINT fk_id_name_coll_entries_collection_id FOREIGN KEY (collection_id) REFERENCES id_name_coll_type (collection_id)\n);\n\nCREATE TABLE favorite_coll_type (\n id INTEGER,\n PRIMARY KEY (id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor each product, provide the product_id, month in 2019, and the smallest difference between its ending inventory and minimum required level, based on a monthly inventory adjustment model that includes restocking when levels fall below the minimum.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please generate a summary of the closing balances at the end of each month for each customer transactions, show the monthly changes and monthly cumulative bank account balances. Ensure that even if a customer has no account activity in a given month, the balance for that month is still included in the output.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease generate a summary of the closing balances at the end of each month for each customer transactions, show the monthly changes and monthly cumulative bank account balances. Ensure that even if a customer has no account activity in a given month, the balance for that month is still included in the output.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Which bowler has the lowest bowling average per wicket taken?", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['wickets', 'runs']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich bowler has the lowest bowling average per wicket taken?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you find 5 delivery drivers with the highest average number of daily deliveries?", "schema": "CREATE TABLE channels (\n channel_id INTEGER, -- example: [1, 2]\n channel_name VARCHAR(50), -- example: ['OTHER PLACE', 'PHONE PLACE']\n channel_type VARCHAR(50), -- example: ['OWN CHANNEL', 'MARKETPLACE']\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE drivers (\n driver_id INTEGER, -- example: [133, 138]\n driver_modal VARCHAR(50), -- example: ['MOTOBOY', 'BIKER']\n driver_type VARCHAR(50), -- example: ['LOGISTIC OPERATOR', 'FREELANCE']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE deliveries (\n delivery_id INTEGER, -- example: [2174658, 2174660]\n delivery_order_id INTEGER, -- example: [68413340, 68414309]\n driver_id INTEGER, -- example: [8378, 2473]\n delivery_distance_meters DECIMAL(10, 2), -- example: [5199, 410]\n delivery_status VARCHAR(50), -- example: ['DELIVERED', 'CANCELLED']\n PRIMARY KEY (delivery_id)\n);\n\nCREATE TABLE hubs (\n hub_id INTEGER, -- example: [2, 3]\n hub_name VARCHAR(50), -- example: ['BLUE SHOPPING', 'GREEN SHOPPING']\n hub_city VARCHAR(50), -- example: ['PORTO ALEGRE', 'RIO DE JANEIRO']\n hub_state CHAR(2), -- example: ['RS', 'RJ']\n hub_latitude DECIMAL(9, 6), -- example: [-30.0474148, -30.0374149]\n hub_longitude DECIMAL(9, 6), -- example: [-51.21351, -51.20352]\n PRIMARY KEY (hub_id)\n);\n\nCREATE TABLE payments (\n payment_id INTEGER, -- example: [4427917, 4427918]\n payment_order_id INTEGER, -- example: [68410055, 68412721]\n payment_amount DECIMAL(10, 2), -- example: [118.44, 394.81]\n payment_fee DECIMAL(10, 2), -- example: [0, 7.9]\n payment_method VARCHAR(50), -- example: ['VOUCHER', 'ONLINE']\n payment_status VARCHAR(50), -- example: ['PAID', 'CHARGEBACK']\n PRIMARY KEY (payment_id)\n);\n\nCREATE TABLE stores (\n store_id INTEGER, -- example: [3, 6]\n hub_id INTEGER, -- example: [2, 3]\n store_name VARCHAR(50), -- example: ['CUMIURI', 'PIMGUCIS DA VIVA ']\n store_segment VARCHAR(50), -- example: ['FOOD', 'GOOD']\n store_plan_price DECIMAL(10, 2), -- example: [0, 49]\n store_latitude DECIMAL(9, 6), -- example: [-30.0374149, -22.921475]\n store_longitude DECIMAL(9, 6), -- example: [-51.20352, -43.234822]\n PRIMARY KEY (store_id)\n);\n\nCREATE TABLE orders (\n order_id INTEGER, -- example: [68405119, 68405123]\n store_id INTEGER, -- example: [3512, 3401]\n channel_id INTEGER, -- example: [5, 35]\n payment_order_id INTEGER, -- example: [68405119, 68405123]\n delivery_order_id INTEGER, -- example: [68405119, 68405123]\n order_status VARCHAR(50), -- example: ['CANCELED', 'FINISHED']\n order_amount DECIMAL(10, 2), -- example: [62.7, 115.5]\n order_delivery_fee DECIMAL(10, 2), -- example: [0, 9.9]\n order_delivery_cost DECIMAL(10, 2), -- example: [0, 6]\n order_created_hour INTEGER, -- example: [0, 1]\n order_created_minute INTEGER, -- example: [1, 4]\n order_created_day INTEGER, -- example: [1, 2]\n order_created_month INTEGER, -- example: [1, 2]\n order_created_year INTEGER, -- example: [2021]\n order_moment_created DATETIME, -- example: ['1/1/2021 12:01:36 AM', '1/1/2021 12:04:26 AM']\n order_moment_accepted DATETIME, -- example: ['1/1/2021 1:57:00 AM', '1/1/2021 2:33:00 AM']\n order_moment_ready DATETIME, -- example: ['1/2/2021 6:24:06 PM', '1/1/2021 2:38:15 PM']\n order_moment_collected DATETIME, -- example: ['1/2/2021 6:30:44 PM', '1/1/2021 2:38:31 PM']\n order_moment_in_expedition DATETIME, -- example: ['1/2/2021 6:31:15 PM', '1/1/2021 2:39:05 PM']\n order_moment_delivering DATETIME, -- example: ['1/2/2021 6:35:49 PM', '1/1/2021 2:49:18 PM']\n order_moment_delivered DATETIME, -- example: ['1/1/2021 4:22:19 PM', '1/1/2021 3:56:45 PM']\n order_moment_finished DATETIME, -- example: ['1/2/2021 6:57:34 PM', '1/1/2021 4:12:36 PM']\n order_metric_collected_time DECIMAL(10, 2), -- example: [6.63, 0.27]\n order_metric_paused_time DECIMAL(10, 2), -- example: [4.55, 10.22]\n order_metric_production_time DECIMAL(10, 2), -- example: [2391.25, 26.07]\n order_metric_walking_time DECIMAL(10, 2), -- example: [7.17, 0.83]\n order_metric_expediton_speed_time DECIMAL(10, 2), -- example: [11.72, 11.05]\n order_metric_transit_time DECIMAL(10, 2), -- example: [21.75, 83.3]\n order_metric_cycle_time DECIMAL(10, 2), -- example: [2424.72, 120.42]\n PRIMARY KEY (order_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE channels (\n channel_id INTEGER, -- example: [1, 2]\n channel_name VARCHAR(50), -- example: ['OTHER PLACE', 'PHONE PLACE']\n channel_type VARCHAR(50), -- example: ['OWN CHANNEL', 'MARKETPLACE']\n PRIMARY KEY (channel_id)\n);\n\nCREATE TABLE drivers (\n driver_id INTEGER, -- example: [133, 138]\n driver_modal VARCHAR(50), -- example: ['MOTOBOY', 'BIKER']\n driver_type VARCHAR(50), -- example: ['LOGISTIC OPERATOR', 'FREELANCE']\n PRIMARY KEY (driver_id)\n);\n\nCREATE TABLE deliveries (\n delivery_id INTEGER, -- example: [2174658, 2174660]\n delivery_order_id INTEGER, -- example: [68413340, 68414309]\n driver_id INTEGER, -- example: [8378, 2473]\n delivery_distance_meters DECIMAL(10, 2), -- example: [5199, 410]\n delivery_status VARCHAR(50), -- example: ['DELIVERED', 'CANCELLED']\n PRIMARY KEY (delivery_id)\n);\n\nCREATE TABLE hubs (\n hub_id INTEGER, -- example: [2, 3]\n hub_name VARCHAR(50), -- example: ['BLUE SHOPPING', 'GREEN SHOPPING']\n hub_city VARCHAR(50), -- example: ['PORTO ALEGRE', 'RIO DE JANEIRO']\n hub_state CHAR(2), -- example: ['RS', 'RJ']\n hub_latitude DECIMAL(9, 6), -- example: [-30.0474148, -30.0374149]\n hub_longitude DECIMAL(9, 6), -- example: [-51.21351, -51.20352]\n PRIMARY KEY (hub_id)\n);\n\nCREATE TABLE payments (\n payment_id INTEGER, -- example: [4427917, 4427918]\n payment_order_id INTEGER, -- example: [68410055, 68412721]\n payment_amount DECIMAL(10, 2), -- example: [118.44, 394.81]\n payment_fee DECIMAL(10, 2), -- example: [0, 7.9]\n payment_method VARCHAR(50), -- example: ['VOUCHER', 'ONLINE']\n payment_status VARCHAR(50), -- example: ['PAID', 'CHARGEBACK']\n PRIMARY KEY (payment_id)\n);\n\nCREATE TABLE stores (\n store_id INTEGER, -- example: [3, 6]\n hub_id INTEGER, -- example: [2, 3]\n store_name VARCHAR(50), -- example: ['CUMIURI', 'PIMGUCIS DA VIVA ']\n store_segment VARCHAR(50), -- example: ['FOOD', 'GOOD']\n store_plan_price DECIMAL(10, 2), -- example: [0, 49]\n store_latitude DECIMAL(9, 6), -- example: [-30.0374149, -22.921475]\n store_longitude DECIMAL(9, 6), -- example: [-51.20352, -43.234822]\n PRIMARY KEY (store_id)\n);\n\nCREATE TABLE orders (\n order_id INTEGER, -- example: [68405119, 68405123]\n store_id INTEGER, -- example: [3512, 3401]\n channel_id INTEGER, -- example: [5, 35]\n payment_order_id INTEGER, -- example: [68405119, 68405123]\n delivery_order_id INTEGER, -- example: [68405119, 68405123]\n order_status VARCHAR(50), -- example: ['CANCELED', 'FINISHED']\n order_amount DECIMAL(10, 2), -- example: [62.7, 115.5]\n order_delivery_fee DECIMAL(10, 2), -- example: [0, 9.9]\n order_delivery_cost DECIMAL(10, 2), -- example: [0, 6]\n order_created_hour INTEGER, -- example: [0, 1]\n order_created_minute INTEGER, -- example: [1, 4]\n order_created_day INTEGER, -- example: [1, 2]\n order_created_month INTEGER, -- example: [1, 2]\n order_created_year INTEGER, -- example: [2021]\n order_moment_created DATETIME, -- example: ['1/1/2021 12:01:36 AM', '1/1/2021 12:04:26 AM']\n order_moment_accepted DATETIME, -- example: ['1/1/2021 1:57:00 AM', '1/1/2021 2:33:00 AM']\n order_moment_ready DATETIME, -- example: ['1/2/2021 6:24:06 PM', '1/1/2021 2:38:15 PM']\n order_moment_collected DATETIME, -- example: ['1/2/2021 6:30:44 PM', '1/1/2021 2:38:31 PM']\n order_moment_in_expedition DATETIME, -- example: ['1/2/2021 6:31:15 PM', '1/1/2021 2:39:05 PM']\n order_moment_delivering DATETIME, -- example: ['1/2/2021 6:35:49 PM', '1/1/2021 2:49:18 PM']\n order_moment_delivered DATETIME, -- example: ['1/1/2021 4:22:19 PM', '1/1/2021 3:56:45 PM']\n order_moment_finished DATETIME, -- example: ['1/2/2021 6:57:34 PM', '1/1/2021 4:12:36 PM']\n order_metric_collected_time DECIMAL(10, 2), -- example: [6.63, 0.27]\n order_metric_paused_time DECIMAL(10, 2), -- example: [4.55, 10.22]\n order_metric_production_time DECIMAL(10, 2), -- example: [2391.25, 26.07]\n order_metric_walking_time DECIMAL(10, 2), -- example: [7.17, 0.83]\n order_metric_expediton_speed_time DECIMAL(10, 2), -- example: [11.72, 11.05]\n order_metric_transit_time DECIMAL(10, 2), -- example: [21.75, 83.3]\n order_metric_cycle_time DECIMAL(10, 2), -- example: [2424.72, 120.42]\n PRIMARY KEY (order_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you find 5 delivery drivers with the highest average number of daily deliveries?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For the most common cause of traffic accidents in 2021, how much did its share (percentage in the annual roal incidents) decrease compared to 10 years earlier?", "schema": "CREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['12597', '020507']\n reporting_district TEXT, -- example: ['1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['077', '089']\n primary_road TEXT, -- example: ['RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['clear', 'raining']\n weather_2 TEXT, -- example: ['raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['construction', 'normal']\n road_condition_2 TEXT, -- example: ['normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['00', 'semi']\n party_race TEXT, -- example: ['white', 'hispanic']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['12597', '020507']\n reporting_district TEXT, -- example: ['1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['077', '089']\n primary_road TEXT, -- example: ['RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['clear', 'raining']\n weather_2 TEXT, -- example: ['raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['construction', 'normal']\n road_condition_2 TEXT, -- example: ['normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['00', 'semi']\n party_race TEXT, -- example: ['white', 'hispanic']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor the most common cause of traffic accidents in 2021, how much did its share (percentage in the annual roal incidents) decrease compared to 10 years earlier?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Please calculate the average payment value, city, and state for the top 3 customers with the most delivered orders.", "schema": "CREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['top ', 'Top ', 'TOP', 'Top', 'top', 'Recebi bem antes do prazo estipulado.']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['top ', 'Top ', 'TOP', 'Top', 'top', 'Recebi bem antes do prazo estipulado.']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease calculate the average payment value, city, and state for the top 3 customers with the most delivered orders.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "How many customers were in each spending group in 1998, and what percentage of the total customer base does each group represent?", "schema": "CREATE TABLE categories (\n categoryid INTEGER, -- example: [1, 2]\n categoryname TEXT, -- example: ['Beverages', 'Condiments']\n description TEXT, -- example: ['Soft drinks, coffees, teas, beers, and a', 'Sweet and savory sauces, relishes, sprea']\n picture BLOB, -- example: ['\\\\x']\n);\n\nCREATE TABLE customercustomerdemo (\n customerid TEXT,\n customertypeid TEXT\n);\n\nCREATE TABLE customerdemographics (\n customertypeid TEXT,\n customerdesc TEXT\n);\n\nCREATE TABLE customers (\n customerid TEXT, -- example: ['ALFKI', 'ANATR']\n companyname TEXT, -- example: ['Alfreds Futterkiste', 'Ana Trujillo Emparedados y helados']\n contactname TEXT, -- example: ['Maria Anders', 'Ana Trujillo']\n contacttitle TEXT, -- example: ['Sales Representative', 'Owner']\n address TEXT, -- example: ['Obere Str. 57', 'Avda. de la Constitución 2222']\n city TEXT, -- example: ['Berlin', 'México D.F.']\n region TEXT, -- example: ['BC', 'SP']\n postalcode TEXT, -- example: ['12209', '05021']\n country TEXT, -- example: ['Germany', 'Mexico']\n phone TEXT, -- example: ['030-0074321', '(5) 555-4729']\n fax TEXT, -- example: ['030-0076545', '(5) 555-3745']\n);\n\nCREATE TABLE employees (\n employeeid INTEGER, -- example: [1, 2]\n lastname TEXT, -- example: ['Davolio', 'Fuller']\n firstname TEXT, -- example: ['Nancy', 'Andrew']\n title TEXT, -- example: ['Sales Representative', 'Vice President, Sales']\n titleofcourtesy TEXT, -- example: ['Ms.', 'Dr.']\n birthdate DATE, -- example: ['1948-12-08', '1952-02-19']\n hiredate DATE, -- example: ['1992-05-01', '1992-08-14']\n address TEXT, -- example: ['507 - 20th Ave. E.\\\\nApt. 2A', '908 W. Capital Way']\n city TEXT, -- example: ['Seattle', 'Tacoma']\n region TEXT, -- example: ['WA']\n postalcode TEXT, -- example: ['98122', '98401']\n country TEXT, -- example: ['USA', 'UK']\n homephone TEXT, -- example: ['(206) 555-9857', '(206) 555-9482']\n extension TEXT, -- example: ['5467', '3457']\n photo BLOB, -- example: ['\\\\x']\n notes TEXT, -- example: ['Education includes a BA in psychology fr', 'Andrew received his BTS commercial in 19']\n reportsto INTEGER, -- example: [2, 5]\n photopath TEXT, -- example: ['http://accweb/emmployees/davolio.bmp', 'http://accweb/emmployees/fuller.bmp']\n);\n\nCREATE TABLE employeeterritories (\n employeeid INTEGER, -- example: [1, 2]\n territoryid TEXT, -- example: ['06897', '19713']\n);\n\nCREATE TABLE order_details (\n orderid INTEGER, -- example: [10248, 10249]\n productid INTEGER, -- example: [11, 42]\n unitprice REAL, -- example: [14.0, 9.80000019]\n quantity INTEGER, -- example: [12, 10]\n discount REAL, -- example: [0.0, 0.150000006]\n);\n\nCREATE TABLE orders (\n orderid INTEGER, -- example: [10248, 10249]\n customerid TEXT, -- example: ['VINET', 'TOMSP']\n employeeid INTEGER, -- example: [5, 6]\n orderdate DATE, -- example: ['1996-07-04', '1996-07-05']\n requireddate DATE, -- example: ['1996-08-01', '1996-08-16']\n shippeddate DATE, -- example: ['1996-07-16', '1996-07-10']\n shipvia INTEGER, -- example: [3, 1]\n freight REAL, -- example: [32.3800011, 11.6099997]\n shipname TEXT, -- example: ['Vins et alcools Chevalier', 'Toms Spezialitäten']\n shipaddress TEXT, -- example: [\"59 rue de l'Abbaye\", 'Luisenstr. 48']\n shipcity TEXT, -- example: ['Reims', 'Münster']\n shipregion TEXT, -- example: ['RJ', 'SP']\n shippostalcode TEXT, -- example: ['51100', '44087']\n shipcountry TEXT, -- example: ['France', 'Germany']\n);\n\nCREATE TABLE products (\n productid INTEGER, -- example: [1, 2]\n productname TEXT, -- example: ['Chai', 'Chang']\n supplierid INTEGER, -- example: [8, 1]\n categoryid INTEGER, -- example: [1, 2]\n quantityperunit TEXT, -- example: ['10 boxes x 30 bags', '24 - 12 oz bottles']\n unitprice REAL, -- example: [18.0, 19.0]\n unitsinstock INTEGER, -- example: [39, 17]\n unitsonorder INTEGER, -- example: [0, 40]\n reorderlevel INTEGER, -- example: [10, 25]\n discontinued INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE region (\n regionid INTEGER, -- example: [1, 2]\n regiondescription TEXT, -- example: ['Eastern', 'Western']\n);\n\nCREATE TABLE shippers (\n shipperid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Speedy Express', 'United Package']\n phone TEXT, -- example: ['(503) 555-9831', '(503) 555-3199']\n);\n\nCREATE TABLE suppliers (\n supplierid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Exotic Liquids', 'New Orleans Cajun Delights']\n contactname TEXT, -- example: ['Charlotte Cooper', 'Shelley Burke']\n contacttitle TEXT, -- example: ['Purchasing Manager', 'Order Administrator']\n address TEXT, -- example: ['49 Gilbert St.', 'P.O. Box 78934']\n city TEXT, -- example: ['London', 'New Orleans']\n region TEXT, -- example: ['LA', 'MI']\n postalcode TEXT, -- example: ['EC1 4SD', '70117']\n country TEXT, -- example: ['UK', 'USA']\n phone TEXT, -- example: ['(171) 555-2222', '(100) 555-4822']\n fax TEXT, -- example: ['(313) 555-3349', '(03) 444-6588']\n homepage TEXT, -- example: ['#CAJUN.HTM#', \"Mayumi's (on the World Wide Web)#http://\"]\n);\n\nCREATE TABLE territories (\n territoryid TEXT, -- example: ['01581', '01730']\n territorydescription TEXT, -- example: ['Westboro', 'Bedford']\n regionid INTEGER, -- example: [1, 3]\n);\n\nCREATE TABLE usstates (\n stateid INTEGER, -- example: [1, 2]\n statename TEXT, -- example: ['Alabama', 'Alaska']\n stateabbr TEXT, -- example: ['AL', 'AK']\n stateregion TEXT, -- example: ['south', 'north']\n);\n\nCREATE TABLE customergroupthreshold (\n groupname TEXT, -- example: ['Low', 'Medium']\n rangebottom DECIMAL, -- example: [0, 1000]\n rangetop DECIMAL, -- example: [999.9999, 4999.9999]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE categories (\n categoryid INTEGER, -- example: [1, 2]\n categoryname TEXT, -- example: ['Beverages', 'Condiments']\n description TEXT, -- example: ['Soft drinks, coffees, teas, beers, and a', 'Sweet and savory sauces, relishes, sprea']\n picture BLOB, -- example: ['\\\\x']\n);\n\nCREATE TABLE customercustomerdemo (\n customerid TEXT,\n customertypeid TEXT\n);\n\nCREATE TABLE customerdemographics (\n customertypeid TEXT,\n customerdesc TEXT\n);\n\nCREATE TABLE customers (\n customerid TEXT, -- example: ['ALFKI', 'ANATR']\n companyname TEXT, -- example: ['Alfreds Futterkiste', 'Ana Trujillo Emparedados y helados']\n contactname TEXT, -- example: ['Maria Anders', 'Ana Trujillo']\n contacttitle TEXT, -- example: ['Sales Representative', 'Owner']\n address TEXT, -- example: ['Obere Str. 57', 'Avda. de la Constitución 2222']\n city TEXT, -- example: ['Berlin', 'México D.F.']\n region TEXT, -- example: ['BC', 'SP']\n postalcode TEXT, -- example: ['12209', '05021']\n country TEXT, -- example: ['Germany', 'Mexico']\n phone TEXT, -- example: ['030-0074321', '(5) 555-4729']\n fax TEXT, -- example: ['030-0076545', '(5) 555-3745']\n);\n\nCREATE TABLE employees (\n employeeid INTEGER, -- example: [1, 2]\n lastname TEXT, -- example: ['Davolio', 'Fuller']\n firstname TEXT, -- example: ['Nancy', 'Andrew']\n title TEXT, -- example: ['Sales Representative', 'Vice President, Sales']\n titleofcourtesy TEXT, -- example: ['Ms.', 'Dr.']\n birthdate DATE, -- example: ['1948-12-08', '1952-02-19']\n hiredate DATE, -- example: ['1992-05-01', '1992-08-14']\n address TEXT, -- example: ['507 - 20th Ave. E.\\\\nApt. 2A', '908 W. Capital Way']\n city TEXT, -- example: ['Seattle', 'Tacoma']\n region TEXT, -- example: ['WA']\n postalcode TEXT, -- example: ['98122', '98401']\n country TEXT, -- example: ['USA', 'UK']\n homephone TEXT, -- example: ['(206) 555-9857', '(206) 555-9482']\n extension TEXT, -- example: ['5467', '3457']\n photo BLOB, -- example: ['\\\\x']\n notes TEXT, -- example: ['Education includes a BA in psychology fr', 'Andrew received his BTS commercial in 19']\n reportsto INTEGER, -- example: [2, 5]\n photopath TEXT, -- example: ['http://accweb/emmployees/davolio.bmp', 'http://accweb/emmployees/fuller.bmp']\n);\n\nCREATE TABLE employeeterritories (\n employeeid INTEGER, -- example: [1, 2]\n territoryid TEXT, -- example: ['06897', '19713']\n);\n\nCREATE TABLE order_details (\n orderid INTEGER, -- example: [10248, 10249]\n productid INTEGER, -- example: [11, 42]\n unitprice REAL, -- example: [14.0, 9.80000019]\n quantity INTEGER, -- example: [12, 10]\n discount REAL, -- example: [0.0, 0.150000006]\n);\n\nCREATE TABLE orders (\n orderid INTEGER, -- example: [10248, 10249]\n customerid TEXT, -- example: ['VINET', 'TOMSP']\n employeeid INTEGER, -- example: [5, 6]\n orderdate DATE, -- example: ['1996-07-04', '1996-07-05']\n requireddate DATE, -- example: ['1996-08-01', '1996-08-16']\n shippeddate DATE, -- example: ['1996-07-16', '1996-07-10']\n shipvia INTEGER, -- example: [3, 1]\n freight REAL, -- example: [32.3800011, 11.6099997]\n shipname TEXT, -- example: ['Vins et alcools Chevalier', 'Toms Spezialitäten']\n shipaddress TEXT, -- example: [\"59 rue de l'Abbaye\", 'Luisenstr. 48']\n shipcity TEXT, -- example: ['Reims', 'Münster']\n shipregion TEXT, -- example: ['RJ', 'SP']\n shippostalcode TEXT, -- example: ['51100', '44087']\n shipcountry TEXT, -- example: ['France', 'Germany']\n);\n\nCREATE TABLE products (\n productid INTEGER, -- example: [1, 2]\n productname TEXT, -- example: ['Chai', 'Chang']\n supplierid INTEGER, -- example: [8, 1]\n categoryid INTEGER, -- example: [1, 2]\n quantityperunit TEXT, -- example: ['10 boxes x 30 bags', '24 - 12 oz bottles']\n unitprice REAL, -- example: [18.0, 19.0]\n unitsinstock INTEGER, -- example: [39, 17]\n unitsonorder INTEGER, -- example: [0, 40]\n reorderlevel INTEGER, -- example: [10, 25]\n discontinued INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE region (\n regionid INTEGER, -- example: [1, 2]\n regiondescription TEXT, -- example: ['Eastern', 'Western']\n);\n\nCREATE TABLE shippers (\n shipperid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Speedy Express', 'United Package']\n phone TEXT, -- example: ['(503) 555-9831', '(503) 555-3199']\n);\n\nCREATE TABLE suppliers (\n supplierid INTEGER, -- example: [1, 2]\n companyname TEXT, -- example: ['Exotic Liquids', 'New Orleans Cajun Delights']\n contactname TEXT, -- example: ['Charlotte Cooper', 'Shelley Burke']\n contacttitle TEXT, -- example: ['Purchasing Manager', 'Order Administrator']\n address TEXT, -- example: ['49 Gilbert St.', 'P.O. Box 78934']\n city TEXT, -- example: ['London', 'New Orleans']\n region TEXT, -- example: ['LA', 'MI']\n postalcode TEXT, -- example: ['EC1 4SD', '70117']\n country TEXT, -- example: ['UK', 'USA']\n phone TEXT, -- example: ['(171) 555-2222', '(100) 555-4822']\n fax TEXT, -- example: ['(313) 555-3349', '(03) 444-6588']\n homepage TEXT, -- example: ['#CAJUN.HTM#', \"Mayumi's (on the World Wide Web)#http://\"]\n);\n\nCREATE TABLE territories (\n territoryid TEXT, -- example: ['01581', '01730']\n territorydescription TEXT, -- example: ['Westboro', 'Bedford']\n regionid INTEGER, -- example: [1, 3]\n);\n\nCREATE TABLE usstates (\n stateid INTEGER, -- example: [1, 2]\n statename TEXT, -- example: ['Alabama', 'Alaska']\n stateabbr TEXT, -- example: ['AL', 'AK']\n stateregion TEXT, -- example: ['south', 'north']\n);\n\nCREATE TABLE customergroupthreshold (\n groupname TEXT, -- example: ['Low', 'Medium']\n rangebottom DECIMAL, -- example: [0, 1000]\n rangetop DECIMAL, -- example: [999.9999, 4999.9999]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many customers were in each spending group in 1998, and what percentage of the total customer base does each group represent?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Can you provide a breakdown of how many times each product was viewed, how many times they were added to the shopping cart, and how many times they were left in the cart without being purchased? Also, give me the count of actual purchases for each product. Ensure that products with a page id in (1, 2, 12, 13) are filtered out.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['purchase', 'deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Purchase', 'Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['purchase', 'deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['BUY', 'SELL']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Purchase', 'Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCan you provide a breakdown of how many times each product was viewed, how many times they were added to the shopping cart, and how many times they were left in the cart without being purchased? Also, give me the count of actual purchases for each product. Ensure that products with a page id in (1, 2, 12, 13) are filtered out.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Identify the country with data inserted on nine different days in January 2022. Then, find the longest consecutive period with data insertions for this country during January 2022, and calculate the proportion of entries that are from its capital city within this longest consecutive insertion period.", "schema": "CREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Day', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['January', 'Day', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['day', 'year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['january', 'day', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['January', 'Day', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Within', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aliens_details (\n detail_id INTEGER, -- example: [1, 2]\n favorite_food TEXT, -- example: ['White-faced tree rat', 'Lizard, goanna']\n feeding_frequency TEXT, -- example: ['Weekly', 'Seldom']\n aggressive INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE skills_dim (\n skill_id INTEGER, -- example: [195, 201]\n skills TEXT, -- example: ['sharepoint', 'alteryx']\n type TEXT, -- example: ['analyst_tools', 'webframeworks']\n);\n\nCREATE TABLE legislators_terms (\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n term_number INTEGER, -- example: [0, 1]\n term_id TEXT, -- example: ['B000944-0', 'C000127-0']\n term_type TEXT, -- example: ['rep', 'sen']\n term_start TEXT, -- example: ['1993-01-05', '1987-01-06']\n term_end TEXT, -- example: ['1995-01-03', '1989-01-03']\n state TEXT, -- example: ['OH', 'WA']\n district REAL, -- example: [13.0, 1.0]\n class REAL, -- example: [1.0, 2.0]\n party TEXT, -- example: ['Democrat', 'Republican']\n how TEXT, -- example: ['appointment']\n url TEXT, -- example: ['http://casey.senate.gov/', 'https://fulcher.house.gov']\n address TEXT, -- example: ['393 RUSSELL SENATE OFFICE BUILDING WASHI', '1520 Longworth House Office Building; Wa']\n phone TEXT, -- example: ['202-224-6324', '202-225-6611']\n fax TEXT, -- example: ['202-228-0604', '202-228-2186']\n contact_form TEXT, -- example: ['http://www.casey.senate.gov/contact/', 'http://www.klobuchar.senate.gov/emailamy']\n office TEXT, -- example: ['393 Russell Senate Office Building', '1520 Longworth House Office Building']\n state_rank TEXT, -- example: ['senior', 'junior']\n rss_url TEXT, -- example: ['http://www.merkley.senate.gov/rss/', 'http://www.shaheen.senate.gov/rss/']\n caucus TEXT, -- example: ['Democrat']\n);\n\nCREATE TABLE cities_currencies (\n currency_id INTEGER, -- example: [1, 2]\n country_code_2 TEXT, -- example: ['af', 'al']\n currency_name TEXT, -- example: ['afghani', 'lek']\n currency_code TEXT, -- example: ['afn', 'all']\n);\n\nCREATE TABLE legislators (\n full_name TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n first_name TEXT, -- example: ['Sherrod', 'Maria']\n last_name TEXT, -- example: ['Day', 'Brown', 'Cantwell']\n middle_name TEXT, -- example: ['January', 'Day', 'L.', 'Richard']\n nickname TEXT, -- example: ['Bob', 'Bernie']\n suffix TEXT, -- example: ['Jr.', 'III']\n other_names_end TEXT, -- example: ['1846-01-12', '1995-09-03']\n other_names_middle REAL,\n other_names_last TEXT, -- example: ['Menendez', 'Levy']\n birthday TEXT, -- example: ['1952-11-09', '1958-10-13']\n gender TEXT, -- example: ['M', 'F']\n id_bioguide TEXT, -- example: ['B000944', 'C000127']\n id_bioguide_previous_0 TEXT, -- example: ['F000246', 'L000266']\n id_govtrack INTEGER, -- example: [400050, 300018]\n id_icpsr REAL, -- example: [29389.0, 39310.0]\n id_wikipedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_wikidata TEXT, -- example: ['Q381880', 'Q22250']\n id_google_entity_id TEXT, -- example: ['kg:/m/034s80', 'kg:/m/01x68t']\n id_house_history REAL, -- example: [9996.0, 10608.0]\n id_house_history_alternate REAL, -- example: [13283.0]\n id_thomas REAL, -- example: [136.0, 172.0]\n id_cspan REAL, -- example: [5051.0, 26137.0]\n id_votesmart REAL, -- example: [27018.0, 27122.0]\n id_lis TEXT, -- example: ['S307', 'S275']\n id_ballotpedia TEXT, -- example: ['Sherrod Brown', 'Maria Cantwell']\n id_opensecrets TEXT, -- example: ['N00003535', 'N00007836']\n id_fec_0 TEXT, -- example: ['H2OH13033', 'S8WA00194']\n id_fec_1 TEXT, -- example: ['S6OH00163', 'H2WA01054']\n id_fec_2 TEXT, -- example: ['S4TN00096', 'S0NV00237']\n);\n\nCREATE TABLE skills_job_dim (\n job_id INTEGER, -- example: [310991, 471015]\n skill_id INTEGER, -- example: [1, 0]\n);\n\nCREATE TABLE job_postings_fact (\n job_id INTEGER, -- example: [1422666, 399976]\n company_id INTEGER, -- example: [58904, 939]\n job_title_short TEXT, -- example: ['Data Analyst', 'Senior Data Engineer']\n job_title TEXT, -- example: ['JUNIOR IT DATA ANALYST (DURBAN)', 'Trainee, L1 integration and data analyti']\n job_location TEXT, -- example: ['Durban, South Africa', 'Oulu, Finland']\n job_via TEXT, -- example: ['via Pnet', 'via Nokia - Talentify']\n job_schedule_type TEXT, -- example: ['Full-time', 'Contractor']\n job_work_from_home INTEGER, -- example: [0, 1]\n search_location TEXT, -- example: ['South Africa', 'Finland']\n job_posted_date TEXT, -- example: ['2023-01-09 12:31:15', '2023-03-02 08:32:37']\n job_no_degree_mention INTEGER, -- example: [1, 0]\n job_health_insurance INTEGER, -- example: [0, 1]\n job_country TEXT, -- example: ['South Africa', 'Finland']\n salary_rate TEXT, -- example: ['day', 'year', 'hour']\n salary_year_avg REAL, -- example: [300000.0, 120000.0]\n salary_hour_avg REAL, -- example: [77.5, 27.979999542236328]\n);\n\nCREATE TABLE alien_data (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['tyrus', 'ealasaid']\n last_name TEXT, -- example: ['january', 'day', 'wrey', 'st louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['non-binary', 'female']\n type TEXT, -- example: ['reptile', 'flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n age INTEGER, -- example: [307, 351]\n favorite_food TEXT, -- example: ['white-faced tree rat', 'lizard, goanna']\n feeding_frequency TEXT, -- example: ['weekly', 'seldom']\n aggressive INTEGER, -- example: [1, 0]\n occupation TEXT, -- example: ['senior cost accountant', 'senior sales associate']\n current_location TEXT, -- example: ['cincinnati', 'bethesda']\n state TEXT, -- example: ['ohio', 'maryland']\n us_region TEXT, -- example: ['great lakes', 'mideast']\n country TEXT, -- example: ['united states']\n);\n\nCREATE TABLE cities_countries (\n country_id INTEGER, -- example: [1, 2]\n country_name TEXT, -- example: ['afghanistan', 'albania']\n country_code_2 TEXT, -- example: ['af', 'al']\n country_code_3 TEXT, -- example: ['afg', 'alb']\n region TEXT, -- example: ['asia', 'europe']\n sub_region TEXT, -- example: ['southern asia', 'southern europe']\n intermediate_region TEXT, -- example: ['middle africa', 'caribbean']\n created_on TEXT, -- example: ['2024-07-18']\n);\n\nCREATE TABLE legislation_date_dim (\n `date` TEXT, -- example: ['1917-01-01', '1917-01-02']\n month_name TEXT, -- example: ['January', 'February']\n day_of_month INTEGER, -- example: [1, 2]\n);\n\nCREATE TABLE cities (\n city_id INTEGER, -- example: [1, 2]\n city_name TEXT, -- example: ['tokyo', 'jakarta']\n latitude REAL, -- example: [139.6922, 106.8275]\n longitude REAL, -- example: [35.6897, -6.175]\n country_code_2 TEXT, -- example: ['jp', 'id']\n capital INTEGER, -- example: [1, 0]\n population REAL, -- example: [37732000.0, 33756000.0]\n insert_date TEXT, -- example: ['2022-01-12', '2021-08-22']\n);\n\nCREATE TABLE aliens_location (\n loc_id INTEGER, -- example: [1, 2]\n current_location TEXT, -- example: ['Cincinnati', 'Bethesda']\n state TEXT, -- example: ['Ohio', 'Maryland']\n country TEXT, -- example: ['United States']\n occupation TEXT, -- example: ['Senior Cost Accountant', 'Senior Sales Associate']\n);\n\nCREATE TABLE aliens (\n id INTEGER, -- example: [1, 2]\n first_name TEXT, -- example: ['Tyrus', 'Ealasaid']\n last_name TEXT, -- example: ['January', 'Day', 'Wrey', 'St Louis']\n email TEXT, -- example: ['twrey0@sakura.ne.jp', 'estlouis1@amazon.co.uk']\n gender TEXT, -- example: ['Agender', 'Female']\n type TEXT, -- example: ['Reptile', 'Flatwoods']\n birth_year INTEGER, -- example: [1717, 1673]\n);\n\nCREATE TABLE cities_languages (\n language_id INTEGER, -- example: [1, 2]\n `language` TEXT, -- example: ['pashto', 'persian']\n country_code_2 TEXT, -- example: ['af', 'al']\n);\n\nCREATE TABLE job_company (\n company_id INTEGER, -- example: [195094, 211890]\n name TEXT, -- example: ['Within', 'Kaderabotim.bg', 'acalerate']\n link TEXT, -- example: ['http://www.bitplane.com/', 'http://www.face2face.eu/']\n link_google TEXT, -- example: ['https://www.google.com/search?sca_esv=59', 'https://www.google.com/search?gl=us&hl=e']\n thumbnail TEXT, -- example: ['https://encrypted-tbn0.gstatic.com/image']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIdentify the country with data inserted on nine different days in January 2022. Then, find the longest consecutive period with data insertions for this country during January 2022, and calculate the proportion of entries that are from its capital city within this longest consecutive insertion period.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For veg whsle data, can you analyze our financial performance over the years 2020 to 2023? I need insights into the average wholesale price, maximum wholesale price, minimum wholesale price, wholesale price difference, total wholesale price, total selling price, average loss rate, total loss, and profit for each category within each year. Round all calculated values to two decimal places.", "schema": "CREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['SELL', 'BUY']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE weekly_sales (\n week_date TEXT, -- example: ['31/8/20', '24/8/20']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n);\n\nCREATE TABLE shopping_cart_users (\n user_id INTEGER, -- example: [1, 2]\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n start_date TEXT, -- example: ['2020-02-04', '2020-01-18']\n);\n\nCREATE TABLE bitcoin_members (\n member_id TEXT, -- example: ['c4ca42', 'c81e72']\n first_name TEXT, -- example: ['Danny', 'Vipul']\n region TEXT, -- example: ['Australia', 'United States']\n);\n\nCREATE TABLE interest_metrics (\n _month REAL, -- example: [7.0, 8.0]\n _year REAL, -- example: [2018.0, 2019.0]\n month_year TEXT, -- example: ['07-2018', '08-2018']\n interest_id REAL, -- example: [32486.0, 6106.0]\n composition REAL, -- example: [11.89, 9.93]\n index_value REAL, -- example: [6.19, 5.31]\n ranking INTEGER, -- example: [1, 2]\n percentile_ranking REAL, -- example: [99.86, 99.73]\n);\n\nCREATE TABLE customer_regions (\n region_id INTEGER, -- example: [1, 2]\n region_name TEXT, -- example: ['Australia', 'America']\n);\n\nCREATE TABLE customer_transactions (\n customer_id INTEGER, -- example: [429, 155]\n txn_date TEXT, -- example: ['2020-01-21', '2020-01-10']\n txn_type TEXT, -- example: ['deposit', 'withdrawal']\n txn_amount INTEGER, -- example: [82, 712]\n);\n\nCREATE TABLE bitcoin_transactions (\n txn_id INTEGER, -- example: [1, 2]\n member_id TEXT, -- example: ['c81e72', 'eccbc8']\n ticker TEXT, -- example: ['BTC', 'ETH']\n txn_date TEXT, -- example: ['01-01-2017', '02-01-2017']\n txn_type TEXT, -- example: ['SELL', 'BUY']\n quantity REAL, -- example: [50.0, 9.562185136]\n percentage_fee REAL, -- example: [0.3, 0.0]\n txn_time TEXT, -- example: ['2017-01-01T00:00:00.000Z', '2017-01-01T01:22:32.097Z']\n);\n\nCREATE TABLE customer_nodes (\n customer_id INTEGER, -- example: [1, 2]\n region_id INTEGER, -- example: [3, 5]\n node_id INTEGER, -- example: [4, 5]\n start_date TEXT, -- example: ['2020-01-02', '2020-01-03']\n end_date TEXT, -- example: ['2020-01-03', '2020-01-17']\n);\n\nCREATE TABLE cleaned_weekly_sales (\n week_date_formatted TEXT, -- example: ['2020-8-31', '2020-8-24']\n week_date TEXT, -- example: ['2020-08-31', '2020-08-24']\n region TEXT, -- example: ['ASIA', 'USA']\n platform TEXT, -- example: ['Retail', 'Shopify']\n segment TEXT, -- example: ['C3', 'F1']\n customer_type TEXT, -- example: ['New', 'Guest']\n transactions INTEGER, -- example: [120631, 31574]\n sales INTEGER, -- example: [3656163, 996575]\n week_number INTEGER, -- example: [36, 35]\n month_number INTEGER, -- example: [8, 7]\n calendar_year INTEGER, -- example: [2020, 2019]\n age_band TEXT, -- example: ['Retirees', 'Young Adults']\n demographic TEXT, -- example: ['Couples', 'Families']\n avg_transaction REAL, -- example: [30.31, 31.56]\n);\n\nCREATE TABLE veg_txn_df (\n `index` INTEGER, -- example: [0, 1]\n txn_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n txn_time TEXT, -- example: ['09:15:07', '09:17:27']\n item_code INTEGER, -- example: [102900005117056, 102900005115960]\n `qty_sold(kg)` REAL, -- example: [0.396, 0.849]\n `unit_selling_px_rmb/kg` REAL, -- example: [7.6, 3.2]\n `sale/return` TEXT, -- example: ['sale', 'return']\n `discount(%)` INTEGER, -- example: [1]\n day_of_week TEXT, -- example: ['Wednesday', 'Thursday']\n);\n\nCREATE TABLE shopping_cart_events (\n visit_id TEXT, -- example: ['ccf365', 'd58cbd']\n cookie_id TEXT, -- example: ['c4ca42', 'c81e72']\n page_id INTEGER, -- example: [1, 2]\n event_type INTEGER, -- example: [1, 2]\n sequence_number INTEGER, -- example: [1, 2]\n event_time TEXT, -- example: ['2020-02-04 19:16:09.182546', '2020-02-04 19:16:17.358191']\n);\n\nCREATE TABLE shopping_cart_page_hierarchy (\n page_id INTEGER, -- example: [1, 2]\n page_name TEXT, -- example: ['Home Page', 'All Products']\n product_category TEXT, -- example: ['Fish', 'Luxury']\n product_id REAL, -- example: [1.0, 2.0]\n);\n\nCREATE TABLE bitcoin_prices (\n ticker TEXT, -- example: ['ETH', 'BTC']\n market_date TEXT, -- example: ['29-08-2021', '28-08-2021']\n price REAL, -- example: [3177.84, 3243.9]\n `open` REAL, -- example: [3243.96, 3273.78]\n high REAL, -- example: [3282.21, 3284.58]\n low REAL, -- example: [3162.79, 3212.24]\n volume TEXT, -- example: ['582.04K', '466.21K']\n change TEXT, -- example: ['-2.04%', '-0.91%']\n);\n\nCREATE TABLE interest_map (\n id INTEGER, -- example: [1, 2]\n interest_name TEXT, -- example: ['Fitness Enthusiasts', 'Gamers']\n interest_summary TEXT, -- example: ['Consumers using fitness tracking apps an', 'Consumers researching game reviews and c']\n created_at TEXT, -- example: ['2016-05-26 14:57:59', '2016-06-09 16:28:11']\n last_modified TEXT, -- example: ['2018-05-23 11:30:12', '2018-05-23 11:30:13']\n);\n\nCREATE TABLE veg_loss_rate_df (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n `loss_rate_%` REAL, -- example: [4.39, 10.46]\n);\n\nCREATE TABLE shopping_cart_campaign_identifier (\n campaign_id INTEGER, -- example: [1, 2]\n products TEXT, -- example: ['1-3', '4-5']\n campaign_name TEXT, -- example: ['BOGOF - Fishing For Compliments', '25% Off - Living The Lux Life']\n start_date TEXT, -- example: ['2020-01-01', '2020-01-15']\n end_date TEXT, -- example: ['2020-01-14', '2020-01-28']\n);\n\nCREATE TABLE veg_cat (\n `index` INTEGER, -- example: [0, 1]\n item_code INTEGER, -- example: [102900005115168, 102900005115199]\n item_name TEXT, -- example: ['Niushou Shengcai', 'Sichuan Red Cedar']\n category_code INTEGER, -- example: [1011010101, 1011010201]\n category_name TEXT, -- example: ['Flower/Leaf\\xa0Vegetables', 'Cabbage']\n);\n\nCREATE TABLE veg_whsle_df (\n `index` INTEGER, -- example: [0, 1]\n whsle_date TEXT, -- example: ['2020-07-01 00:00:00', '2020-07-02 00:00:00']\n item_code INTEGER, -- example: [102900005115762, 102900005115779]\n `whsle_px_rmb-kg` REAL, -- example: [3.88, 6.72]\n);\n\nCREATE TABLE shopping_cart_event_identifier (\n event_type INTEGER, -- example: [1, 2]\n event_name TEXT, -- example: ['Page View', 'Add to Cart']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFor veg whsle data, can you analyze our financial performance over the years 2020 to 2023? I need insights into the average wholesale price, maximum wholesale price, minimum wholesale price, wholesale price difference, total wholesale price, total selling price, average loss rate, total loss, and profit for each category within each year. Round all calculated values to two decimal places.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "In which year were the two most common causes of traffic accidents different from those in other years?", "schema": "CREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['OTHER', '12597', '020507']\n reporting_district TEXT, -- example: ['TWO', '1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['TWO', '077', '089']\n primary_road TEXT, -- example: ['RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['other', 'clear', 'raining']\n weather_2 TEXT, -- example: ['other', 'raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['other', 'rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['other', 'construction', 'normal']\n road_condition_2 TEXT, -- example: ['other', 'normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['other', 'none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['other', 'proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['00', 'semi']\n party_race TEXT, -- example: ['other', 'white', 'hispanic']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE victims (\n id INTEGER, -- example: [1087998, 952544]\n case_id REAL, -- example: [5224627.0, 930503.0]\n party_number INTEGER, -- example: [2, 1]\n victim_role TEXT, -- example: ['passenger', 'non-injured party']\n victim_sex TEXT, -- example: ['female', 'male']\n victim_age REAL, -- example: [14.0, 6.0]\n victim_degree_of_injury TEXT, -- example: ['no injury', 'complaint of pain']\n victim_seating_position TEXT, -- example: ['passenger seat 3', 'passenger seat 6']\n victim_safety_equipment_1 TEXT, -- example: ['air bag not deployed', 'child restraint in vehicle used']\n victim_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'lap belt used']\n victim_ejected TEXT, -- example: ['not ejected', 'unknown']\n);\n\nCREATE TABLE collisions (\n case_id REAL, -- example: [5419819.0, 6603782.0]\n jurisdiction REAL, -- example: [9835.0, 9340.0]\n officer_id TEXT, -- example: ['OTHER', '12597', '020507']\n reporting_district TEXT, -- example: ['TWO', '1503', '4300']\n chp_shift TEXT, -- example: ['0600 thru 1359', '1400 thru 2159']\n population TEXT, -- example: ['unincorporated', '>250000']\n county_city_location INTEGER, -- example: [3600, 4313]\n county_location TEXT, -- example: ['san bernardino', 'santa clara']\n special_condition REAL, -- example: [0.0, 1.0]\n beat_type TEXT, -- example: ['chp state highway', 'not chp']\n chp_beat_type TEXT, -- example: ['interstate', 'not chp']\n city_division_lapd TEXT, -- example: ['Q', 'H']\n chp_beat_class TEXT, -- example: ['chp other', 'not chp']\n beat_number TEXT, -- example: ['TWO', '077', '089']\n primary_road TEXT, -- example: ['RT 15', 'RT 880']\n secondary_road TEXT, -- example: ['CIMA RD', 'MONTAGUE EXPWY']\n distance REAL, -- example: [15470.0, 3000.0]\n direction TEXT, -- example: ['south', 'east']\n intersection REAL, -- example: [0.0, 1.0]\n weather_1 TEXT, -- example: ['other', 'clear', 'raining']\n weather_2 TEXT, -- example: ['other', 'raining', 'snowing']\n state_highway_indicator REAL, -- example: [1.0, 0.0]\n caltrans_county TEXT, -- example: ['san bernardino', 'santa clara']\n caltrans_district REAL, -- example: [8.0, 4.0]\n state_route REAL, -- example: [15.0, 880.0]\n route_suffix TEXT, -- example: ['B', 'S']\n postmile_prefix TEXT, -- example: ['R', 'B']\n postmile REAL, -- example: [159.8, 6.13]\n location_type TEXT, -- example: ['highway', 'intersection']\n ramp_intersection TEXT, -- example: ['intersection', 'ramp entry, first 50 feet']\n side_of_highway TEXT, -- example: ['northbound', 'eastbound']\n tow_away REAL, -- example: [1.0, 0.0]\n collision_severity TEXT, -- example: ['property damage only', 'pain']\n killed_victims REAL, -- example: [0.0, 1.0]\n injured_victims REAL, -- example: [0.0, 2.0]\n party_count REAL, -- example: [2.0, 1.0]\n primary_collision_factor TEXT, -- example: ['vehicle code violation', 'other than driver']\n pcf_violation_code TEXT, -- example: ['vehicle', \"'\"]\n pcf_violation_category TEXT, -- example: ['speeding', 'other than driver (or pedestrian)']\n pcf_violation REAL, -- example: [22350.0, 21658.0]\n pcf_violation_subsection TEXT, -- example: ['A', 'B']\n hit_and_run TEXT, -- example: ['not hit and run', 'misdemeanor']\n type_of_collision TEXT, -- example: ['other', 'rear end', 'hit object']\n motor_vehicle_involved_with TEXT, -- example: ['other motor vehicle', 'other object']\n pedestrian_action TEXT, -- example: ['no pedestrian involved', 'crossing not in crosswalk']\n road_surface TEXT, -- example: ['dry', 'wet']\n road_condition_1 TEXT, -- example: ['other', 'construction', 'normal']\n road_condition_2 TEXT, -- example: ['other', 'normal', 'reduced width']\n lighting TEXT, -- example: ['daylight', 'dark with street lights']\n control_device TEXT, -- example: ['none', 'functioning']\n chp_road_type TEXT, -- example: ['1', '0']\n pedestrian_collision INTEGER, -- example: [0, 1]\n bicycle_collision INTEGER, -- example: [0, 1]\n motorcycle_collision INTEGER, -- example: [0, 1]\n truck_collision INTEGER, -- example: [0, 1]\n not_private_property REAL, -- example: [1.0]\n alcohol_involved REAL, -- example: [1.0]\n statewide_vehicle_type_at_fault TEXT, -- example: ['passenger car', 'pickup or panel truck']\n chp_vehicle_type_at_fault TEXT, -- example: ['passenger car, station', 'pickups & panels']\n severe_injury_count INTEGER, -- example: [0, 1]\n other_visible_injury_count INTEGER, -- example: [0, 1]\n complaint_of_pain_injury_count INTEGER, -- example: [0, 2]\n pedestrian_killed_count INTEGER, -- example: [0, 1]\n pedestrian_injured_count INTEGER, -- example: [0, 1]\n bicyclist_killed_count INTEGER, -- example: [0, 1]\n bicyclist_injured_count INTEGER, -- example: [0, 1]\n motorcyclist_killed_count INTEGER, -- example: [0, 1]\n motorcyclist_injured_count REAL, -- example: [0.0, 1.0]\n primary_ramp TEXT, -- example: ['FR', 'TO']\n secondary_ramp TEXT, -- example: ['westbound off-ramp', 'northbound off-ramp']\n latitude REAL, -- example: [37.23878, 38.05759]\n longitude REAL, -- example: [-121.54662, -121.37198]\n collision_date TEXT, -- example: ['2011-11-22', '2014-07-25']\n collision_time TEXT, -- example: ['13:27:00', '14:00:00']\n process_date TEXT, -- example: ['2013-07-29', '2016-05-13']\n);\n\nCREATE TABLE case_ids (\n case_id REAL, -- example: [3736596.0, 2711941.0]\n db_year INTEGER, -- example: [2020, 2018]\n);\n\nCREATE TABLE parties (\n id INTEGER, -- example: [138356, 4145454]\n case_id REAL, -- example: [3640533.0, 2206036.0]\n party_number INTEGER, -- example: [1, 2]\n party_type TEXT, -- example: ['driver', 'parked vehicle']\n at_fault INTEGER, -- example: [1, 0]\n party_sex TEXT, -- example: ['male', 'female']\n party_age REAL, -- example: [40.0, 29.0]\n party_sobriety TEXT, -- example: ['had been drinking, impairment unknown', 'impairment unknown']\n party_drug_physical TEXT, -- example: ['G', 'under drug influence']\n direction_of_travel TEXT, -- example: ['west', 'east']\n party_safety_equipment_1 TEXT, -- example: ['unknown', 'lap belt not used']\n party_safety_equipment_2 TEXT, -- example: ['lap/shoulder harness used', 'unknown']\n financial_responsibility TEXT, -- example: ['proof of insurance obtained', 'not applicable']\n hazardous_materials REAL, -- example: [1.0]\n cellphone_in_use REAL, -- example: [0.0, 1.0]\n cellphone_use_type TEXT, -- example: ['cellphone not in use', 'cellphone in use']\n school_bus_related REAL, -- example: [1.0]\n oaf_violation_code TEXT, -- example: ['vehicle', 'A']\n oaf_violation_category TEXT, -- example: ['improper turning', 'unsafe speed']\n oaf_violation_section REAL, -- example: [0.0, 22107.0]\n oaf_violation_suffix TEXT, -- example: ['0', 'A']\n other_associate_factor_1 TEXT, -- example: ['other', 'none apparent', 'violation']\n other_associate_factor_2 TEXT, -- example: ['other', 'none apparent']\n party_number_killed INTEGER, -- example: [0, 1]\n party_number_injured INTEGER, -- example: [0, 1]\n movement_preceding_collision TEXT, -- example: ['other', 'proceeding straight', 'parking maneuver']\n vehicle_year REAL, -- example: [1991.0, 1995.0]\n vehicle_make TEXT, -- example: ['ford', 'honda']\n statewide_vehicle_type TEXT, -- example: ['passenger car', 'truck or truck tractor with trailer']\n chp_vehicle_type_towing TEXT, -- example: ['passenger car, station', 'truck tractor']\n chp_vehicle_type_towed TEXT, -- example: ['00', 'semi']\n party_race TEXT, -- example: ['other', 'white', 'hispanic']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIn which year were the two most common causes of traffic accidents different from those in other years?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Could you generate a report that shows the number of delivered orders for each month in the years 2016, 2017, and 2018? Each column represents a year, and each row represents a month", "schema": "CREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['Show', 'SHOW', 'recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['show', 'SHOW', 'Show', 'Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE olist_customers (\n customer_id TEXT, -- example: ['06b8999e2fba1a1fbc88172c00ba8bc7', '18955e83d337fd6b2def6b18a428ac77']\n customer_unique_id TEXT, -- example: ['861eff4711a542e4b93843c6dd7febb0', '290c77bc529b7ac935b93aa66c333dc3']\n customer_zip_code_prefix BIGINT, -- example: [14409, 9790]\n customer_city TEXT, -- example: ['franca', 'sao bernardo do campo']\n customer_state TEXT, -- example: ['SP', 'SC']\n);\n\nCREATE TABLE olist_sellers (\n seller_id TEXT, -- example: ['3442f8959a84dea7ee197c632cb2df15', 'd1b65fc7debc3361ea86b5f14c68d2e2']\n seller_zip_code_prefix BIGINT, -- example: [13023, 13844]\n seller_city TEXT, -- example: ['campinas', 'mogi guacu']\n seller_state TEXT, -- example: ['SP', 'RJ']\n);\n\nCREATE TABLE olist_order_reviews (\n review_id TEXT, -- example: ['7bc2406110b926393aa56f80a40eba40', '80e641a11e56f04c1ad469d5645fdfde']\n order_id TEXT, -- example: ['73fc7af87114b39712e6da79b0a377eb', 'a548910a1c6147796b98fdf73dbeba33']\n review_score BIGINT, -- example: [4, 5]\n review_comment_title TEXT, -- example: ['Show', 'SHOW', 'recomendo', 'Super recomendo']\n review_comment_message TEXT, -- example: ['show', 'SHOW', 'Show', 'Recebi bem antes do prazo estipulado.', 'Parabéns lojas lannister adorei comprar ']\n review_creation_date TEXT, -- example: ['2018-01-18 00:00:00', '2018-03-10 00:00:00']\n review_answer_timestamp TEXT, -- example: ['2018-01-18 21:46:59', '2018-03-11 03:05:13']\n);\n\nCREATE TABLE olist_order_items (\n order_id TEXT, -- example: ['00010242fe8c5a6d1ba2dd792cb16214', '00018f77f2f0320c557190d7a144bdd3']\n order_item_id BIGINT, -- example: [1, 2]\n product_id TEXT, -- example: ['4244733e06e7ecb4970a6e2683c13e61', 'e5f2d52b802189ee658865ca93d83a8f']\n seller_id TEXT, -- example: ['48436dade18ac8b2bce089ec2a041202', 'dd7ddc04e1b6c2c614352b383efe2d36']\n shipping_limit_date TEXT, -- example: ['2017-09-19 09:45:35', '2017-05-03 11:05:13']\n price FLOAT, -- example: [58.9, 239.9]\n freight_value FLOAT, -- example: [13.29, 19.93]\n);\n\nCREATE TABLE olist_products (\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\n\nCREATE TABLE olist_geolocation (\n geolocation_zip_code_prefix BIGINT, -- example: [1037, 1046]\n geolocation_lat FLOAT, -- example: [-23.54562128115268, -23.54608112703553]\n geolocation_lng FLOAT, -- example: [-46.63929204800168, -46.64482029837157]\n geolocation_city TEXT, -- example: ['sao paulo', 'são paulo']\n geolocation_state TEXT, -- example: ['SP', 'RN']\n);\n\nCREATE TABLE product_category_name_translation (\n product_category_name TEXT, -- example: ['beleza_saude', 'informatica_acessorios']\n product_category_name_english TEXT, -- example: ['health_beauty', 'computers_accessories']\n);\n\nCREATE TABLE olist_orders (\n order_id TEXT, -- example: ['e481f51cbdc54678b7cc49136f2d6af7', '53cdb2fc8bc7dce0b6741e2150273451']\n customer_id TEXT, -- example: ['9ef432eb6251297304e76186b10a928d', 'b0830fb4747a6c6d20dea0b8c802d7ef']\n order_status TEXT, -- example: ['delivered', 'invoiced']\n order_purchase_timestamp TEXT, -- example: ['2017-10-02 10:56:33', '2018-07-24 20:41:37']\n order_approved_at TEXT, -- example: ['2017-10-02 11:07:15', '2018-07-26 03:24:27']\n order_delivered_carrier_date TEXT, -- example: ['2017-10-04 19:55:00', '2018-07-26 14:31:00']\n order_delivered_customer_date TEXT, -- example: ['2017-10-10 21:25:13', '2018-08-07 15:27:45']\n order_estimated_delivery_date TEXT, -- example: ['2017-10-18 00:00:00', '2018-08-13 00:00:00']\n);\n\nCREATE TABLE olist_order_payments (\n order_id TEXT, -- example: ['b81ef226f3fe1789b1e8b2acac839d17', 'a9810da82917af2d9aefd1278f1dcfa0']\n payment_sequential BIGINT, -- example: [1, 2]\n payment_type TEXT, -- example: ['credit_card', 'boleto']\n payment_installments BIGINT, -- example: [8, 1]\n payment_value FLOAT, -- example: [99.33, 24.39]\n);\n\nCREATE TABLE olist_products_dataset (\n `index` BIGINT, -- example: [0, 1]\n product_id TEXT, -- example: ['1e9e8ef04dbcff4541ed26657ea517e5', '3aa071139cb16b67ca9e5dea641aaa2f']\n product_category_name TEXT, -- example: ['perfumaria', 'artes']\n product_name_lenght FLOAT, -- example: [40.0, 44.0]\n product_description_lenght FLOAT, -- example: [287.0, 276.0]\n product_photos_qty FLOAT, -- example: [1.0, 4.0]\n product_weight_g FLOAT, -- example: [225.0, 1000.0]\n product_length_cm FLOAT, -- example: [16.0, 30.0]\n product_height_cm FLOAT, -- example: [10.0, 18.0]\n product_width_cm FLOAT, -- example: [14.0, 20.0]\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCould you generate a report that shows the number of delivered orders for each month in the years 2016, 2017, and 2018? Each column represents a year, and each row represents a month\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "Distribute all the unique city pairs into the distance ranges 0, 1000, 2000, 3000, 4000, 5000, and 6000+, based on their average distance of all routes between them. Then how many pairs are there in the distance range with the fewest unique city paires?", "schema": "CREATE TABLE aircrafts_data (\n aircraft_code character(3), -- example: ['773', '763']\n model jsonb, -- example: ['{\"en\": \"Boeing 777-300\", \"ru\": \"Боинг 77', '{\"en\": \"Boeing 767-300\", \"ru\": \"Боинг 76']\n `range` integer, -- example: [11100, 7900]\n);\n\nCREATE TABLE airports_data (\n airport_code character(3), -- example: ['YKS', 'MJZ']\n airport_name jsonb, -- example: ['{\"en\": \"Yakutsk Airport\", \"ru\": \"Якутск\"', '{\"en\": \"Mirny Airport\", \"ru\": \"Мирный\"}']\n city jsonb, -- example: ['{\"en\": \"Yakutsk\", \"ru\": \"Якутск\"}', '{\"en\": \"Mirnyj\", \"ru\": \"Мирный\"}']\n coordinates point, -- example: ['(129.77099609375,62.0932998657226562)', '(114.03900146484375,62.534698486328125)']\n timezone text, -- example: ['Asia/Yakutsk', 'Asia/Vladivostok']\n);\n\nCREATE TABLE boarding_passes (\n ticket_no character(13), -- example: ['0005435212351', '0005435212386']\n flight_id integer, -- example: [30625, 24836]\n boarding_no integer, -- example: [1, 2]\n seat_no character varying(4), -- example: ['2D', '3G']\n);\n\nCREATE TABLE bookings (\n book_ref character(6), -- example: ['00000F', '000012']\n book_date timestamp with time zone, -- example: ['2017-07-05 03:12:00+03', '2017-07-14 09:02:00+03']\n total_amount numeric(10,2), -- example: [265700, 37900]\n);\n\nCREATE TABLE flights (\n flight_id integer, -- example: [1185, 3979]\n flight_no character(6), -- example: ['PG0134', 'PG0052']\n scheduled_departure timestamp with time zone, -- example: ['2017-09-10 09:50:00+03', '2017-08-25 14:50:00+03']\n scheduled_arrival timestamp with time zone, -- example: ['2017-09-10 14:55:00+03', '2017-08-25 17:35:00+03']\n departure_airport character(3), -- example: ['DME', 'VKO']\n arrival_airport character(3), -- example: ['BTK', 'HMA']\n status character varying(20), -- example: ['Scheduled', 'Cancelled']\n aircraft_code character(3), -- example: ['319', 'CR2']\n actual_departure timestamp with time zone, -- example: ['\\\\N', '2017-07-16 09:44:00+03']\n actual_arrival timestamp with time zone, -- example: ['\\\\N', '2017-07-16 10:39:00+03']\n);\n\nCREATE TABLE seats (\n aircraft_code character(3), -- example: ['319', '320']\n seat_no character varying(4), -- example: ['2A', '2C']\n fare_conditions character varying(10), -- example: ['Business', 'Economy']\n);\n\nCREATE TABLE ticket_flights (\n ticket_no character(13), -- example: ['0005432159776', '0005435212351']\n flight_id integer, -- example: [30625, 24836]\n fare_conditions character varying(10), -- example: ['Business', 'Comfort']\n amount numeric(10,2), -- example: [42100, 23900]\n);\n\nCREATE TABLE tickets (\n ticket_no character(13), -- example: ['0005432000987', '0005432000988']\n book_ref character(6), -- example: ['06B046', 'E170C3']\n passenger_id character varying(20), -- example: ['8149 604011', '8499 420203']\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE aircrafts_data (\n aircraft_code character(3), -- example: ['773', '763']\n model jsonb, -- example: ['{\"en\": \"Boeing 777-300\", \"ru\": \"Боинг 77', '{\"en\": \"Boeing 767-300\", \"ru\": \"Боинг 76']\n `range` integer, -- example: [11100, 7900]\n);\n\nCREATE TABLE airports_data (\n airport_code character(3), -- example: ['YKS', 'MJZ']\n airport_name jsonb, -- example: ['{\"en\": \"Yakutsk Airport\", \"ru\": \"Якутск\"', '{\"en\": \"Mirny Airport\", \"ru\": \"Мирный\"}']\n city jsonb, -- example: ['{\"en\": \"Yakutsk\", \"ru\": \"Якутск\"}', '{\"en\": \"Mirnyj\", \"ru\": \"Мирный\"}']\n coordinates point, -- example: ['(129.77099609375,62.0932998657226562)', '(114.03900146484375,62.534698486328125)']\n timezone text, -- example: ['Asia/Yakutsk', 'Asia/Vladivostok']\n);\n\nCREATE TABLE boarding_passes (\n ticket_no character(13), -- example: ['0005435212351', '0005435212386']\n flight_id integer, -- example: [30625, 24836]\n boarding_no integer, -- example: [1, 2]\n seat_no character varying(4), -- example: ['2D', '3G']\n);\n\nCREATE TABLE bookings (\n book_ref character(6), -- example: ['00000F', '000012']\n book_date timestamp with time zone, -- example: ['2017-07-05 03:12:00+03', '2017-07-14 09:02:00+03']\n total_amount numeric(10,2), -- example: [265700, 37900]\n);\n\nCREATE TABLE flights (\n flight_id integer, -- example: [1185, 3979]\n flight_no character(6), -- example: ['PG0134', 'PG0052']\n scheduled_departure timestamp with time zone, -- example: ['2017-09-10 09:50:00+03', '2017-08-25 14:50:00+03']\n scheduled_arrival timestamp with time zone, -- example: ['2017-09-10 14:55:00+03', '2017-08-25 17:35:00+03']\n departure_airport character(3), -- example: ['DME', 'VKO']\n arrival_airport character(3), -- example: ['BTK', 'HMA']\n status character varying(20), -- example: ['Scheduled', 'Cancelled']\n aircraft_code character(3), -- example: ['319', 'CR2']\n actual_departure timestamp with time zone, -- example: ['\\\\N', '2017-07-16 09:44:00+03']\n actual_arrival timestamp with time zone, -- example: ['\\\\N', '2017-07-16 10:39:00+03']\n);\n\nCREATE TABLE seats (\n aircraft_code character(3), -- example: ['319', '320']\n seat_no character varying(4), -- example: ['2A', '2C']\n fare_conditions character varying(10), -- example: ['Business', 'Economy']\n);\n\nCREATE TABLE ticket_flights (\n ticket_no character(13), -- example: ['0005432159776', '0005435212351']\n flight_id integer, -- example: [30625, 24836]\n fare_conditions character varying(10), -- example: ['Business', 'Comfort']\n amount numeric(10,2), -- example: [42100, 23900]\n);\n\nCREATE TABLE tickets (\n ticket_no character(13), -- example: ['0005432000987', '0005432000988']\n book_ref character(6), -- example: ['06B046', 'E170C3']\n passenger_id character varying(20), -- example: ['8149 604011', '8499 420203']\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n# Flight Route Distance Calculation\n\n## Introduction\n\nThis document describes the method used to calculate the distance between two cities for flight routes. The calculation is based on the Haversine formula, which is commonly used to find the shortest distance between two points on a sphere given their latitude and longitude. This method is especially useful for determining flight distances between airports located in different cities around the world.\n\n## City and Coordinate Extraction\n\nFor each flight, the following data is obtained:\n\n- **Departure city** (referred to as `from_city`) and its geographical coordinates (longitude and latitude).\n- **Arrival city** (referred to as `to_city`) and its geographical coordinates (longitude and latitude).\n\nThe coordinates are extracted as decimal values, with longitude and latitude represented in degrees. This ensures that trigonometric operations can be applied during the distance calculation.\n\n## Haversine Formula\n\nThe Haversine formula is used to calculate the great-circle distance between two points on a sphere using their latitude and longitude. The formula is given as:\n\n\\[\nd = 2r \\cdot \\arcsin\\left(\\sqrt{\\sin^2\\left(\\frac{\\Delta \\phi}{2}\\right) + \\cos(\\phi_1) \\cdot \\cos(\\phi_2) \\cdot \\sin^2\\left(\\frac{\\Delta \\lambda}{2}\\right)}\\right)\n\\]\n\nWhere:\n\n- \\( d \\) is the distance between the two points (in kilometers).\n- \\( r \\) is the radius of the Earth (approximately 6371 km).\n- \\( \\phi_1 \\) and \\( \\phi_2 \\) are the latitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\phi = \\phi_2 - \\phi_1 \\) is the difference in latitudes.\n- \\( \\lambda_1 \\) and \\( \\lambda_2 \\) are the longitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\lambda = \\lambda_2 - \\lambda_1 \\) is the difference in longitudes.\n\n### Conversion to Radians\n\nSince the input coordinates are in degrees, they must be converted to radians before applying the Haversine formula. This conversion is done using the formula:\n\n\\[\n\\text{radians} = \\text{degrees} \\times \\frac{\\pi}{180}\n\\]\n\n## Symmetry of Routes\n\nTo identify unique flight routes between two cities, we standardize the order of cities in each route. Specifically, we ensure that the lexicographically smaller city name is always listed as the first city (`city1`), and the larger city is listed as the second city (`city2`). This ensures that a flight from City A to City B is treated the same as a flight from City B to City A.\n\n## Average Route Distance\n\nOnce the distances for all flights between two cities are computed, the average distance for each city pair is calculated by summing the distances and dividing by the total number of flights between those cities:\n\n\\[\n\\text{Average Distance} = \\frac{\\sum \\text{Flight Distances}}{\\text{Number of Flights}}\n\\]\n\n## Conclusion\n\nThis method of flight route distance calculation provides a reliable way to determine the great-circle distance between cities based on the coordinates of their respective airports. The use of the Haversine formula ensures accurate results for distances on the Earth's surface, making it ideal for aviation and travel analysis.\nDistribute all the unique city pairs into the distance ranges 0, 1000, 2000, 3000, 4000, 5000, and 6000+, based on their average distance of all routes between them. Then how many pairs are there in the distance range with the fewest unique city paires?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "# Flight Route Distance Calculation\n\n## Introduction\n\nThis document describes the method used to calculate the distance between two cities for flight routes. The calculation is based on the Haversine formula, which is commonly used to find the shortest distance between two points on a sphere given their latitude and longitude. This method is especially useful for determining flight distances between airports located in different cities around the world.\n\n## City and Coordinate Extraction\n\nFor each flight, the following data is obtained:\n\n- **Departure city** (referred to as `from_city`) and its geographical coordinates (longitude and latitude).\n- **Arrival city** (referred to as `to_city`) and its geographical coordinates (longitude and latitude).\n\nThe coordinates are extracted as decimal values, with longitude and latitude represented in degrees. This ensures that trigonometric operations can be applied during the distance calculation.\n\n## Haversine Formula\n\nThe Haversine formula is used to calculate the great-circle distance between two points on a sphere using their latitude and longitude. The formula is given as:\n\n\\[\nd = 2r \\cdot \\arcsin\\left(\\sqrt{\\sin^2\\left(\\frac{\\Delta \\phi}{2}\\right) + \\cos(\\phi_1) \\cdot \\cos(\\phi_2) \\cdot \\sin^2\\left(\\frac{\\Delta \\lambda}{2}\\right)}\\right)\n\\]\n\nWhere:\n\n- \\( d \\) is the distance between the two points (in kilometers).\n- \\( r \\) is the radius of the Earth (approximately 6371 km).\n- \\( \\phi_1 \\) and \\( \\phi_2 \\) are the latitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\phi = \\phi_2 - \\phi_1 \\) is the difference in latitudes.\n- \\( \\lambda_1 \\) and \\( \\lambda_2 \\) are the longitudes of the departure and arrival points, respectively, in radians.\n- \\( \\Delta \\lambda = \\lambda_2 - \\lambda_1 \\) is the difference in longitudes.\n\n### Conversion to Radians\n\nSince the input coordinates are in degrees, they must be converted to radians before applying the Haversine formula. This conversion is done using the formula:\n\n\\[\n\\text{radians} = \\text{degrees} \\times \\frac{\\pi}{180}\n\\]\n\n## Symmetry of Routes\n\nTo identify unique flight routes between two cities, we standardize the order of cities in each route. Specifically, we ensure that the lexicographically smaller city name is always listed as the first city (`city1`), and the larger city is listed as the second city (`city2`). This ensures that a flight from City A to City B is treated the same as a flight from City B to City A.\n\n## Average Route Distance\n\nOnce the distances for all flights between two cities are computed, the average distance for each city pair is calculated by summing the distances and dividing by the total number of flights between those cities:\n\n\\[\n\\text{Average Distance} = \\frac{\\sum \\text{Flight Distances}}{\\text{Number of Flights}}\n\\]\n\n## Conclusion\n\nThis method of flight route distance calculation provides a reliable way to determine the great-circle distance between cities based on the coordinates of their respective airports. The use of the Haversine formula ensures accurate results for distances on the Earth's surface, making it ideal for aviation and travel analysis." }, { "question": "Please help me find the top 3 bowlers who conceded the maximum runs in a single over, along with the corresponding matches.", "schema": "CREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);", "input_seq": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE player (\n player_id INTEGER, -- example: [1, 2]\n player_name TEXT, -- example: ['SC Ganguly', 'BB McCullum']\n dob DATE, -- example: ['1972-07-08', '1981-09-27']\n batting_hand TEXT, -- example: ['Left-hand bat', 'Right-hand bat']\n bowling_skill TEXT, -- example: ['Right-arm medium', 'Right-arm offbreak']\n country_name TEXT, -- example: ['India', 'New Zealand']\n PRIMARY KEY (player_id)\n);\n\nCREATE TABLE team (\n team_id INTEGER, -- example: [2, 3]\n name TEXT, -- example: ['Royal Challengers Bangalore', 'Chennai Super Kings']\n PRIMARY KEY (team_id)\n);\n\nCREATE TABLE `match` (\n match_id INTEGER, -- example: [335987, 335988]\n team_1 INTEGER, -- example: [2, 4]\n team_2 INTEGER, -- example: [1, 3]\n match_date DATE, -- example: ['2008-04-18', '2008-04-19']\n season_id INTEGER, -- example: [1, 2]\n venue TEXT, -- example: ['M Chinnaswamy Stadium', 'Punjab Cricket Association Stadium Mohal']\n toss_winner INTEGER, -- example: [2, 3]\n toss_decision TEXT, -- example: ['field', 'bat']\n win_type TEXT, -- example: ['runs', 'wickets']\n win_margin INTEGER, -- example: [140, 33]\n outcome_type TEXT, -- example: ['Result']\n match_winner INTEGER, -- example: [1, 3]\n man_of_the_match INTEGER, -- example: [2, 19]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE player_match (\n match_id INTEGER, -- example: [335987, 335988]\n player_id INTEGER, -- example: [1, 2]\n `role` TEXT, -- example: ['Captain', 'Keeper']\n team_id INTEGER, -- example: [7, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE ball_by_ball (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n innings_no INTEGER, -- example: [2, 1]\n team_batting INTEGER, -- example: [2, 1]\n team_bowling INTEGER, -- example: [1, 2]\n striker_batting_position INTEGER, -- example: [1, 2]\n striker INTEGER, -- example: [6, 2]\n non_striker INTEGER, -- example: [7, 1]\n bowler INTEGER, -- example: [106, 14]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE batsman_scored (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n runs_scored INTEGER, -- example: [1, 0]\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE wicket_taken (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [2, 3]\n ball_id INTEGER, -- example: [1, 2]\n player_out INTEGER, -- example: [154, 46]\n kind_out TEXT, -- example: ['caught', 'bowled']\n innings_no INTEGER, -- example: [2, 1]\n PRIMARY KEY (match_id)\n);\n\nCREATE TABLE extra_runs (\n match_id INTEGER, -- example: [335987, 335988]\n over_id INTEGER, -- example: [1, 2]\n ball_id INTEGER, -- example: [1, 2]\n extra_type TEXT, -- example: ['legbyes', 'wides']\n extra_runs INTEGER, -- example: [1, 4]\n innings_no INTEGER, -- example: [1, 2]\n PRIMARY KEY (match_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease help me find the top 3 bowlers who conceded the maximum runs in a single over, along with the corresponding matches.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "output_seq": "", "external_knowledge": "None" }, { "question": "For the NXT title that had the shortest match (excluding titles with \"title change\"), what were the names of the two wrestlers involved?", "schema": "CREATE TABLE Promotions (\n id INTEGER, -- example: [1, 230]\n name TEXT, -- example: ['NXT', 'ECW']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE sqlite_sequence (\n name TEXT, -- example: ['Tables', 'Events']\n seq TEXT, -- example: [14431, 540800]\n);\n\nCREATE TABLE Tables (\n id INTEGER, -- example: [1, 11]\n html TEXT, -- example: ['\\n']\n url TEXT, -- example: ['http://www.profightdb.com/cards/nxt-card']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Cards (\n id INTEGER, -- example: [1, 2]\n table_id INTEGER, -- example: [1, 11]\n location_id INTEGER, -- example: [1, 24]\n promotion_id INTEGER, -- example: [1, 230]\n event_date TEXT, -- example: ['1979-03-26', '1979-02-19']\n event_id INTEGER, -- example: [1, 2]\n url TEXT, -- example: ['http://www.profightdb.com/cards/nxt/aber', 'http://www.profightdb.com/cards/nxt/alba']\n info_html TEXT, -- example: ['
\\n \\n ']\n match_html TEXT, -- example: ['
\\n']\n url TEXT, -- example: ['http://www.profightdb.com/cards/nxt-card']\n PRIMARY KEY (id)\n);\n\nCREATE TABLE Cards (\n id INTEGER, -- example: [1, 2]\n table_id INTEGER, -- example: [1, 11]\n location_id INTEGER, -- example: [1, 24]\n promotion_id INTEGER, -- example: [1, 230]\n event_date TEXT, -- example: ['1979-03-26', '1979-02-19']\n event_id INTEGER, -- example: [1, 2]\n url TEXT, -- example: ['http://www.profightdb.com/cards/nxt/aber', 'http://www.profightdb.com/cards/nxt/alba']\n info_html TEXT, -- example: ['
\\n \\n ']\n match_html TEXT, -- example: ['