data_source
stringclasses
1 value
prompt
listlengths
2
2
ability
stringclasses
1 value
reward_model
dict
extra_info
dict
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-card', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabels refers to label_id;\nHow many labels belong to the game-card 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(label_id) FROM label_categories WHERE category = 'game-card'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(label_id) FROM label_categories WHERE category = 'game-card'", "index": 600, "question": "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 app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-card', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabels refers to label_id;\nHow many labels belong to the game-card 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['vivo', '小米']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage group refers to group;\nWhat is the age group of users who use phone brand of vivo?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo'", "index": 601, "question": "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 app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['vivo', '小米']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage group refers to group;\nWhat is the age group of users who use phone brand of vivo?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['OPPO', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOPPO refers to phone_brand = 'OPPO'; percentage = MULTIPLY(DIVIDE(SUM(age < 50), COUNT(device_id)), 1.0); under 50 years old refers to age < 50;\nAmong the users who use OPPO, calculate the percentage of those who are under 50 years old.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(IIF(T1.age < 50, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'OPPO'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.age < 50, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'OPPO'", "index": 602, "question": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['OPPO', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOPPO refers to phone_brand = 'OPPO'; percentage = MULTIPLY(DIVIDE(SUM(age < 50), COUNT(device_id)), 1.0); under 50 years old refers to age < 50;\nAmong the users who use OPPO, calculate the percentage of those who are under 50 years old.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['R7', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age);\nWhat is the average age of the users who use model device of R7?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(T1.age) / COUNT(T1.device_id) AS avg FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'R7'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(T1.age) / COUNT(T1.device_id) AS avg FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'R7'", "index": 603, "question": "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['R7', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age);\nWhat is the average age of the users who use model device of R7?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabel that represented the behavior category refers to label_id;\nWhat is the category of the label that represented the behavior category of app id 5902120154267990000?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000", "index": 604, "question": "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 gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabel that represented the behavior category refers to label_id;\nWhat is the category of the label that represented the behavior category of app id 5902120154267990000?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['LG', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngroup of age refers to group;\nMention the group of age of users who use phone brand of LG.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'LG'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'LG'", "index": 605, "question": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['LG', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngroup of age refers to group;\nMention the group of age of users who use phone brand of LG.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M29-31` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabel that represented the behavior category refers to label_id;\nState the category of the label that represented the behavior category of app id 4955831798976240000.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 4955831798976240000", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 4955831798976240000", "index": 606, "question": "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M29-31` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabel that represented the behavior category refers to label_id;\nState the category of the label that represented the behavior category of app id 4955831798976240000.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['MI 3', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale refers to gender = 'F';\nHow many female users use device model of MI 3?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T2.device_model = 'MI 3'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T2.device_model = 'MI 3'", "index": 607, "question": "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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['MI 3', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale refers to gender = 'F';\nHow many female users use device model of MI 3?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['ELIFE E7 Mini', 'E7', 'Z7 Mini', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nabove 20 refers to age > 20;\nAmong the users who are above 20, how many users use device model of ELIFE E7 Mini?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'ELIFE E7 Mini' AND T1.age > 20", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'ELIFE E7 Mini' AND T1.age > 20", "index": 608, "question": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['ELIFE E7 Mini', 'E7', 'Z7 Mini', '红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nabove 20 refers to age > 20;\nAmong the users who are above 20, how many users use device model of ELIFE E7 Mini?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['HTC', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to gender = 'M';\nGive the number of male users who use phone branded HTC.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'M' AND T2.phone_brand = 'HTC'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'M' AND T2.phone_brand = 'HTC'", "index": 609, "question": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['HTC', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to gender = 'M';\nGive the number of male users who use phone branded HTC.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabeled 7 refers to label_id = 7;\nHow many apps are labeled 7?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(app_id) FROM app_labels WHERE label_id = 7", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(app_id) FROM app_labels WHERE label_id = 7", "index": 610, "question": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlabeled 7 refers to label_id = 7;\nHow many apps are labeled 7?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nid refers to device_id; women refers to gender = 'F'; age range of 29 to 31 years refers to age between 29 and 31;\nIdentify by their id all the devices that are used by women who are in the age range of 29 to 31 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT device_id FROM gender_age_train WHERE age BETWEEN 29 AND 31 AND gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT device_id FROM gender_age_train WHERE age BETWEEN 29 AND 31 AND gender = 'F'", "index": 611, "question": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nid refers to device_id; women refers to gender = 'F'; age range of 29 to 31 years refers to age between 29 and 31;\nIdentify by their id all the devices that are used by women who are in the age range of 29 to 31 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:00:06.0', '2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngender that logged in the most refers to MAX(COUNT(gender)); first 10 days of May 2016 refers to timestamp BETWEEN '2016-05-01 00:00:00' AND '2016-05-10 23:59:59';\nWhich gender logged in the most to an event in the first 10 days of May 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T.gender FROM ( SELECT T1.gender, COUNT(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE date(T2.timestamp) BETWEEN '2016-05-01' AND '2016-05-10' GROUP BY T1.gender ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.gender FROM ( SELECT T1.gender, COUNT(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE date(T2.timestamp) BETWEEN '2016-05-01' AND '2016-05-10' GROUP BY T1.gender ) AS T ORDER BY T.num DESC LIMIT 1", "index": 612, "question": "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 gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:00:06.0', '2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngender that logged in the most refers to MAX(COUNT(gender)); first 10 days of May 2016 refers to timestamp BETWEEN '2016-05-01 00:00:00' AND '2016-05-10 23:59:59';\nWhich gender logged in the most to an event in the first 10 days of May 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(gender = 'F'), SUM(gender = 'M')), 1.0); women refers to gender = 'F'; not installed refers to is_installed = 0; men refers to gender = 'M';\nWhat percentage of women do not have applications installed on their mobile with respect to men?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(IIF(T1.gender = 'F', 1, 0)) / SUM(IIF(T1.gender = 'M', 1, 0)) AS per FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T3.is_installed = 0", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.gender = 'F', 1, 0)) / SUM(IIF(T1.gender = 'M', 1, 0)) AS per FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T3.is_installed = 0", "index": 613, "question": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(gender = 'F'), SUM(gender = 'M')), 1.0); women refers to gender = 'F'; not installed refers to is_installed = 0; men refers to gender = 'M';\nWhat percentage of women do not have applications installed on their mobile with respect to men?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non the 1st of May 2016 refers to timestamp like '2016-05-01%';\nPlease list any three events that happened on the 1st of May 2016 that have the same latitude of 31.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT event_id FROM events WHERE timestamp LIKE '2016-05-01%' AND latitude = 31 LIMIT 3", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT event_id FROM events WHERE timestamp LIKE '2016-05-01%' AND latitude = 31 LIMIT 3", "index": 614, "question": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non the 1st of May 2016 refers to timestamp like '2016-05-01%';\nPlease list any three events that happened on the 1st of May 2016 that have the same latitude of 31.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(is_installed = 1 and is_active = 0), COUNT(app_id)), 1.0); event number refers to event_id = 6; installed refers to is_installed = 1; do not use refers to is_active = 0;\nWhat is the percentage of users who experienced event number 6 who have the app installed but do not use the app?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(IIF(is_installed = 1 AND is_active = 0, 1, 0)) / COUNT(app_id) AS perrcent FROM app_events WHERE event_id = 6", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(is_installed = 1 AND is_active = 0, 1, 0)) / COUNT(app_id) AS perrcent FROM app_events WHERE event_id = 6", "index": 615, "question": "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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(is_installed = 1 and is_active = 0), COUNT(app_id)), 1.0); event number refers to event_id = 6; installed refers to is_installed = 1; do not use refers to is_active = 0;\nWhat is the percentage of users who experienced event number 6 who have the app installed but do not use the app?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Note 2', 'Galaxy Note', 'Galaxy Note 4', 'Galaxy Note 3', 'Galaxy Note 5', 'Galaxy S']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngender that owned more = SUBTRACT(IF(SUM(gender = 'M'), SUM(gender = 'F'),'M','F'));\nWhich gender owned more of the Galaxy Note 2 device model?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT IIF(SUM(IIF(T1.gender = 'M', 1, 0)) - SUM(IIF(T1.gender = 'F', 1, 0)) > 0, 'M', 'F') AS gender FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 2'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT IIF(SUM(IIF(T1.gender = 'M', 1, 0)) - SUM(IIF(T1.gender = 'F', 1, 0)) > 0, 'M', 'F') AS gender FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 2'", "index": 616, "question": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Note 2', 'Galaxy Note', 'Galaxy Note 4', 'Galaxy Note 3', 'Galaxy Note 5', 'Galaxy S']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngender that owned more = SUBTRACT(IF(SUM(gender = 'M'), SUM(gender = 'F'),'M','F'));\nWhich gender owned more of the Galaxy Note 2 device model?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nevent number refers to event_id; event_id = 2; active refers to is_active = 1;\nWhen did event number 2 happen and how many users were active?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.app_id) AS num FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE T1.event_id = 2 AND T1.is_active = 1 GROUP BY T2.timestamp", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.app_id) AS num FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE T1.event_id = 2 AND T1.is_active = 1 GROUP BY T2.timestamp", "index": 617, "question": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nevent number refers to event_id; event_id = 2; active refers to is_active = 1;\nWhen did event number 2 happen and how many users were active?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior category refers to category; number refers to app_id; app_id = 5902120154267990000;\nWhich behavior category does user number 5902120154267990000 belong to?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000", "index": 618, "question": "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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior category refers to category; number refers to app_id; app_id = 5902120154267990000;\nWhich behavior category does user number 5902120154267990000 belong to?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['comics', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior category refers to category; category = 'comics';\nHow many users belong to the same behavior category as comics?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'comics'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'comics'", "index": 619, "question": "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 app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['comics', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior category refers to category; category = 'comics';\nHow many users belong to the same behavior category as comics?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nevent number refers to event_id; event_id = 7; user number refers to app_id; app_id = -8022267440849930000;\nWhen did event number 7 happen for user number -8022267440849930000?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.timestamp FROM events_relevant AS T1 INNER JOIN app_events AS T2 ON T1.event_id = T2.event_id WHERE T2.app_id = -8022267440849930000 AND T1.event_id = 7", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.timestamp FROM events_relevant AS T1 INNER JOIN app_events AS T2 ON T1.event_id = T2.event_id WHERE T2.app_id = -8022267440849930000 AND T1.event_id = 7", "index": 620, "question": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nevent number refers to event_id; event_id = 7; user number refers to app_id; app_id = -8022267440849930000;\nWhen did event number 7 happen for user number -8022267440849930000?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior categories refers to category; user number refers to app_id; app_id = -9222198347540750000;\nWhat are the behavior categories that user number -9222198347540750000 belongs to?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.category FROM app_all AS T1 INNER JOIN app_labels AS T2 ON T1.app_id = T2.app_id INNER JOIN label_categories AS T3 ON T2.label_id = T3.label_id WHERE T1.app_id = -9222198347540750000", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T3.category FROM app_all AS T1 INNER JOIN app_labels AS T2 ON T1.app_id = T2.app_id INNER JOIN label_categories AS T3 ON T2.label_id = T3.label_id WHERE T1.app_id = -9222198347540750000", "index": 621, "question": "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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbehavior categories refers to category; user number refers to app_id; app_id = -9222198347540750000;\nWhat are the behavior categories that user number -9222198347540750000 belongs to?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Academic Information', 'Information', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F33-42` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(category = 'Academic Information'), COUNT(app_id)), 1.0); behavior category refers to category; category = 'Academic Information';\nWhat is the percentage of users who are in the same behavior category as \"Academic Information\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(IIF(T1.category = 'Academic Information', 1.0, 0)) / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.category = 'Academic Information', 1.0, 0)) / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id", "index": 622, "question": "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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Academic Information', 'Information', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F33-42` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(category = 'Academic Information'), COUNT(app_id)), 1.0); behavior category refers to category; category = 'Academic Information';\nWhat is the percentage of users who are in the same behavior category as \"Academic Information\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['OPPO', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOPPO devices refers to phone_brand = 'OPPO';\nHow many OPPO devices are 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO'", "index": 623, "question": "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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['OPPO', '小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOPPO devices refers to phone_brand = 'OPPO';\nHow many OPPO devices are 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost common age group refers to MAX(COUNT(`group`));\nWhat is the most common age group among all device users?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T.num FROM ( SELECT `group`, COUNT(`group`) AS num FROM gender_age GROUP BY `group` ) T", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.num FROM ( SELECT `group`, COUNT(`group`) AS num FROM gender_age GROUP BY `group` ) T", "index": 624, "question": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost common age group refers to MAX(COUNT(`group`));\nWhat is the most common age group among all device users?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Note 3', 'Galaxy Note', 'Galaxy Note 4', 'Galaxy Note 2', 'Galaxy Note 5', 'Galaxy S']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to gender = 'M'; Galaxy Note 3 refers to device_model = 'Galaxy Note 3';\nHow many male users have a Galaxy Note 3?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 3' AND T1.gender = 'M'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 3' AND T1.gender = 'M'", "index": 625, "question": "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 events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Note 3', 'Galaxy Note', 'Galaxy Note 4', 'Galaxy Note 2', 'Galaxy Note 5', 'Galaxy S']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to gender = 'M'; Galaxy Note 3 refers to device_model = 'Galaxy Note 3';\nHow many male users have a Galaxy Note 3?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndevices' brands refers to phone_brand; models refers to device_model; on 5/7/2016 at 6:03:22 AM refers to timestamp = '2016-05-07 06:03:22';\nList all the devices' brands and models of events on 5/7/2016 at 6:03:22 AM.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-07 06:03:22'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-07 06:03:22'", "index": 626, "question": "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n longitude real, -- example: [1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n longitude real, -- example: [121.0, 104.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndevices' brands refers to phone_brand; models refers to device_model; on 5/7/2016 at 6:03:22 AM refers to timestamp = '2016-05-07 06:03:22';\nList all the devices' brands and models of events on 5/7/2016 at 6:03:22 AM.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbrand refers to phone_brand; brand that is most common refers to MAX(COUNT(phone_brand)); twenties refers to age BETWEEN 20 AND 30;\nWhich brand is most common among people in their twenties?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T.phone_brand FROM ( SELECT T2.phone_brand, COUNT(T2.phone_brand) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.age BETWEEN 20 AND 30 GROUP BY T2.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.phone_brand FROM ( SELECT T2.phone_brand, COUNT(T2.phone_brand) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.age BETWEEN 20 AND 30 GROUP BY T2.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1", "index": 627, "question": "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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.0']\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n longitude real, -- example: [1.0]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbrand refers to phone_brand; brand that is most common refers to MAX(COUNT(phone_brand)); twenties refers to age BETWEEN 20 AND 30;\nWhich brand is most common among people in their twenties?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Information', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['vivo', '小米']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(gender = NULL and age = NULL and `group` = NULL), COUNT(device_id)), 1.0); vivo devices refers to phone_brand = 'vivo'; no information refers to gender = NULL AND age = NULL AND `group` = NULL;\nWhat percentage of vivo devices belong to users with no information?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(IIF(T1.gender IS NULL AND T1.age IS NULL AND T1.`group` IS NULL, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.gender IS NULL AND T1.age IS NULL AND T1.`group` IS NULL, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo'", "index": 628, "question": "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 app_labels (\n app_id integer, -- example: [7324884708820027918, -4494216993218550286]\n label_id integer, -- example: [251, 406]\n CONSTRAINT fk_app_labels_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id),\n CONSTRAINT fk_app_labels_label_id FOREIGN KEY (label_id) REFERENCES label_categories (label_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE app_events_relevant (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_relevant_event_id FOREIGN KEY (event_id) REFERENCES events_relevant (event_id),\n CONSTRAINT fk_app_events_relevant_app_id FOREIGN KEY (app_id) REFERENCES app_all (app_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Information', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\n);\n\nCREATE TABLE events_relevant (\n event_id integer, -- example: [2, 6]\n device_id integer,\n `timestamp` datetime, -- example: [-8942695423876075857, -8764672938472212518]\n latitude real, -- example: [0.0, 1.0]\n PRIMARY KEY (event_id),\n CONSTRAINT fk_events_relevant_device_id FOREIGN KEY (device_id) REFERENCES gender_age (device_id)\n);\n\nCREATE TABLE app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_id)\n);\n\nCREATE TABLE gender_age_test (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M29-31', 'M32-38']\n PRIMARY KEY (device_id),\n CONSTRAINT fk_gender_age_device_id FOREIGN KEY (device_id) REFERENCES phone_brand_device_model2 (device_id)\n);\n\nCREATE TABLE app_events (\n event_id integer, -- example: [2, 6]\n app_id integer, -- example: [-8942695423876075857, -8022267440849930066]\n is_installed integer, -- example: [1]\n is_active integer, -- example: [0, 1]\n PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (event_id)\n);\n\nCREATE TABLE events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.0]\n latitude real, -- example: [31.0, 30.0]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M23-26` real, -- example: [0.0833]\n `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['vivo', '小米']\n device_model text, -- example: ['红米note', 'Y19T']\n PRIMARY KEY (device_id, phone_brand, device_model)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(gender = NULL and age = NULL and `group` = NULL), COUNT(device_id)), 1.0); vivo devices refers to phone_brand = 'vivo'; no information refers to gender = NULL AND age = NULL AND `group` = NULL;\nWhat percentage of vivo devices belong to users with no information?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['laundering money', 'nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nkeyword \"laundering money\" refers to keyword = 'laundering money'\nWhat is the title of the episode with the keyword \"laundering money\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword = 'laundering money'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword = 'laundering money'", "index": 629, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['laundering money', 'nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nkeyword \"laundering money\" refers to keyword = 'laundering money'\nWhat is the title of the episode with the keyword \"laundering money\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\na rating of over 8 refers to rating > 8\nPlease list all the keywords for the episodes with a rating of over 8.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.rating > 8", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.rating > 8", "index": 630, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\na rating of over 8 refers to rating > 8\nPlease list all the keywords for the episodes with a rating of over 8.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n10-star vote refers to stars = 10; titled \"Cherished\" refers to title = 'Cherished'\nHow many 10-star votes were given to the episode titled \"Cherished\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.stars = 10", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.stars = 10", "index": 631, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n10-star vote refers to stars = 10; titled \"Cherished\" refers to title = 'Cherished'\nHow many 10-star votes were given to the episode titled \"Cherished\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntitled \"Cherished\" refers to title = 'Cherished'\nHow many votes did the episode titled \"Cherished\" get 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished'", "index": 632, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntitled \"Cherished\" refers to title = 'Cherished'\nHow many votes did the episode titled \"Cherished\" get 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most refers to max(votes); 10-star refers to stars = 10\nWhat is the title of the episode that got the most 10-star votes?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 ORDER BY T2.votes DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 ORDER BY T2.votes DESC LIMIT 1", "index": 633, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most refers to max(votes); 10-star refers to stars = 10\nWhat is the title of the episode that got the most 10-star votes?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Park Dietz', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredited refers to credited = 'true'; titled \"Cherished\" refers to title = 'Cherished'\nPark Dietz was credited in which role in the episode titled \"Cherished\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.role FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T3.name = 'Park Dietz' AND T2.credited = 'true'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.role FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T3.name = 'Park Dietz' AND T2.credited = 'true'", "index": 634, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Park Dietz', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredited refers to credited = 'true'; titled \"Cherished\" refers to title = 'Cherished'\nPark Dietz was credited in which role in the episode titled \"Cherished\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_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 refers to name; credited refers to credited = 'true'; as \"technical advisor\" refers to role = 'technical advisor'; titled \"Cherished\" refers to title = 'Cherished'\nWho was credited as \"technical advisor\" in the episode titled \"Cherished\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T2.credited = 'true' AND T2.role = 'technical advisor'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T2.credited = 'true' AND T2.role = 'technical advisor'", "index": 635, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_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 refers to name; credited refers to credited = 'true'; as \"technical advisor\" refers to role = 'technical advisor'; titled \"Cherished\" refers to title = 'Cherished'\nWho was credited as \"technical advisor\" in the episode titled \"Cherished\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Park Dietz', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredited refers to credited = 'true'\nFor how many times was Park Dietz credited?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz'", "index": 636, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Park Dietz', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredited refers to credited = 'true'\nFor how many times was Park Dietz credited?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629204', 'tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629204', 'tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Anthony Azzara', 'Julia Roberts', 'Rene Balcer']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode tt0629204 refers to episode_id = 'tt0629204'; credited refers to credited = 'true'; not credited refers to credited = ''\nWas Anthony Azzara's role in episode tt0629204 displayed in the credits at the end of the episode?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.credited FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Anthony Azzara' AND T1.episode_id = 'tt0629204'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.credited FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Anthony Azzara' AND T1.episode_id = 'tt0629204'", "index": 637, "question": "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 Episode (\n episode_id text, -- example: ['tt0629204', 'tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629204', 'tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Anthony Azzara', 'Julia Roberts', 'Rene Balcer']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode tt0629204 refers to episode_id = 'tt0629204'; credited refers to credited = 'true'; not credited refers to credited = ''\nWas Anthony Azzara's role in episode tt0629204 displayed in the credits at the end of the episode?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLaw and Order refers to series = 'Law and Order'; included in the credit refers to credited = 'true'\nFor season 9, episode 17 of the show Law and Order, how many roles have been included in the credit?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.role) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.series = 'Law and Order' AND T1.season = 9 AND T1.episode = 17 AND T2.credited = 'true'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T2.role) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.series = 'Law and Order' AND T1.season = 9 AND T1.episode = 17 AND T2.credited = 'true'", "index": 638, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLaw and Order refers to series = 'Law and Order'; included in the credit refers to credited = 'true'\nFor season 9, episode 17 of the show Law and Order, how many roles have been included in the credit?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_country text, -- example: ['USA', 'Canada']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndescription of what happened refers to summary; award no.296 refers to award_id = '296'\nDescribe what happened in the episode of award no.296.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.summary FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.award_id = 296", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.summary FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.award_id = 296", "index": 639, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_country text, -- example: ['USA', 'Canada']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndescription of what happened refers to summary; award no.296 refers to award_id = '296'\nDescribe what happened in the episode of award no.296.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Joseph Blair', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_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 role did Joseph Blair play in the show?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.role FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Joseph Blair'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.role FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Joseph Blair'", "index": 640, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Joseph Blair', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_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 role did Joseph Blair play in the show?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most votes refers to max(votes)\nFor the episode with the most votes, give its air date.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.air_date FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id GROUP BY T2.episode_id ORDER BY SUM(T1.votes) DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.air_date FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id GROUP BY T2.episode_id ORDER BY SUM(T1.votes) DESC LIMIT 1", "index": 641, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most votes refers to max(votes)\nFor the episode with the most votes, give its air date.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naward no.313 refers to award_id = '313'; full name refers to name\nWho was nominated for award no.313? Give the 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.award_id = 313", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.award_id = 313", "index": 642, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naward no.313 refers to award_id = '313'; full name refers to name\nWho was nominated for award no.313? Give the 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['J.K. Simmons', 'Julia Roberts', 'Rene Balcer']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\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 episodes did J.K. Simmons' role appear on the show?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'J.K. Simmons'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'J.K. Simmons'", "index": 643, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['J.K. Simmons', 'Julia Roberts', 'Rene Balcer']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\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 episodes did J.K. Simmons' role appear on the show?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Sideshow', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n9-star vote refers to stars = '9'; episode Sideshow refers to title = 'Sideshow'\nDisplay the number of 9-star votes the episode Sideshow received.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 9 AND T1.title = 'Sideshow'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 9 AND T1.title = 'Sideshow'", "index": 644, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Sideshow', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n9-star vote refers to stars = '9'; episode Sideshow refers to title = 'Sideshow'\nDisplay the number of 9-star votes the episode Sideshow received.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwon refers to result = 'Winner'; at least 3 awards refers to count(result) > 3\nHow many people have won at least 3 awards?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.result = 'Winner' GROUP BY T1.person_id HAVING COUNT(T2.award_id) >= 3", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.result = 'Winner' GROUP BY T1.person_id HAVING COUNT(T2.award_id) >= 3", "index": 645, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwon refers to result = 'Winner'; at least 3 awards refers to count(result) > 3\nHow many people have won at least 3 awards?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['True North', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe \"True North\" episode refers to title = 'True North'; 1-star refers to stars = 1; percentage = divide(count(episode_id where stars = 1), count(episode_id)) * 100% where title = 'True North'\nWhat is the percentage of people who gave the \"True North\" episode a 1-star rating?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.stars = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'True North' AND T1.episode_id = 'tt0629477'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.stars = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'True North' AND T1.episode_id = 'tt0629477'", "index": 646, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['True North', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe \"True North\" episode refers to title = 'True North'; 1-star refers to stars = 1; percentage = divide(count(episode_id where stars = 1), count(episode_id)) * 100% where title = 'True North'\nWhat is the percentage of people who gave the \"True North\" episode a 1-star rating?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest number of keywords refers to max(count(keyword))\nWhat is the title of the episode with the highest number of keywords?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id GROUP BY T1.episode_id ORDER BY COUNT(T2.keyword) DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id GROUP BY T1.episode_id ORDER BY COUNT(T2.keyword) DESC LIMIT 1", "index": 647, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest number of keywords refers to max(count(keyword))\nWhat is the title of the episode with the highest number of keywords?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naired in 1998 refers to air_date like '1998%'; won refers to result = 'Winner'; International Monitor Awards refers to organization = 'International Monitor Awards'\nAmong the episodes that were aired in 1998, how many won an International Monitor Awards?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE strftime('%Y', T1.air_date) = '1998' AND T2.organization = 'International Monitor Awards' AND T2.result = 'Winner'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE strftime('%Y', T1.air_date) = '1998' AND T2.organization = 'International Monitor Awards' AND T2.result = 'Winner'", "index": 648, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naired in 1998 refers to air_date like '1998%'; won refers to result = 'Winner'; International Monitor Awards refers to organization = 'International Monitor Awards'\nAmong the episodes that were aired in 1998, how many won an International Monitor Awards?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe 2nd-highest number of votes refers to second max(votes)\nWhat are the keywords of the episode which received the 2nd-highest number of votes?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.votes NOT IN ( SELECT MAX(T1.votes) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id ) ORDER BY T1.votes DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.votes NOT IN ( SELECT MAX(T1.votes) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id ) ORDER BY T1.votes DESC LIMIT 1", "index": 649, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe 2nd-highest number of votes refers to second max(votes)\nWhat are the keywords of the episode which received the 2nd-highest number of votes?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['Narrator', 'technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Flight', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_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 refers to name; narrator refers to role = 'Narrator'; the \"Flight\" episode refers to title = 'Flight'\nWho is the narrator of the \"Flight\" episode?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Flight' AND T2.role = 'Narrator'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Flight' AND T2.role = 'Narrator'", "index": 650, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['Narrator', 'technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Flight', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_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 refers to name; narrator refers to role = 'Narrator'; the \"Flight\" episode refers to title = 'Flight'\nWho is the narrator of the \"Flight\" episode?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Art Department', 'Additional Crew']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest number of crews refers to max(count(person_id)); in the Art Department refers to category = 'Art Department'\nWhat is the title of the episode that has the highest number of crews in the Art Department?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.title FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.category = 'Art Department' GROUP BY T2.episode_id ORDER BY COUNT(T1.category) DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.title FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.category = 'Art Department' GROUP BY T2.episode_id ORDER BY COUNT(T1.category) DESC LIMIT 1", "index": 651, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Art Department', 'Additional Crew']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest number of crews refers to max(count(person_id)); in the Art Department refers to category = 'Art Department'\nWhat is the title of the episode that has the highest number of crews in the Art Department?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\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 roles did Julia Roberts play in the series?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Julia Roberts'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Julia Roberts'", "index": 652, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\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 roles did Julia Roberts play in the series?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['Clerk', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n PRIMARY KEY (episode_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 refers to name; the youngest person refers to max(birthdate); a \"clerk\" role refers to role = 'Clerk'\nWho is the youngest person to ever play a \"clerk\" role in the series?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'Clerk' AND T2.birthdate IS NOT NULL ORDER BY T2.birthdate LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'Clerk' AND T2.birthdate IS NOT NULL ORDER BY T2.birthdate LIMIT 1", "index": 653, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['Clerk', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n PRIMARY KEY (episode_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 refers to name; the youngest person refers to max(birthdate); a \"clerk\" role refers to role = 'Clerk'\nWho is the youngest person to ever play a \"clerk\" role in the series?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not enjoy refers to stars = 1; the finale episode refers to episode = 24\nHow many people did not enjoy the finale episode?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode = 24 AND T2.stars = 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode = 24 AND T2.stars = 1", "index": 654, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not enjoy refers to stars = 1; the finale episode refers to episode = 24\nHow many people did not enjoy the finale episode?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_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 refers to name; appear the most refers to max(count(person_id)); percentage = divide(count(person_id where max(count(person_id))), count(person_id)) * 100%\nWho is the person who appeared the most in the series? Calculate in percentage how many times he or she appeared.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.person_id, CAST(COUNT(T2.person_id) AS REAL) * 100 / ( SELECT COUNT(T2.person_id) AS num FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id ) AS per FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id GROUP BY T2.person_id ORDER BY COUNT(T2.person_id) DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.person_id, CAST(COUNT(T2.person_id) AS REAL) * 100 / ( SELECT COUNT(T2.person_id) AS num FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id ) AS per FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id GROUP BY T2.person_id ORDER BY COUNT(T2.person_id) DESC LIMIT 1", "index": 655, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_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 refers to name; appear the most refers to max(count(person_id)); percentage = divide(count(person_id where max(count(person_id))), count(person_id)) * 100%\nWho is the person who appeared the most in the series? Calculate in percentage how many times he or she appeared.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['Primetime Emmy Awards', 'International Monitor Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Primetime Emmy', 'Monitor']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to award; the Primetime Emmy Awards refers to award_category like 'Primetime Emmy'\nWhich episodes of the Law & Order have been nominated for the Primetime Emmy Awards?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT episode_id FROM Award WHERE award_category = 'Primetime Emmy'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT DISTINCT episode_id FROM Award WHERE award_category = 'Primetime Emmy'", "index": 656, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['Primetime Emmy Awards', 'International Monitor Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Primetime Emmy', 'Monitor']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to award; the Primetime Emmy Awards refers to award_category like 'Primetime Emmy'\nWhich episodes of the Law & Order have been nominated for the Primetime Emmy Awards?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhave not been credited refers to credited = ''\nWhat roles have not been credited at the end of the episodes?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT role FROM Credit WHERE credited = 'false'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT DISTINCT role FROM Credit WHERE credited = 'false'", "index": 657, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhave not been credited refers to credited = ''\nWhat roles have not been credited at the end of the episodes?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Rene Chenevert Balcer', 'Julia Fiona Roberts']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull place of birth refers to birth_place, birth_region; Rene Chenevert Balcer refers to birth_name = 'Rene Chenevert Balcer'\nWhat is the full place of birth of Rene Chenevert Balcer?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT birth_place, birth_region FROM Person WHERE birth_name = 'Rene Chenevert Balcer'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT birth_place, birth_region FROM Person WHERE birth_name = 'Rene Chenevert Balcer'", "index": 658, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Rene Chenevert Balcer', 'Julia Fiona Roberts']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull place of birth refers to birth_place, birth_region; Rene Chenevert Balcer refers to birth_name = 'Rene Chenevert Balcer'\nWhat is the full place of birth of Rene Chenevert Balcer?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n number_in_series integer, -- example: [182, 183]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['director', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['director', 'Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwon an award refers to result = 'Winner'; role as director refers to role = 'director'\nWhat are the names of the two people who won an award for their role as directors?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.Result = 'Winner' AND T2.role = 'director'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.Result = 'Winner' AND T2.role = 'director'", "index": 659, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n number_in_series integer, -- example: [182, 183]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['director', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['director', 'Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwon an award refers to result = 'Winner'; role as director refers to role = 'director'\nWhat are the names of the two people who won an award for their role as directors?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Anthony Azzara', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_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 episode refers to title; not credited refers to credited = ''\nIn which episodes was Anthony Azzara not credited?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'false' AND T3.name = 'Anthony Azzara'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'false' AND T3.name = 'Anthony Azzara'", "index": 660, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Anthony Azzara', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_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 episode refers to title; not credited refers to credited = ''\nIn which episodes was Anthony Azzara not credited?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['assistant location manager', 'location manager', 'technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nregion refers to birth_region; assistant location manager refers to role = 'assistant location manager'\nIn which region were the assistant location managers born?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.birth_region FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'president of NBC West Coast'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.birth_region FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'president of NBC West Coast'", "index": 661, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['assistant location manager', 'location manager', 'technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nregion refers to birth_region; assistant location manager refers to role = 'assistant location manager'\nIn which region were the assistant location managers born?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Donna Villella', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\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 stars did the episodes in which Donna Villella worked?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T3.name = 'Donna Villella'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T3.name = 'Donna Villella'", "index": 662, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Donna Villella', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\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 stars did the episodes in which Donna Villella worked?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Nominee', 'Winner']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnominated refers to result = 'Nominee'\nWhat role was Julia Roberts nominated for?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.role FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.Result = 'Nominee' AND T1.name = 'Julia Roberts'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.role FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.Result = 'Nominee' AND T1.name = 'Julia Roberts'", "index": 663, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Nominee', 'Winner']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnominated refers to result = 'Nominee'\nWhat role was Julia Roberts nominated for?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Nominee', 'Winner']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most nominations refers to max(count(episode_id where result = 'Nominee'))\nWhat is the title of the episode with the most nominations?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.result = 'Nominee' GROUP BY T2.episode_id ORDER BY COUNT(T1.result) DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.result = 'Nominee' GROUP BY T2.episode_id ORDER BY COUNT(T1.result) DESC LIMIT 1", "index": 664, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Nominee', 'Winner']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe most nominations refers to max(count(episode_id where result = 'Nominee'))\nWhat is the title of the episode with the most nominations?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_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 are the names of all the people who worked on episode 19 of season 9?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.episode = 19 AND T1.season = 9", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.episode = 19 AND T1.season = 9", "index": 665, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n PRIMARY KEY (person_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 are the names of all the people who worked on episode 19 of season 9?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['True North', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe True North episode refers to title = 'True North'; additional crew refers to role = 'Additional Crew'; percentage = divide(count(episode_id where role = 'Additional Crew'), count(episode_id)) * 100% where title = 'True North'\nWhat percentage of people have worked on the True North episode as additional crew?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.role = 'Additional Crew' THEN 1 ELSE 0 END) AS REAL ) * 100 / COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'True North'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.role = 'Additional Crew' THEN 1 ELSE 0 END) AS REAL ) * 100 / COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'True North'", "index": 666, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['True North', 'Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe True North episode refers to title = 'True North'; additional crew refers to role = 'Additional Crew'; percentage = divide(count(episode_id where role = 'Additional Crew'), count(episode_id)) * 100% where title = 'True North'\nWhat percentage of people have worked on the True North episode as additional crew?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n72 10-star votes refers to stars = 10 and votes = 72\nWrite down the title, summary, and air date of the episode that garnered 72 10-star votes.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.title, T2.summary, T2.air_date FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10 AND T1.votes = 72", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.title, T2.summary, T2.air_date FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10 AND T1.votes = 72", "index": 667, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n72 10-star votes refers to stars = 10 and votes = 72\nWrite down the title, summary, and air date of the episode that garnered 72 10-star votes.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n6-star vote refers to stars = 6\nHow many 6-star votes did episode 12 get? Please include the air date and rating.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.air_date, T2.rating FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 6 AND T2.episode = 12", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.air_date, T2.rating FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 6 AND T2.episode = 12", "index": 668, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n6-star vote refers to stars = 6\nHow many 6-star votes did episode 12 get? Please include the air date and rating.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Rene Balcer', 'Julia Roberts']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nRene Balcer refers to name = 'Rene Balcer'; the winner refers to result = 'Winner'\nWrite down the organization, year, award, and award category in which Rene Balcer is the winner.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.organization, T2.year, T2.award, T2.award_category FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Rene Balcer' AND T2.result = 'Winner'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.organization, T2.year, T2.award, T2.award_category FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Rene Balcer' AND T2.result = 'Winner'", "index": 669, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Rene Balcer', 'Julia Roberts']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nRene Balcer refers to name = 'Rene Balcer'; the winner refers to result = 'Winner'\nWrite down the organization, year, award, and award category in which Rene Balcer is the winner.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Constantine Makris', 'Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Silver Gavel Award', 'Monitor', 'Primetime Emmy']\n award text, -- example: ['Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe winner refers to result = 'Winner'; the Television refers to award = 'Television'; Silver Gavel Award refers to award_category = 'Silver Gavel Award'; the American Bar Association Silver Gavel Awards for Media and the Arts refers to organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'\nGive me the years and episode IDs in which Constantine Makris was the winner of the Television Silver Gavel Award at the American Bar Association Silver Gavel Awards for Media and the Arts for two consecutive 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT t3.years, t3.episode_id FROM ( SELECT DISTINCT T2.year AS years, T2.episode_id, row_number() OVER (PARTITION BY T2.episode_id ORDER BY T2.year) AS rm FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.award = 'Television' AND T2.award_category = 'Silver Gavel Award' AND T1.name = 'Constantine Makris' AND T2.result = 'Winner' AND T2.organization = 'American Bar Association Silver Gavel Awards for Media and the Arts' ) AS T3 GROUP BY t3.episode_id HAVING COUNT(t3.years - t3.rm) >= 2", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT t3.years, t3.episode_id FROM ( SELECT DISTINCT T2.year AS years, T2.episode_id, row_number() OVER (PARTITION BY T2.episode_id ORDER BY T2.year) AS rm FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.award = 'Television' AND T2.award_category = 'Silver Gavel Award' AND T1.name = 'Constantine Makris' AND T2.result = 'Winner' AND T2.organization = 'American Bar Association Silver Gavel Awards for Media and the Arts' ) AS T3 GROUP BY t3.episode_id HAVING COUNT(t3.years - t3.rm) >= 2", "index": 670, "question": "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 Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Constantine Makris', 'Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Silver Gavel Award', 'Monitor', 'Primetime Emmy']\n award text, -- example: ['Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe winner refers to result = 'Winner'; the Television refers to award = 'Television'; Silver Gavel Award refers to award_category = 'Silver Gavel Award'; the American Bar Association Silver Gavel Awards for Media and the Arts refers to organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'\nGive me the years and episode IDs in which Constantine Makris was the winner of the Television Silver Gavel Award at the American Bar Association Silver Gavel Awards for Media and the Arts for two consecutive 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['president of NBC West Coast', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_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 refers to name; the role of the \"president of NBC West Coast\" refers to role = 'president of NBC West Coast'; the first episode refers to episode = 1\nWho played the role of the \"president of NBC West Coast\" in the first episode?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T3.episode = 1 AND T1.role = 'president of NBC West Coast'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T3.episode = 1 AND T1.role = 'president of NBC West Coast'", "index": 671, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['president of NBC West Coast', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_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 refers to name; the role of the \"president of NBC West Coast\" refers to role = 'president of NBC West Coast'; the first episode refers to episode = 1\nWho played the role of the \"president of NBC West Coast\" in the first episode?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['Canada', 'USA']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfrom Canada refers to birth_country = Canada; nominated refers to award is NOT NULL\nHow many people from Canada are nominated for an award?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.birth_country = 'Canada'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.birth_country = 'Canada'", "index": 672, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['Canada', 'USA']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfrom Canada refers to birth_country = Canada; nominated refers to award is NOT NULL\nHow many people from Canada are nominated for an award?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Jerry Orbach', 'Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\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 episodes are credited to Jerry Orbach?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.person_id) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Jerry Orbach'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T2.person_id) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Jerry Orbach'", "index": 673, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Jerry Orbach', 'Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\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 episodes are credited to Jerry Orbach?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat least two awards refers to count(role) >1\nWhich role have won at least two awards for the entire season and list out the 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id GROUP BY T2.role HAVING COUNT(T2.award_id) > 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id GROUP BY T2.role HAVING COUNT(T2.award_id) > 1", "index": 674, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat least two awards refers to count(role) >1\nWhich role have won at least two awards for the entire season and list out the 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe first episode refers to episode = 1; the last episode refers to episode = 24; 10 stars vote refers to stars = 10; the difference = subtract(votes where episode = 1, votes where episode = 24) where stars = 10\nWhat is the difference of 10 stars votes between the first episode and the last episode?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(CASE WHEN T2.episode = 24 THEN T1.votes ELSE 0 END) - SUM(CASE WHEN T2.episode = 1 THEN T1.votes ELSE 0 END) FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT SUM(CASE WHEN T2.episode = 24 THEN T1.votes ELSE 0 END) - SUM(CASE WHEN T2.episode = 1 THEN T1.votes ELSE 0 END) FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10", "index": 675, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe first episode refers to episode = 1; the last episode refers to episode = 24; 10 stars vote refers to stars = 10; the difference = subtract(votes where episode = 1, votes where episode = 24) where stars = 10\nWhat is the difference of 10 stars votes between the first episode and the last episode?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit displayed refers to credited = 'true'; from episode 1 until 10 refers to episode > = 1 AND episode < = 10\nHow many credits have been displayed from episode 1 until 10?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.person_id) FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.credited = 'true' AND T2.episode BETWEEN 1 AND 10", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(T1.person_id) FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.credited = 'true' AND T2.episode BETWEEN 1 AND 10", "index": 676, "question": "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 Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n PRIMARY KEY (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit displayed refers to credited = 'true'; from episode 1 until 10 refers to episode > = 1 AND episode < = 10\nHow many credits have been displayed from episode 1 until 10?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreceived award refers to result = 'Winner'; the highest percentage refers to max(percent); average star = divide(sum(stars), count(episode_id))\nWhat is the average star with highest percentage for episodes that have received award?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.person_id FROM Vote AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id ORDER BY T1.percent DESC LIMIT 1", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.person_id FROM Vote AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id ORDER BY T1.percent DESC LIMIT 1", "index": 677, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreceived award refers to result = 'Winner'; the highest percentage refers to max(percent); average star = divide(sum(stars), count(episode_id))\nWhat is the average star with highest percentage for episodes that have received award?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage ranking = divide(sum(rating), sum(episode_id))\nWhat is the average ranking episodes that are nominated for an award?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(T1.rating) / COUNT(T1.episode) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT SUM(T1.rating) / COUNT(T1.episode) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id", "index": 678, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage ranking = divide(sum(rating), sum(episode_id))\nWhat is the average ranking episodes that are nominated for an award?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwinner refers to result = 'Winner'; Television award refers to award = 'Television'; the \"American Bar Association Silver Gavel Awards for Media and the Arts\" refers to organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'\nHow many winners have been awarded a Television award by the \"American Bar Association Silver Gavel Awards for Media and the Arts\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(award_id) FROM Award WHERE result = 'Winner' AND award = 'Television' AND organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT COUNT(award_id) FROM Award WHERE result = 'Winner' AND award = 'Television' AND organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'", "index": 679, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwinner refers to result = 'Winner'; Television award refers to award = 'Television'; the \"American Bar Association Silver Gavel Awards for Media and the Arts\" refers to organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'\nHow many winners have been awarded a Television award by the \"American Bar Association Silver Gavel Awards for Media and the Arts\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Michael Preston', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncontinent refers to birth_country\nWhich continent was Michael Preston born on?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT birth_country FROM Person WHERE name = 'Michael Preston'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT birth_country FROM Person WHERE name = 'Michael Preston'", "index": 680, "question": "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 Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Michael Preston', 'Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncontinent refers to birth_country\nWhich continent was Michael Preston born on?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Best Television Episode', 'Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['teleplay', 'Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe role of a teleplay refers to role = 'teleplay'; won refers to result = 'Winner'; \"Best Television Episode\" refers to award = 'Best Television Episode'\nWho played the role of a teleplay in the episode that won \"Best Television Episode\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.name FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.result = 'Winner' AND T1.award = 'Best Television Episode'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.name FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.result = 'Winner' AND T1.award = 'Best Television Episode'", "index": 681, "question": "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 Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birth_region text, -- example: ['Georgia', 'Quebec']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n `year` integer, -- example: [1999, 2000]\n award text, -- example: ['Best Television Episode', 'Television', 'Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['teleplay', 'Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe role of a teleplay refers to role = 'teleplay'; won refers to result = 'Winner'; \"Best Television Episode\" refers to award = 'Best Television Episode'\nWho played the role of a teleplay in the episode that won \"Best Television Episode\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Outstanding Costume Design for a Series', 'Film Originated Television Series - Best']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['Costume Designer', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to title; \"Outstanding Costume Design for a Series\" refers to award = 'Outstanding Costume Design for a Series'\nWhich episode was nominated for the award for \"Outstanding Costume Design for a Series\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award = 'Outstanding Costume Design for a Series'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award = 'Outstanding Costume Design for a Series'", "index": 682, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Outstanding Costume Design for a Series', 'Film Originated Television Series - Best']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['Costume Designer', 'technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to title; \"Outstanding Costume Design for a Series\" refers to award = 'Outstanding Costume Design for a Series'\nWhich episode was nominated for the award for \"Outstanding Costume Design for a Series\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Shield', 'Cherished', 'DWB']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe episode \"Shield\" refers to title = 'Shield'\nWhat are the keywords of the episode \"Shield\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Shield'", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Shield'", "index": 683, "question": "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 Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['nun', 'priest']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n `role` text, -- example: ['technical advisor', 'production accountant']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n episode integer, -- example: [1, 2]\n title text, -- example: ['Shield', 'Cherished', 'DWB']\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n votes integer, -- example: [36, 39]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Award (\n award_id integer, -- example: [258, 259]\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe episode \"Shield\" refers to title = 'Shield'\nWhat are the keywords of the episode \"Shield\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['priest', 'nun']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to title; the two keywords \"nun\" and \"priest\" refers to keyword = 'nun' or keyword = 'priest';\nWhich episode has the two keywords \"nun\" and \"priest\"?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword IN ('nun', 'priest')", "style": "rule" }
{ "db_id": "law_episode.sqlite", "gt_sql": "SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword IN ('nun', 'priest')", "index": 684, "question": "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 Award (\n award_id integer, -- example: [258, 259]\n organization text, -- example: ['International Monitor Awards', 'Primetime Emmy Awards']\n `year` integer, -- example: [1999, 2000]\n award_category text, -- example: ['Monitor', 'Primetime Emmy']\n award text, -- example: ['Film Originated Television Series - Best', 'Outstanding Costume Design for a Series']\n series text, -- example: ['Law and Order']\n episode_id text, -- example: ['tt0629149', 'tt0629398']\n person_id text, -- example: ['nm0937725', 'nm0792309']\n `role` text, -- example: ['Katrina Ludlow', 'production mixer']\n result text, -- example: ['Winner', 'Nominee']\n PRIMARY KEY (award_id),\n CONSTRAINT fk_award_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_award_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\n\nCREATE TABLE Episode (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n series text, -- example: ['Law and Order']\n season integer, -- example: [9]\n episode integer, -- example: [1, 2]\n number_in_series integer, -- example: [182, 183]\n title text, -- example: ['Cherished', 'DWB']\n summary text, -- example: ['New assistant DA Abbie Carmichael aggres', 'White police officers are accused of bea']\n air_date date, -- example: ['1998-09-23', '1998-10-07']\n episode_image text, -- example: ['https://m.media-amazon.com/images/M/MV5B']\n rating real, -- example: [7.9, 7.6]\n votes integer, -- example: [203, 177]\n PRIMARY KEY (episode_id)\n);\n\nCREATE TABLE Keyword (\n episode_id text, -- example: ['tt0629239', 'tt0629397']\n keyword text, -- example: ['priest', 'nun']\n PRIMARY KEY (episode_id, keyword),\n CONSTRAINT fk_keyword_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Vote (\n episode_id text, -- example: ['tt0629204', 'tt0629228']\n stars integer, -- example: [10, 9]\n votes integer, -- example: [36, 39]\n `percent` real, -- example: [17.7, 19.2]\n CONSTRAINT fk_vote_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id)\n);\n\nCREATE TABLE Person (\n person_id text, -- example: ['nm0000210', 'nm0000973']\n name text, -- example: ['Julia Roberts', 'Rene Balcer']\n birthdate date, -- example: ['1967-10-28', '1954-02-09']\n birth_name text, -- example: ['Julia Fiona Roberts', 'Rene Chenevert Balcer']\n birth_place text, -- example: ['Smyrna', 'Montreal']\n birth_region text, -- example: ['Georgia', 'Quebec']\n birth_country text, -- example: ['USA', 'Canada']\n height_meters real, -- example: [1.73, 1.88]\n nickname text, -- example: ['Jules', 'Gus']\n PRIMARY KEY (person_id)\n);\n\nCREATE TABLE Credit (\n episode_id text, -- example: ['tt0629146', 'tt0629149']\n person_id text, -- example: ['nm0000973', 'nm0001583']\n category text, -- example: ['Additional Crew', 'Art Department']\n `role` text, -- example: ['technical advisor', 'production accountant']\n credited text, -- example: ['true', 'false']\n PRIMARY KEY (episode_id, person_id),\n CONSTRAINT fk_credit_episode_id FOREIGN KEY (episode_id) REFERENCES Episode (episode_id),\n CONSTRAINT fk_credit_person_id FOREIGN KEY (person_id) REFERENCES Person (person_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nepisode refers to title; the two keywords \"nun\" and \"priest\" refers to keyword = 'nun' or keyword = 'priest';\nWhich episode has the two keywords \"nun\" and \"priest\"?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Systolic Blood Pressure', 'Diastolic Blood Pressure', 'Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest Systolic Blood Pressure refers to MAX(DESCRIPTION = 'Systolic Blood Pressure') from observations;\nDuring all the observations of Elly Koss, what was the highest Systolic Blood Pressure observed?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.value, T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure' ORDER BY T2.VALUE DESC LIMIT 1", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T2.value, T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure' ORDER BY T2.VALUE DESC LIMIT 1", "index": 685, "question": "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 immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Systolic Blood Pressure', 'Diastolic Blood Pressure', 'Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nthe highest Systolic Blood Pressure refers to MAX(DESCRIPTION = 'Systolic Blood Pressure') from observations;\nDuring all the observations of Elly Koss, what was the highest Systolic Blood Pressure observed?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Systolic Blood Pressure', 'Diastolic Blood Pressure', 'Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\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:\nSystolic Blood Pressure refers to DESCRIPTION = 'Systolic Blood Pressure';\nFor how many times had Elly Koss have her Systolic Blood Pressure observed?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.description) FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT COUNT(T2.description) FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure'", "index": 686, "question": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Systolic Blood Pressure', 'Diastolic Blood Pressure', 'Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\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:\nSystolic Blood Pressure refers to DESCRIPTION = 'Systolic Blood Pressure';\nFor how many times had Elly Koss have her Systolic Blood Pressure observed?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION COUNT` integer, -- example: [1000]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Koss', 'Schuster', 'Schaden']\n PRIMARY KEY (patient)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nSUM(MULTIPLY(365, SUBTRACT(strftime('%Y', STOP), strftime('%Y', START))), MULTIPLY(30, SUBTRACT(strftime('%m', STOP), strftime('%m', START))), SUBTRACT(strftime('%d', STOP), strftime('%d', START))) where DESCRIPTION like 'Acetaminophen%';\nFor how long was Elly Koss required to take Acetaminophen?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT strftime('%J', T2.STOP) - strftime('%J', T2.START) AS days FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT strftime('%J', T2.STOP) - strftime('%J', T2.START) AS days FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'", "index": 687, "question": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION COUNT` integer, -- example: [1000]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Koss', 'Schuster', 'Schaden']\n PRIMARY KEY (patient)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nSUM(MULTIPLY(365, SUBTRACT(strftime('%Y', STOP), strftime('%Y', START))), MULTIPLY(30, SUBTRACT(strftime('%m', STOP), strftime('%m', START))), SUBTRACT(strftime('%d', STOP), strftime('%d', START))) where DESCRIPTION like 'Acetaminophen%';\nFor how long was Elly Koss required to take Acetaminophen?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n gender text, -- example: ['F', 'M']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwhy need to take Acetaminophen refers to REASONDESCRIPTION  where DESCRIPTION like 'Acetaminophen%' from medications;\nWhy did Elly Koss need to take Acetaminophen?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.REASONDESCRIPTION FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T2.REASONDESCRIPTION FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'", "index": 688, "question": "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_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n gender text, -- example: ['F', 'M']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwhy need to take Acetaminophen refers to REASONDESCRIPTION  where DESCRIPTION like 'Acetaminophen%' from medications;\nWhy did Elly Koss need to take Acetaminophen?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, last; prescribed with Acetaminophen refer to DESCRIPTION like 'Acetaminophen%' from medications;\nPlease give the full names of all the patients who had been prescribed with Acetaminophen.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.description LIKE 'Acetaminophen%'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.description LIKE 'Acetaminophen%'", "index": 689, "question": "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 observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, last; prescribed with Acetaminophen refer to DESCRIPTION like 'Acetaminophen%' from medications;\nPlease give the full names of all the patients who had been prescribed with Acetaminophen.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Koss', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2009-01-08', '2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['2009-01-08', '1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2009-01-08', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-08', '2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncondition on 2009/1/8 refers to DESCRIPTION from conditions where START = '2009-01-08';\nWhat was the condition of Elly Koss on 2009/1/8?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.START = '2009-01-08'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.START = '2009-01-08'", "index": 690, "question": "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 patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Elly', 'Rosamaria', 'Loan']\n last text, -- example: ['Koss', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Koss', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2009-01-08', '2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['2009-01-08', '1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2009-01-08', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-08', '2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncondition on 2009/1/8 refers to DESCRIPTION from conditions where START = '2009-01-08';\nWhat was the condition of Elly Koss on 2009/1/8?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Norman', 'Rosamaria', 'Loan']\n last text, -- example: ['Berge', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n REASONCODE integer, -- example: [10509002, 38822007]\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\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 care plans has Mrs. Norman Berge 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Norman' AND T1.last = 'Berge'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Norman' AND T1.last = 'Berge'", "index": 691, "question": "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 observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Norman', 'Rosamaria', 'Loan']\n last text, -- example: ['Berge', 'Pfannerstill', 'Bashirian']\n marital text, -- example: ['S', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n REASONCODE integer, -- example: [10509002, 38822007]\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\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 care plans has Mrs. Norman Berge 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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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_prevalences (\n ITEM text, -- example: ['Leucovorin 100 Mg Injection', '0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['1970-12-15', '1970-12-12', '2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Annabelle', 'Rosamaria', 'Loan']\n last text, -- example: ['Pouros', 'Pfannerstill', 'Bashirian']\n race text, -- example: ['black', 'white']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1970-12-19', '1918-04-17', '1919-06-28']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Leucovorin 100 MG Injection', 'Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['1970-12-12', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreason why take leucovorin 100 mg injection refers to REASONDESCRIPTION where DESCRIPTION = 'Leucovorin 100 MG Injection'; on 1970/12/19 refers to START = '1970-12-19';\nWhy did Mrs. Annabelle Pouros take leucovorin 100 mg injection on 1970/12/19? State the reason.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.reasondescription FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Annabelle' AND T1.last = 'Pouros' AND T2.start = '1970-12-19' AND T2.description = 'Leucovorin 100 MG Injection'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T2.reasondescription FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Annabelle' AND T1.last = 'Pouros' AND T2.start = '1970-12-19' AND T2.description = 'Leucovorin 100 MG Injection'", "index": 692, "question": "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_prevalences (\n ITEM text, -- example: ['Leucovorin 100 Mg Injection', '0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['1970-12-15', '1970-12-12', '2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Annabelle', 'Rosamaria', 'Loan']\n last text, -- example: ['Pouros', 'Pfannerstill', 'Bashirian']\n race text, -- example: ['black', 'white']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1970-12-19', '1918-04-17', '1919-06-28']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Leucovorin 100 MG Injection', 'Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['1970-12-12', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreason why take leucovorin 100 mg injection refers to REASONDESCRIPTION where DESCRIPTION = 'Leucovorin 100 MG Injection'; on 1970/12/19 refers to START = '1970-12-19';\nWhy did Mrs. Annabelle Pouros take leucovorin 100 mg injection on 1970/12/19? State the reason.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n maiden text, -- example: ['Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncondition no. 64859006 refers to conditions where CODE = '64859006';\nWhat is the prevalence percentage of condition no. 64859006?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT T1.\"PREVALENCE PERCENTAGE\" FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) WHERE T2.code = '64859006'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT DISTINCT T1.\"PREVALENCE PERCENTAGE\" FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) WHERE T2.code = '64859006'", "index": 693, "question": "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 medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n maiden text, -- example: ['Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncondition no. 64859006 refers to conditions where CODE = '64859006';\nWhat is the prevalence percentage of condition no. 64859006?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2009-08-09', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2009-08-09', '2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-08-09', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-08-09', '2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2009-08-09', '2008-03-11', '2009-01-11']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-08-09', '2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Ms.', 'Mr.', 'Mrs.']\n first text, -- example: ['Jacquelyn', 'Rosamaria', 'Loan']\n last text, -- example: ['Shanahan', 'Pfannerstill', 'Bashirian']\n maiden text, -- example: ['Shanahan', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n gender text, -- example: ['F', 'M']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2009/8/9 refers to DATE = '2009-08-09';\nGive the procedure description of Ms. Jacquelyn Shanahan on 2009/8/9.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Jacquelyn' AND T1.last = 'Shanahan' AND T2.DATE = '2009-08-09'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Jacquelyn' AND T1.last = 'Shanahan' AND T2.DATE = '2009-08-09'", "index": 694, "question": "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 encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2009-08-09', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2009-08-09', '2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-08-09', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-08-09', '2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2009-08-09', '2008-03-11', '2009-01-11']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-08-09', '2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Ms.', 'Mr.', 'Mrs.']\n first text, -- example: ['Jacquelyn', 'Rosamaria', 'Loan']\n last text, -- example: ['Shanahan', 'Pfannerstill', 'Bashirian']\n maiden text, -- example: ['Shanahan', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n gender text, -- example: ['F', 'M']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2009/8/9 refers to DATE = '2009-08-09';\nGive the procedure description of Ms. Jacquelyn Shanahan on 2009/8/9.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Saundra', 'Rosamaria', 'Loan']\n last text, -- example: ['Monahan', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nallergies refer to PATIENT from allergies;\nHow many allergies does Mrs. Saundra Monahan have?\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(DISTINCT T2.code) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Saundra' AND T1.last = 'Monahan'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT COUNT(DISTINCT T2.code) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Saundra' AND T1.last = 'Monahan'", "index": 695, "question": "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 claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE observations (\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n `VALUE` real, -- example: [166.03, 54.42]\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mrs.', 'Mr.']\n first text, -- example: ['Saundra', 'Rosamaria', 'Loan']\n last text, -- example: ['Monahan', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nallergies refer to PATIENT from allergies;\nHow many allergies does Mrs. Saundra Monahan have?\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['1947-09-11', '2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['1947-09-11', '2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['1947-09-11', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['1947-09-11', '2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nname of the patient implies full name and refers to first, last; on 1947/9/11 refers to BILLABLEPERIOD = '1947-09-11';\nProvide the name of the patient who had a claim on 1947/9/11.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T2.billableperiod = '1947-09-11'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T2.billableperiod = '1947-09-11'", "index": 696, "question": "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 conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['1947-09-11', '2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['1947-09-11', '2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['1947-09-11', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['1947-09-11', '2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nname of the patient implies full name and refers to first, last; on 1947/9/11 refers to BILLABLEPERIOD = '1947-09-11';\nProvide the name of the patient who had a claim on 1947/9/11.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Keven', 'Rosamaria', 'Loan']\n last text, -- example: ['Kuhn', 'Pfannerstill', 'Bashirian']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2016-09-24', '2016-10-10', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2016-10-10', '2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2016-09-24', '2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['2016-09-24', '2016-10-10', '1918-04-17', '1919-06-28']\n STOP date, -- example: ['2016-10-10', '2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2016-10-10', '2009-01-11', '2010-10-16']\n STOP date, -- example: ['2016-10-10', '2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nkind of condition refers to DESCRIPTION from conditions; from 2016/9/24 to 2016/10/10 refers to START = '2016-09-24' and STOP = '2016-10-10';\nWhat kind of condition did Keven Kuhn have from 2016/9/24 to 2016/10/10? Describe the condition.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Keven' AND T1.last = 'Kuhn' AND T2.start = '2016-09-24' AND T2.stop = '2016-10-10'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Keven' AND T1.last = 'Kuhn' AND T2.start = '2016-09-24' AND T2.stop = '2016-10-10'", "index": 697, "question": "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 allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n first text, -- example: ['Keven', 'Rosamaria', 'Loan']\n last text, -- example: ['Kuhn', 'Pfannerstill', 'Bashirian']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2016-09-24', '2016-10-10', '2009-01-08', '2010-10-16']\n STOP date, -- example: ['2016-10-10', '2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2016-09-24', '2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['2016-09-24', '2016-10-10', '1918-04-17', '1919-06-28']\n STOP date, -- example: ['2016-10-10', '2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2016-10-10', '2009-01-11', '2010-10-16']\n STOP date, -- example: ['2016-10-10', '2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2016-09-24', '2016-10-10', '2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nkind of condition refers to DESCRIPTION from conditions; from 2016/9/24 to 2016/10/10 refers to START = '2016-09-24' and STOP = '2016-10-10';\nWhat kind of condition did Keven Kuhn have from 2016/9/24 to 2016/10/10? Describe the condition.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Wesley', 'Rosamaria', 'Loan']\n last text, -- example: ['Lemke', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Lemke', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\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:\nDIVIDE(SUBTRACT(stop time - start time), COUNT(ID)));\nCalculate the average period of Mr. Wesley Lemke's care plans.\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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(strftime('%J', T2.STOP) - strftime('%J', T2.START)) AS REAL) / COUNT(T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mr.' AND T1.first = 'Wesley' AND T1.last = 'Lemke'", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT CAST(SUM(strftime('%J', T2.STOP) - strftime('%J', T2.START)) AS REAL) / COUNT(T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mr.' AND T1.first = 'Wesley' AND T1.last = 'Lemke'", "index": 698, "question": "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 careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE integer, -- example: [10509002, 38822007]\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONCODE integer, -- example: [10509002, 72892002]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n REASONCODE integer, -- example: [43878008, 10509002]\n REASONDESCRIPTION text, -- example: ['Streptococcal sore throat (disorder)', 'Acute bronchitis (disorder)']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n `POPULATION TYPE` text, -- example: ['LIVING']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n CODE integer, -- example: [185349003, 185345009]\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n ssn text, -- social security number, example: ['999-78-5976', '999-59-9186']\n drivers text, -- example: ['S99992928', 'S99975961']\n passport text, -- example: ['FALSE', 'X98167138X']\n prefix text, -- example: ['Mr.', 'Mrs.']\n first text, -- example: ['Wesley', 'Rosamaria', 'Loan']\n last text, -- example: ['Lemke', 'Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Lemke', 'Schuster', 'Schaden']\n marital text, -- example: ['S', 'M']\n race text, -- example: ['black', 'white']\n ethnicity text, -- example: ['dominican', 'american']\n gender text, -- example: ['F', 'M']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DIAGNOSIS text,\n TOTAL integer, -- example: [100]\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:\nDIVIDE(SUBTRACT(stop time - start time), COUNT(ID)));\nCalculate the average period of Mr. Wesley Lemke's care plans.\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", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "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 medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Schuster', 'Schaden']\n race text, -- example: ['black', 'white']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nid of the patient refers to PATIENT from allergies where STOP is not null; the longest allergy period refers to MAX(SUBTRACT((SUBSTR(STOP, - 2, 1)! = '9' then substr(STOP, length(STOP) - 1) + 2000 end), (SUBSTR(START, - 2, 1) = '9' then substr(START, length(START) - 1) + 1900 else substr(START, length(START) - 1) + 2000 end)));\n\nWhat is the id of the patient who has the longest allergy 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", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT PATIENT FROM allergies WHERE STOP IS NOT NULL GROUP BY PATIENT ORDER BY CASE WHEN SUBSTR(STOP, -2, 1) != '9' THEN SUBSTR(STOP, LENGTH(STOP) - 1) + 2000 END - CASE WHEN SUBSTR(START, -2, 1) = '9' THEN SUBSTR(START, LENGTH(START) - 1) + 1900 ELSE SUBSTR(START, LENGTH(START) - 1) + 2000 END LIMIT 1", "style": "rule" }
{ "db_id": "synthea.sqlite", "gt_sql": "SELECT PATIENT FROM allergies WHERE STOP IS NOT NULL GROUP BY PATIENT ORDER BY CASE WHEN SUBSTR(STOP, -2, 1) != '9' THEN SUBSTR(STOP, LENGTH(STOP) - 1) + 2000 END - CASE WHEN SUBSTR(START, -2, 1) = '9' THEN SUBSTR(START, LENGTH(START) - 1) + 1900 ELSE SUBSTR(START, LENGTH(START) - 1) + 2000 END LIMIT 1", "index": 699, "question": "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 medications (\n `START` date, -- example: ['1918-04-17', '1919-06-28']\n STOP date, -- example: ['2008-06-04', '2009-01-21']\n PATIENT text, -- example: ['ce11bcba-c83c-43ae-802d-b20ee8715afe', 'a9c61b1f-3ad5-47e0-9aae-1613640a8187']\n ENCOUNTER text, -- example: ['6334071d-e6b0-42c1-a082-2a08e123de4e', '23ab74d3-044b-465b-ad85-394acfda0ef7']\n CODE integer, -- example: [834060, 745679]\n DESCRIPTION text, -- example: ['Penicillin V Potassium 250 MG', 'NuvaRing 0.12/0.015 MG per 24HR 21 Day V']\n PRIMARY KEY (`START`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_medications_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_medications_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE careplans (\n ID text, -- example: ['e031962d-d13d-4ede-a449-040417d5e4fb', '26b879b7-0066-4bd6-b59c-099909720155']\n `START` date, -- example: ['2009-01-11', '2010-10-16']\n STOP date, -- example: ['2009-04-07', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n CODE real, -- example: [53950000.0, 304510005.0]\n DESCRIPTION text, -- example: ['Respiratory therapy', 'Recommendation to avoid exercise']\n REASONCODE integer, -- example: [10509002, 38822007]\n CONSTRAINT fk_careplans_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_careplans_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE claims (\n ID text, -- example: ['0004caaf-fd7a-4f64-bda6-dce5ebd1196c', '000acf3a-fcac-4cab-ac41-0153802bfd8c']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n BILLABLEPERIOD date, -- example: ['2008-03-11', '2009-01-11']\n ORGANIZATION text, -- example: ['temp organization']\n ENCOUNTER text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n TOTAL integer, -- example: [100]\n PRIMARY KEY (ID)\n);\n\nCREATE TABLE conditions (\n `START` date, -- example: ['2009-01-08', '2010-10-16']\n STOP date, -- example: ['2009-01-21', '2010-10-23']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['4d451e22-a354-40c9-8b33-b6126158666d', 'bed7ecff-b41c-422b-beac-ea00c8b02837']\n DESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Cystitis']\n CONSTRAINT fk_conditions_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_conditions_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID),\n CONSTRAINT fk_conditions_description FOREIGN KEY (DESCRIPTION) REFERENCES all_prevalences (ITEM)\n);\n\nCREATE TABLE all_prevalences (\n ITEM text, -- example: ['0.3 Ml Epinephrine 0.5 Mg/Ml Auto Inject', '0.65 Ml Depo Subq Provera 160 Mg/Ml Pref']\n OCCURRENCES integer, -- example: [868, 487]\n `POPULATION COUNT` integer, -- example: [1000]\n `PREVALENCE RATE` real, -- example: [0.868, 0.487]\n `PREVALENCE PERCENTAGE` real, -- example: [86.8, 48.7]\n PRIMARY KEY (ITEM)\n);\n\nCREATE TABLE patients (\n patient text, -- example: ['00269bb7-e3ab-43a9-9cdf-cdf9b6e3b2b3', '00341a88-1cc1-4b39-b0f9-05b0531991a0']\n birthdate date, -- example: ['1929-04-08', '2016-12-15']\n deathdate date, -- example: ['2029-11-11', '2020-02-19']\n first text, -- example: ['Rosamaria', 'Loan']\n last text, -- example: ['Pfannerstill', 'Bashirian']\n suffix text, -- example: ['PhD', 'JD']\n maiden text, -- example: ['Schuster', 'Schaden']\n race text, -- example: ['black', 'white']\n birthplace text, -- example: ['Pittsfield MA US', 'Medford MA US']\n address text, -- example: ['18797 Karson Burgs Suite 444 Palmer Town', '301 Eula Radial Suite 298 Brockton MA 02']\n PRIMARY KEY (patient)\n);\n\nCREATE TABLE encounters (\n ID text, -- example: ['000c20ea-5c3d-43a3-9608-bd37c22f13c8', '0013c51f-c315-4112-ad5e-466b604a05ed']\n `DATE` date, -- example: ['2008-03-11', '2009-01-11']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n DESCRIPTION text, -- example: ['Outpatient Encounter', 'Encounter for symptom']\n REASONCODE integer, -- example: [10509002, 38822007]\n PRIMARY KEY (ID),\n CONSTRAINT fk_encounters_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient)\n);\n\nCREATE TABLE observations (\n `DATE` date, -- example: ['2008-03-11', '2009-04-07']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', 'c2caaace-9119-4b2d-a2c3-4040f5a9cf32']\n ENCOUNTER text, -- example: ['5114a5b4-64b8-47b2-82a6-0ce24aae0943', 'bdb926b8-5b6d-4366-bbe9-76fe3f3fbc4f']\n CODE text, -- example: ['8302-2', '29463-7']\n DESCRIPTION text, -- example: ['Body Height', 'Body Weight']\n `VALUE` real, -- example: [166.03, 54.42]\n UNITS text, -- example: ['cm', 'kg']\n CONSTRAINT fk_observations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_observations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE allergies (\n `START` text, -- example: ['3/11/95', '6/15/58']\n STOP text, -- example: ['12/22/14', '4/21/10']\n PATIENT text, -- example: ['00341a88-1cc1-4b39-b0f9-05b0531991a0', '01347a8e-3a92-4f1e-99c9-5d6df0db2331']\n ENCOUNTER text, -- example: ['ddc8a625-07e6-4a02-a616-e0ce07b5f305', '84714823-ee2b-42ba-b79b-6043270cfdc7']\n CODE integer, -- example: [232347008, 300916003]\n DESCRIPTION text, -- example: ['Allergy to dairy product', 'Allergy to tree pollen']\n PRIMARY KEY (PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_allergies_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_allergies_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE immunizations (\n `DATE` date, -- example: ['2007-11-02', '2007-11-03']\n PATIENT text, -- example: ['70cbc79e-dd9d-4e3b-8158-a92d85951f94', '87828e93-e09b-435b-be8e-657361f1c68a']\n ENCOUNTER text, -- example: ['898ab2de-8a71-4fb3-b239-b768b915284a', 'fc8e3271-cc7c-4169-8c99-d46635a86478']\n CODE integer, -- example: [8, 62]\n DESCRIPTION text, -- example: ['Influenza seasonal injectable preserv', 'Td (adult) preservative free']\n PRIMARY KEY (`DATE`, PATIENT, ENCOUNTER, CODE),\n CONSTRAINT fk_immunizations_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_immunizations_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\n\nCREATE TABLE procedures (\n `DATE` date, -- example: ['2013-02-09', '2013-10-19']\n PATIENT text, -- example: ['71949668-1c2e-43ae-ab0a-64654608defb', '96b24072-e1fe-49cd-a22a-6dfb92c3994c']\n ENCOUNTER text, -- example: ['6f2e3935-b203-493e-a9c0-f23e847b9798', 'da4fd626-e74e-4930-91be-7fb3da7ea098']\n CODE integer, -- example: [23426006, 252160004]\n DESCRIPTION text, -- example: ['Measurement of respiratory function (pro', 'Standard pregnancy test']\n REASONDESCRIPTION text, -- example: ['Acute bronchitis (disorder)', 'Normal pregnancy']\n CONSTRAINT fk_procedures_patient FOREIGN KEY (PATIENT) REFERENCES patients (patient),\n CONSTRAINT fk_procedures_encounter FOREIGN KEY (ENCOUNTER) REFERENCES encounters (ID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nid of the patient refers to PATIENT from allergies where STOP is not null; the longest allergy period refers to MAX(SUBTRACT((SUBSTR(STOP, - 2, 1)! = '9' then substr(STOP, length(STOP) - 1) + 2000 end), (SUBSTR(START, - 2, 1) = '9' then substr(START, length(START) - 1) + 1900 else substr(START, length(START) - 1) + 2000 end)));\n\nWhat is the id of the patient who has the longest allergy 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", "split": "train" }