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 person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['Year_3', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n3rd year of their program refers to yearsInProgram = 'Year_3'; professors refers to p_id_dummy\nIn total, all the students in the 3rd year of their program are advised by how many professors?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(DISTINCT T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3'", "index": 500, "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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['Year_3', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n3rd year of their program refers to yearsInProgram = 'Year_3'; professors refers to p_id_dummy\nIn total, all the students in the 3rd year of their program are advised by how many professors?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessor refers to professor = 1; average number of courses = divide(count(taughtBy.course_id), count(taughtBy.p_id) where professor = 1 )\nWhat is the average number of courses taught by a professor?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) AS num FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) AS num FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1", "index": 501, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessor refers to professor = 1; average number of courses = divide(count(taughtBy.course_id), count(taughtBy.p_id) where professor = 1 )\nWhat is the average number of courses taught by a professor?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh-level undergraduate course refers to courseLevel = 'Level_400'; percentage = divide(count(course.course_id) when courseLevel = 'Level_400', count(course.course_id)) * 100%\nCalculate the percentage of high-level undergraduate course.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 courseLevel = 'Level_400' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM course", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN courseLevel = 'Level_400' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM course", "index": 502, "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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh-level undergraduate course refers to courseLevel = 'Level_400'; percentage = divide(count(course.course_id) when courseLevel = 'Level_400', count(course.course_id)) * 100%\nCalculate the percentage of high-level undergraduate course.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstudent refers to advisedBy.p_id; most number in advisor refers to max(count(p_id_dummy))\nDescribe the year in program and in phase status for the student with most number in advisor.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.yearsInProgram, T2.inPhase FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(*) DESC LIMIT 1", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T2.yearsInProgram, T2.inPhase FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(*) DESC LIMIT 1", "index": 503, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstudent refers to advisedBy.p_id; most number in advisor refers to max(count(p_id_dummy))\nDescribe the year in program and in phase status for the student with most number in advisor.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty_eme', 'Faculty', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvised student IDs refers to person.p_id; IDs of employing professor in faculty refers to p_id_dummy and hasPosition = 'Faculty_eme'\nList down the advised student IDs and IDs of employing professor in faculty.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.p_id, T2.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE hasPosition = 'Faculty_eme'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T1.p_id, T2.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE hasPosition = 'Faculty_eme'", "index": 504, "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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty_eme', 'Faculty', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvised student IDs refers to person.p_id; IDs of employing professor in faculty refers to p_id_dummy and hasPosition = 'Faculty_eme'\nList down the advised student IDs and IDs of employing professor in faculty.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncourse IDs and levels refers to course.course_id and courseLevel; person IDs from 40 to 50 refers to taughtBy.p_id between 40 and 50\nList the course IDs and levels of person IDs from 40 to 50.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.course_id, T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id BETWEEN 40 AND 50", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T1.course_id, T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id BETWEEN 40 AND 50", "index": 505, "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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncourse IDs and levels refers to course.course_id and courseLevel; person IDs from 40 to 50 refers to taughtBy.p_id between 40 and 50\nList the course IDs and levels of person IDs from 40 to 50.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nperson ID refers to person.p_id; faculty professor refers to professor = 1 and hasPosition ! = 0\nMention the person ID of faculty professor who taught course ID 104 and the course level.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T3.course_id = 104 AND T1.hasPosition <> 0", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T3.course_id = 104 AND T1.hasPosition <> 0", "index": 506, "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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nperson ID refers to person.p_id; faculty professor refers to professor = 1 and hasPosition ! = 0\nMention the person ID of faculty professor who taught course ID 104 and the course level.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_8', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvisor IDs refers to p_id_dummy and person.p_id where professor = 1; eighth year of program refers to yearsInprogram = 'Year_8'; position status in faculty of those professors refers to hasPosition\nList the advisor IDs for students with eighth year of program and position status in faculty of those professors.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.p_id_dummy, T2.hasPosition FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_8'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T1.p_id_dummy, T2.hasPosition FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_8'", "index": 507, "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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_8', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvisor IDs refers to p_id_dummy and person.p_id where professor = 1; eighth year of program refers to yearsInprogram = 'Year_8'; position status in faculty of those professors refers to hasPosition\nList the advisor IDs for students with eighth year of program and position status in faculty of those professors.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessional or master/graduate courses refers to courseLevel = 'Level_500'\nHow many professional or master/graduate courses 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(*) FROM course WHERE courseLevel = 'Level_500'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM course WHERE courseLevel = 'Level_500'", "index": 508, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessional or master/graduate courses refers to courseLevel = 'Level_500'\nHow many professional or master/graduate courses 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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnon-faculty members refers to hasPosition = 0; are not undergoing the phase of qualifications refers to inPhase = 0\nHow many non-faculty members are not undergoing the phase of qualifications?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(*) FROM person WHERE hasPosition = 0 AND inPhase = 0", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM person WHERE hasPosition = 0 AND inPhase = 0", "index": 509, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnon-faculty members refers to hasPosition = 0; are not undergoing the phase of qualifications refers to inPhase = 0\nHow many non-faculty members are not undergoing the phase of qualifications?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessor refers to taughtBy.p_id; least amount of courses refers to min(count(course_id))\nWhich professor taught the least amount of courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 p_id FROM taughtBy GROUP BY p_id ORDER BY COUNT(course_id) ASC LIMIT 1", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT p_id FROM taughtBy GROUP BY p_id ORDER BY COUNT(course_id) ASC LIMIT 1", "index": 510, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessor refers to taughtBy.p_id; least amount of courses refers to min(count(course_id))\nWhich professor taught the least amount of courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_5', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAdvisor 5 refers to p_id_dummy = 5; are in the 5th year refers to yearsInProgram = 'Year_5'\nAmong the students being advised by Advisor 5, how many students are in the 5th year?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(*) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.p_id_dummy = 5 AND T2.student = 1 AND T2.yearsInProgram = 'Year_5'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.p_id_dummy = 5 AND T2.student = 1 AND T2.yearsInProgram = 'Year_5'", "index": 511, "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 taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_5', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAdvisor 5 refers to p_id_dummy = 5; are in the 5th year refers to yearsInProgram = 'Year_5'\nAmong the students being advised by Advisor 5, how many students are in the 5th year?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessors refers to course.p_id; highest number of professional or master/undergraduate courses refers to max(count(course.course_id)) where courseLevel = 'Level_500'\nWho are the top 5 professors who teaches the highest number of professional or master/undergraduate courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' GROUP BY T2.p_id ORDER BY COUNT(T2.p_id) DESC LIMIT 5", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' GROUP BY T2.p_id ORDER BY COUNT(T2.p_id) DESC LIMIT 5", "index": 512, "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 p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessors refers to course.p_id; highest number of professional or master/undergraduate courses refers to max(count(course.course_id)) where courseLevel = 'Level_500'\nWho are the top 5 professors who teaches the highest number of professional or master/undergraduate courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_1', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvisors refers to p_id_dummy; students in 1st year refers to student = 1 and yearsInProgram = 'Year_1'\nHow many advisors are in charge of advising all the students in 1st year?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_1' AND T2.student = 1", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_1' AND T2.student = 1", "index": 513, "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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n inPhase text, -- example: ['0', 'Post_Quals']\n yearsInProgram text, -- example: ['Year_1', '0', 'Year_2']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nadvisors refers to p_id_dummy; students in 1st year refers to student = 1 and yearsInProgram = 'Year_1'\nHow many advisors are in charge of advising all the students in 1st year?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessors refers to taughtBy.p_id; high-level or harder undergraduate courses  refers to courseLevel = 'Level_400' ; no more than two refers to count(taughtBy.course_id) < = 2\nHow many professors teaches no more than two high-level or harder undergraduate courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(*) FROM ( SELECT COUNT(T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' GROUP BY T2.p_id HAVING COUNT(DISTINCT T1.course_id) <= 2 )", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM ( SELECT COUNT(T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' GROUP BY T2.p_id HAVING COUNT(DISTINCT T1.course_id) <= 2 )", "index": 514, "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 course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['0', 'Faculty']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessors refers to taughtBy.p_id; high-level or harder undergraduate courses  refers to courseLevel = 'Level_400' ; no more than two refers to count(taughtBy.course_id) < = 2\nHow many professors teaches no more than two high-level or harder undergraduate courses?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty_eme', 'Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfaculty employee professors refers to hasPosition = 'Faculty_eme' and professor = 1; high-level or harder undergraduate courses refers to courseLevel = 'Level_400'; professors unique identifying number refers to person.p_id\nBetween the faculty employee professors, how many teaches high-level or harder undergraduate courses? Indicate each of the professors unique identifying number.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_eme' AND T1.professor = 1 AND T3.courseLevel = 'Level_400'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_eme' AND T1.professor = 1 AND T3.courseLevel = 'Level_400'", "index": 515, "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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n hasPosition text, -- example: ['Faculty_eme', 'Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_400', 'Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfaculty employee professors refers to hasPosition = 'Faculty_eme' and professor = 1; high-level or harder undergraduate courses refers to courseLevel = 'Level_400'; professors unique identifying number refers to person.p_id\nBetween the faculty employee professors, how many teaches high-level or harder undergraduate courses? Indicate each of the professors unique identifying number.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessional or master/undergraduate courses refers to courseLevel = 'Level_500'; average number = divide(count(taughtBy.course_id), count(taughtBy.p_id))\nWhat is the average number of professional or master/undergraduate courses being taught by each professor?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500'", "index": 516, "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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n professor integer, -- example: [0, 1]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['0', 'Year_2']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofessional or master/undergraduate courses refers to courseLevel = 'Level_500'; average number = divide(count(taughtBy.course_id), count(taughtBy.p_id))\nWhat is the average number of professional or master/undergraduate courses being taught by each professor?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['Year_2', 'Year_1', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear 1 and year 2 students refers to yearsInProgram = 'Year_1' and yearsInProgram = 'Year_2' and student = 1\nWhat is the sum of year 1 and year 2 students?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(*) FROM person WHERE yearsInProgram = 'Year_1' OR yearsInProgram = 'Year_2'", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT COUNT(*) FROM person WHERE yearsInProgram = 'Year_1' OR yearsInProgram = 'Year_2'", "index": 517, "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 p_id integer, -- person ID, example: [3, 4]\n student integer, -- example: [1, 0]\n yearsInProgram text, -- example: ['Year_2', 'Year_1', '0']\n PRIMARY KEY (p_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear 1 and year 2 students refers to yearsInProgram = 'Year_1' and yearsInProgram = 'Year_2' and student = 1\nWhat is the sum of year 1 and year 2 students?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmember of the faculty refers to hasPosition <> 0, most courses refers to max(count(course.course_id))\nWhich member of the faculty are teaching the most courses and what is his/her general course level?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1", "style": "rule" }
{ "db_id": "computer_student.sqlite", "gt_sql": "SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1", "index": 518, "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 advisedBy (\n p_id integer, -- person id, example: [6, 9]\n p_id_dummy integer, -- person id dummy, example: [5, 7]\n PRIMARY KEY (p_id, p_id_dummy),\n CONSTRAINT fk_advisedby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id),\n CONSTRAINT fk_advisedby_p_id_dummy FOREIGN KEY (p_id_dummy) REFERENCES person (p_id)\n);\n\nCREATE TABLE course (\n course_id integer, -- example: [0, 1]\n courseLevel text, -- example: ['Level_500', 'Level_300']\n PRIMARY KEY (course_id)\n);\n\nCREATE TABLE taughtBy (\n course_id integer, -- example: [0, 1]\n p_id integer, -- person ID, example: [40, 180]\n PRIMARY KEY (course_id, p_id),\n CONSTRAINT fk_taughtby_course_id FOREIGN KEY (course_id) REFERENCES course (course_id),\n CONSTRAINT fk_taughtby_p_id FOREIGN KEY (p_id) REFERENCES person (p_id)\n);\n\nCREATE TABLE person (\n p_id integer, -- person ID, example: [3, 4]\n hasPosition text, -- example: ['Faculty', '0']\n inPhase text, -- example: ['0', 'Post_Quals']\n PRIMARY KEY (p_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmember of the faculty refers to hasPosition <> 0, most courses refers to max(count(course.course_id))\nWhich member of the faculty are teaching the most courses and what is his/her general course level?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 (\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_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 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 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 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 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 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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncoordinate 97,40 refers to longitude = 97 AND latitude = 40;\nHow many events were held at coordinate 97,40?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(event_id) FROM `events` WHERE latitude = 40 AND longitude = 97", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM `events` WHERE latitude = 40 AND longitude = 97", "index": 519, "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 (\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_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 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 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 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 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 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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncoordinate 97,40 refers to longitude = 97 AND latitude = 40;\nHow many events were held at coordinate 97,40?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 (\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_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 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 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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\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 `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 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_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 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 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);\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'; over the age of 50 refers to age > 50;\nHow many female users over the age of 50 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(gender) FROM gender_age WHERE age > 50 AND gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(gender) FROM gender_age WHERE age > 50 AND gender = 'F'", "index": 520, "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 (\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_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 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 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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\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 `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 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_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 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 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);\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'; over the age of 50 refers to age > 50;\nHow many female users over the age of 50 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 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_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 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 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 `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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` 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 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_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:\nactive users refers to is_active = 1;\nHow many active users were there in the event id 2?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(is_active) FROM app_events WHERE event_id = 2 AND is_active = 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(is_active) FROM app_events WHERE event_id = 2 AND is_active = 1", "index": 521, "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 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 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 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 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 `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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F29-32` 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 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_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:\nactive users refers to is_active = 1;\nHow many active users were there in the event id 2?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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_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 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_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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 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 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 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 `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 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:\nyoungest user refers to MIN(age);\nWhat is the gender of the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 gender FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT gender FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )", "index": 522, "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 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 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_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 app_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 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 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 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 `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 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:\nyoungest user refers to MIN(age);\nWhat is the gender of the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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_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);\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 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 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 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_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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost users belong to refers to MAX(COUNT(app_id)); name of category refers to category;\nWhat is the name of the category which most users 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 T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1", "index": 523, "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 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_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);\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 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 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 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_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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost users belong to refers to MAX(COUNT(app_id)); name of category refers to category;\nWhat is the name of the category which most users 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_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 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 (\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 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 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 `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 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 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 `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.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:\nmodel of the device refers to device_model; oldest user refers to MAX(age);\nWhat is the model of the oldest user's device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id ORDER BY T2.age DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id ORDER BY T2.age DESC LIMIT 1", "index": 524, "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 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 (\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 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 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 `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 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 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 `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.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:\nmodel of the device refers to device_model; oldest user refers to MAX(age);\nWhat is the model of the oldest user's device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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_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 `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 `F24-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_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 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: ['Home Decoration', 'Decoration', '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_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_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:\nHow many users are there in the Home Decoration 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(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Home Decoration'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Home Decoration'", "index": 525, "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 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_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 `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 `F24-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_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 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: ['Home Decoration', 'Decoration', '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_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_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:\nHow many users are there in the Home Decoration 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 (\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_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 `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_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_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_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 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 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 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 `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_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:\noldest event refers to MIN(timestamp);\nWhat are the categories of the top 2 oldest events?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T4.category FROM events_relevant AS T1 INNER JOIN app_events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN app_labels AS T3 ON T3.app_id = T2.app_id INNER JOIN label_categories AS T4 ON T3.label_id = T4.label_id ORDER BY T1.timestamp LIMIT 2", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T4.category FROM events_relevant AS T1 INNER JOIN app_events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN app_labels AS T3 ON T3.app_id = T2.app_id INNER JOIN label_categories AS T4 ON T3.label_id = T4.label_id ORDER BY T1.timestamp LIMIT 2", "index": 526, "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_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 `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_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_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_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 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 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 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 `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_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:\noldest event refers to MIN(timestamp);\nWhat are the categories of the top 2 oldest events?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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_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 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 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_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 `F29-32` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest number of users refers to MAX(COUNT(app_id));\nWhich category has the highest number of 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.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1", "index": 527, "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 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 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 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_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 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 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_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 `F29-32` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest number of users refers to MAX(COUNT(app_id));\nWhich category has the highest number of 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 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 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 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_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 `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['MOBA', '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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many users belong to the MOBA 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(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'MOBA'", "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 T2.label_id = T1.label_id WHERE T1.category = 'MOBA'", "index": 528, "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 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 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 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_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 `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['MOBA', '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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many users belong to the MOBA 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 (\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_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 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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlocation = longitude, latitude; on 8th May, 2016 refers to `timestamp` LIKE '2016-05-08%';\nWhat were the locations of the events on 8th 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 longitude, latitude FROM `events` WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-08'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT longitude, latitude FROM `events` WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-08'", "index": 529, "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 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 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_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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlocation = longitude, latitude; on 8th May, 2016 refers to `timestamp` LIKE '2016-05-08%';\nWhat were the locations of the events on 8th 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\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);\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 `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 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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 30th April, 2016 refers to `timestamp` LIKE '2016-04-30%';\nHow many events were there on 30th April, 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 COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-04-30'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-04-30'", "index": 530, "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 `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\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);\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 `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 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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 30th April, 2016 refers to `timestamp` LIKE '2016-04-30%';\nHow many events were there on 30th April, 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 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 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 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 `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_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_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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['F27-28', 'M27-28', '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: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['F27-28', 'M27-28', '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_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 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:\nratio = DIVIDE(COUNT(device_id WHERE gender = 'M' AND `group` = 'M27-28'), COUNT(device_id WHERE gender = 'F' AND `group` = 'F27-28')); 27-28 age group refers to `group` = 'F27-28';\nWhat is the ratio of male and female users in 27-28 age group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(gender = 'M' AND `group` = 'M27-28', 1, 0)) / SUM(IIF(gender = 'F' AND `group` = 'F27-28', 1, 0)) AS r FROM gender_age", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(gender = 'M' AND `group` = 'M27-28', 1, 0)) / SUM(IIF(gender = 'F' AND `group` = 'F27-28', 1, 0)) AS r FROM gender_age", "index": 531, "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_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 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 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 `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_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_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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['F27-28', 'M27-28', '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: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['F27-28', 'M27-28', '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_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 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:\nratio = DIVIDE(COUNT(device_id WHERE gender = 'M' AND `group` = 'M27-28'), COUNT(device_id WHERE gender = 'F' AND `group` = 'F27-28')); 27-28 age group refers to `group` = 'F27-28';\nWhat is the ratio of male and female users in 27-28 age group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 (\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 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_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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` 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_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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['online shopping', 'online malls', '\"online shopping', '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:\nWhat are the labels' IDs of online shopping and online malls categories?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 label_id FROM label_categories WHERE category IN ('online shopping', 'online malls')", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT label_id FROM label_categories WHERE category IN ('online shopping', 'online malls')", "index": 532, "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 (\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 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_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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n age integer, -- example: [24, 36]\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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` 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_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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['online shopping', 'online malls', '\"online shopping', '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:\nWhat are the labels' IDs of online shopping and online malls categories?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 sample_submission (\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 `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_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 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 label_categories (\n label_id integer, -- example: [1, 2]\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 `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:\nmodels refers to device_model; on 5th May, 2016 refers to timestamp LIKE '2016-05-05%'; coordinates of (112,44) refers to longitude = 112 AND latitude = 44;\nDescribe the phone brands and models of the users who participated in events on 5th May, 2016 at the coordinates of (112,44).\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.timestamp LIKE '2016-05-05%' AND T1.longitude = 112 AND T1.latitude = 44", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT DISTINCT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.timestamp LIKE '2016-05-05%' AND T1.longitude = 112 AND T1.latitude = 44", "index": 533, "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_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 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 sample_submission (\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 `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_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 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 label_categories (\n label_id integer, -- example: [1, 2]\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 `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:\nmodels refers to device_model; on 5th May, 2016 refers to timestamp LIKE '2016-05-05%'; coordinates of (112,44) refers to longitude = 112 AND latitude = 44;\nDescribe the phone brands and models of the users who participated in events on 5th May, 2016 at the coordinates of (112,44).\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.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 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 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 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 `F24-26` 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nDescribe the device user gender and age of the event ID of 15251.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.gender, T1.age FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.event_id = 15251", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.gender, T1.age FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.event_id = 15251", "index": 534, "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 events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.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 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 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 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 `F24-26` 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nDescribe the device user gender and age of the event ID of 15251.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['HTC', '小米', 'vivo']\n device_model text, -- example: ['Butterfly', 'Butterfly s', '红米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 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 (\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 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 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 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 `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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHTC Butterfly refers to phone_brand = 'HTC' AND device_model = 'Butterfly'; females refers to gender = 'F';\nAmong HTC Butterfly phone users, list any five devices' IDs used by females.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.device_id FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Butterfly' AND T2.gender = 'F' AND T1.phone_brand = 'HTC' LIMIT 5", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T2.device_id FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Butterfly' AND T2.gender = 'F' AND T1.phone_brand = 'HTC' LIMIT 5", "index": 535, "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: ['HTC', '小米', 'vivo']\n device_model text, -- example: ['Butterfly', 'Butterfly s', '红米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 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 (\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 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 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 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 `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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHTC Butterfly refers to phone_brand = 'HTC' AND device_model = 'Butterfly'; females refers to gender = 'F';\nAmong HTC Butterfly phone users, list any five devices' IDs used by females.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['science fiction', 'science', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_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 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 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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` 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_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 (\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many app IDs were included under science fiction 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(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'science fiction'", "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 T2.label_id = T1.label_id WHERE T1.category = 'science fiction'", "index": 536, "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: ['science fiction', 'science', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_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 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 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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M22-` 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_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 (\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many app IDs were included under science fiction 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 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 PRIMARY KEY (label_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F43+` real, -- example: [0.0833]\n `M29-31` 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 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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_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 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 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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['LG', '小米', 'vivo']\n device_model text, -- example: ['L70', '红米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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLG L70 refers to phone_brand = 'LG' AND device_model = 'L70';\nWhat are the ages and genders of the LG L70 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 T2.age, T2.gender FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG' AND T1.device_model = 'L70'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T2.age, T2.gender FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG' AND T1.device_model = 'L70'", "index": 537, "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 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 `F43+` real, -- example: [0.0833]\n `M29-31` 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 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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (app_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 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 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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['LG', '小米', 'vivo']\n device_model text, -- example: ['L70', '红米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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLG L70 refers to phone_brand = 'LG' AND device_model = 'L70';\nWhat are the ages and genders of the LG L70 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 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 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 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 (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_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 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 `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Industry tag', '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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = DIVIDE(MULTIPLY(CONCAT(COUNT(app_id WHERE category = 'Industry tag'), 100), COUNT(app_id)),'%');\nCalculate the percentage of the app user IDs under Industry tag 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 SUM(IIF(T1.category = 'Industry tag', 1, 0)) * 100 / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.category = 'Industry tag', 1, 0)) * 100 / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id", "index": 538, "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 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 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 (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_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 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 `M39+` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Industry tag', '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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = DIVIDE(MULTIPLY(CONCAT(COUNT(app_id WHERE category = 'Industry tag'), 100), COUNT(app_id)),'%');\nCalculate the percentage of the app user IDs under Industry tag 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` 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 PRIMARY KEY (device_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: ['Nexus 5', 'Nexus 7', 'Nexus 4', 'Nexus S', '红米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 `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_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: ['F', 'M']\n age integer, -- example: [24, 36]\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 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_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: ['model', '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 PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (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:\nLG brand refers to phone_brand = 'LG'; percentage = DIVIDE(MULTIPLY(CONCAT(COUNT(device_id WHERE device_model = 'Nexus 5'), 100), COUNT(device_id)),'%'); ratio = DIVIDE(COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'M'), COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'F')); Nexus 5 model refers to device_model = 'Nexus 5';\nAmong the LG brand users, calculate the percentage of the Nexus 5 model user. What is the ratio of male and female users of it?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.device_model = 'Nexus 5', 1, 0)) * 100 / COUNT(T1.device_id) AS per , SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'M', 1, 0)) / SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'F', 1, 0)) AS r FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.device_model = 'Nexus 5', 1, 0)) * 100 / COUNT(T1.device_id) AS per , SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'M', 1, 0)) / SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'F', 1, 0)) AS r FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG'", "index": 539, "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` 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 PRIMARY KEY (device_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: ['Nexus 5', 'Nexus 7', 'Nexus 4', 'Nexus S', '红米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 `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_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: ['F', 'M']\n age integer, -- example: [24, 36]\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 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_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: ['model', '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 PRIMARY KEY (event_id, app_id),\n CONSTRAINT fk_app_events_event_id FOREIGN KEY (event_id) REFERENCES events (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:\nLG brand refers to phone_brand = 'LG'; percentage = DIVIDE(MULTIPLY(CONCAT(COUNT(device_id WHERE device_model = 'Nexus 5'), 100), COUNT(device_id)),'%'); ratio = DIVIDE(COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'M'), COUNT(device_id WHERE device_model = 'Nexus 5' AND gender = 'F')); Nexus 5 model refers to device_model = 'Nexus 5';\nAmong the LG brand users, calculate the percentage of the Nexus 5 model user. What is the ratio of male and female users of it?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `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 `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 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 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 `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 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 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 (\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nHow many users of the app were not active when event no.2 happened?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(event_id) FROM app_events WHERE event_id = 2 AND is_active = 0", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM app_events WHERE event_id = 2 AND is_active = 0", "index": 540, "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 `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 `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 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 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 `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 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 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 (\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nHow many users of the app were not active when event no.2 happened?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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_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 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_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 (\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 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 `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:\nin 2016 refers to `timestamp` LIKE '2016%';\nHow many events in total have happened on the devices in 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 COUNT(event_id) FROM `events` WHERE SUBSTR(`timestamp`, 1, 4) = '2016'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM `events` WHERE SUBSTR(`timestamp`, 1, 4) = '2016'", "index": 541, "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 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 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 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_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 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_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 (\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 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 `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:\nin 2016 refers to `timestamp` LIKE '2016%';\nHow many events in total have happened on the devices in 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 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_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 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 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 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 `M32-38` 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 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 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 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:\noldest device user refers to MAX(age);\nWhat is the age of the oldest device user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 MAX(age) FROM gender_age", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT MAX(age) FROM gender_age", "index": 542, "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 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 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 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 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 `M32-38` 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 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 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 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:\noldest device user refers to MAX(age);\nWhat is the age of the oldest device user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_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: ['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_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_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 category text, -- example: ['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 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 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 (\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 `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 `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:\nfemale refers to gender = 'F'; under 30 refers to age < 30;\nAmong the female users of the devices, how many of them are under 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(device_id) FROM gender_age WHERE age < 30 AND gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM gender_age WHERE age < 30 AND gender = 'F'", "index": 543, "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_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: ['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_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_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 category text, -- example: ['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 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 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 (\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 `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 `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:\nfemale refers to gender = 'F'; under 30 refers to age < 30;\nAmong the female users of the devices, how many of them are under 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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_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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\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 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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\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_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 `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 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 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);\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: ['F', 'M']\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:\nGalaxy Note 2 refers to device_model = 'Galaxy Note 2'; female refers to gender = 'F';\nAmong the users who use a Galaxy Note 2, how many of them are female?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T2.gender = 'F' AND T1.device_model = 'Galaxy Note 2'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T2.gender = 'F' AND T1.device_model = 'Galaxy Note 2'", "index": 544, "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_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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_id)\n);\n\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 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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\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_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 `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 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 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);\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: ['F', 'M']\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:\nGalaxy Note 2 refers to device_model = 'Galaxy Note 2'; female refers to gender = 'F';\nAmong the users who use a Galaxy Note 2, how many of them are female?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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: ['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);\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 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 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 `M22-` 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 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_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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nGalaxy Note 2 refers to device_model = 'Galaxy Note 2';\nPlease list the ages of all the users who use a Galaxy Note 2.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.age FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Galaxy Note 2'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T2.age FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Galaxy Note 2'", "index": 545, "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 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: ['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);\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 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 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 `M22-` 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 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_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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nGalaxy Note 2 refers to device_model = 'Galaxy Note 2';\nPlease list the ages of all the users who use a Galaxy Note 2.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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: ['Securities', '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 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 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);\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 `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:\nHow many app users belong to the category of Securities?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Securities'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Securities'", "index": 546, "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 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 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 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: ['Securities', '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 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 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);\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 `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:\nHow many app users belong to the category of Securities?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_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 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 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 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_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 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 age integer, -- example: [24, 36]\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 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 `F29-32` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\napp no. refers to app_id; app_id = 1977658975649780000;\nTo which categories does app user no.1977658975649780000 belong?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 = 1977658975649780000", "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 = 1977658975649780000", "index": 547, "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_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 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 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 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_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 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 age integer, -- example: [24, 36]\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 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 `F29-32` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\napp no. refers to app_id; app_id = 1977658975649780000;\nTo which categories does app user no.1977658975649780000 belong?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 `M27-28` 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 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);\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_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 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);\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 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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nPlease list the categories of the app users who are not active when event no.2 happened.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.event_id = 2 AND T3.is_active = 0", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT DISTINCT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.event_id = 2 AND T3.is_active = 0", "index": 548, "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 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 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 `M27-28` 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 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);\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_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 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);\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 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 (\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nPlease list the categories of the app users who are not active when event no.2 happened.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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 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 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 `F43+` 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 (\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 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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntime refers to timestamp; event no. refers to event_id; event_id = '2'; vivo device refers to phone_brand = 'vivo';\nPlease list the time when event no.2 happened on a vivo device.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE T2.phone_brand = 'vivo' AND T1.event_id = '2'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.timestamp FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE T2.phone_brand = 'vivo' AND T1.event_id = '2'", "index": 549, "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 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 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 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 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 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 `F43+` 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 (\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 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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntime refers to timestamp; event no. refers to event_id; event_id = '2'; vivo device refers to phone_brand = 'vivo';\nPlease list the time when event no.2 happened on a vivo device.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `group` text, -- example: ['M23-26', 'M32-38']\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 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_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 `F33-42` real, -- example: [0.0833]\n `M27-28` 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 `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_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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvivo devices refers to phone_brand = 'vivo'; in the year 2016 refers to year(timestamp) = 2016;\nHow many events in total have happened on all the vivo devices in the year 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 COUNT(T1.event_id) FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE STRFTIME('%Y', T1.timestamp) = '2016' AND T2.phone_brand = 'vivo'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.event_id) FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE STRFTIME('%Y', T1.timestamp) = '2016' AND T2.phone_brand = 'vivo'", "index": 550, "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 `group` text, -- example: ['M23-26', 'M32-38']\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 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_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 `F33-42` real, -- example: [0.0833]\n `M27-28` 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 `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_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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvivo devices refers to phone_brand = 'vivo'; in the year 2016 refers to year(timestamp) = 2016;\nHow many events in total have happened on all the vivo devices in the year 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 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 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 (\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_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 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 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 (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M23-26', '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 `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 `M23-26` 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvivo device refers to phone_brand = 'vivo'; percentage = MULTIPLY(DIVIDE(COUNT(phone_brand = 'vivo WHERE group = 'M23-26), COUNT(phone_brand = 'vivo)), 100); M23-26 user group refers to group = 'M23-26';\nAmong all the users who use a vivo device, what is the percentage of the users in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.`group` = 'M23-26', 1.0, 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.`group` = 'M23-26', 1.0, 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": 551, "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 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 (\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_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 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 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 (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M23-26', '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 `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 `M23-26` 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvivo device refers to phone_brand = 'vivo'; percentage = MULTIPLY(DIVIDE(COUNT(phone_brand = 'vivo WHERE group = 'M23-26), COUNT(phone_brand = 'vivo)), 100); M23-26 user group refers to group = 'M23-26';\nAmong all the users who use a vivo device, what is the percentage of the users in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['F27-28', 'M23-26', 'M32-38']\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 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 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_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 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 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 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: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['F27-28', '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 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:\nfemale refers to gender = 'F'; age group of 27 to 28 refers to `group` = 'F27-28';\nHow many female users belong to the age group of 27 to 28?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 gender_age WHERE `group` = 'F27-28' AND gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM gender_age WHERE `group` = 'F27-28' AND gender = 'F'", "index": 552, "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: ['F', 'M']\n age integer, -- example: [24, 36]\n `group` text, -- example: ['F27-28', 'M23-26', 'M32-38']\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 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 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_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 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 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 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: ['F', 'M']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['F27-28', '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 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:\nfemale refers to gender = 'F'; age group of 27 to 28 refers to `group` = 'F27-28';\nHow many female users belong to the age group of 27 to 28?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F43+` 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 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 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 `group` text, -- example: ['M23-26', 'M32-38']\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 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 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 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest user refers to MAX(age); male refers to gender = 'M';\nWhat is the age of the oldest male user of 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 MAX(age) FROM gender_age WHERE gender = 'M'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT MAX(age) FROM gender_age WHERE gender = 'M'", "index": 553, "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 `F23-` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F43+` 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 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 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 `group` text, -- example: ['M23-26', 'M32-38']\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 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 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 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest user refers to MAX(age); male refers to gender = 'M';\nWhat is the age of the oldest male user of 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 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 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 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 `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ninstalled refers to is_installed = 1; not active refers to is_active = 0;\nHow many users installed the app but are not 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(app_id) FROM app_events WHERE is_installed = 1 AND is_active = 0", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(app_id) FROM app_events WHERE is_installed = 1 AND is_active = 0", "index": 554, "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 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 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 `F33-42` real, -- example: [0.0833]\n `M22-` real, -- example: [0.0833]\n `M27-28` 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 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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ninstalled refers to is_installed = 1; not active refers to is_active = 0;\nHow many users installed the app but are not 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 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 `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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'Phone', 'phone', '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 `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 `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\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: ['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 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 (\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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nphone models refers to device_model; OPPO brand refers to phone_brand = 'OPPO';\nList at least 15 phone models released under the OPPO brand.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_model FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO' LIMIT 15", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT device_model FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO' LIMIT 15", "index": 555, "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_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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'Phone', 'phone', '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 `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 `M23-26` real, -- example: [0.0833]\n `M27-28` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\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: ['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 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 (\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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nphone models refers to device_model; OPPO brand refers to phone_brand = 'OPPO';\nList at least 15 phone models released under the OPPO brand.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 (\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: ['game-Art Style', 'game-game type', 'game-Game themes']\n PRIMARY KEY (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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 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 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 `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many users belong to \"game-Art Style\" 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(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id WHERE T2.category = 'game-Art Style'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id WHERE T2.category = 'game-Art Style'", "index": 556, "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 (\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: ['game-Art Style', 'game-game type', 'game-Game themes']\n PRIMARY KEY (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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 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 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 `F29-32` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many users belong to \"game-Art Style\" 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 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 `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 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 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 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_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 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 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 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 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 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:\nbrand of the device refers to phone_brand; youngest user refers to MIN(age);\nWhat is the brand of the youngest user's device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_model FROM phone_brand_device_model2 WHERE device_id IN ( SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age ) )", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT device_model FROM phone_brand_device_model2 WHERE device_id IN ( SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age ) )", "index": 557, "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 `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 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 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 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_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 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 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 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 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 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:\nbrand of the device refers to phone_brand; youngest user refers to MIN(age);\nWhat is the brand of the youngest user's device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 `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 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 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_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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` 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:\nlowest number of users refers to MIN(COUNT(label_id));\nList at least 3 categories with the lowest number of 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 T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id ORDER BY T2.label_id LIMIT 3", "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 ORDER BY T2.label_id LIMIT 3", "index": 558, "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 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 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 `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 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 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_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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `F43+` 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:\nlowest number of users refers to MIN(COUNT(label_id));\nList at least 3 categories with the lowest number of 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 `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 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 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 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_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 `F24-26` 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 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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Ace Plus', 'Galaxy Ace', 'Galaxy Ace 3', 'Galaxy Ace 2', 'Galaxy Ace 4', 'Galaxy A7']\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'; Galaxy Ace Plus refers to device_model = 'Galaxy Ace Plus';\nHow many male users use the Galaxy Ace Plus 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 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 Ace Plus' 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 Ace Plus' AND T1.gender = 'M'", "index": 559, "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 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 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 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_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 `F24-26` 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 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_all (\n app_id integer, -- example: [-9223281467940916832, -9222877069545393219]\n PRIMARY KEY (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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['小米', 'vivo']\n device_model text, -- example: ['Galaxy Ace Plus', 'Galaxy Ace', 'Galaxy Ace 3', 'Galaxy Ace 2', 'Galaxy Ace 4', 'Galaxy A7']\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'; Galaxy Ace Plus refers to device_model = 'Galaxy Ace Plus';\nHow many male users use the Galaxy Ace Plus 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_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 (\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 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 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 `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: ['OPPO', '小米', '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 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 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: ['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 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);\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; most OPPO users refers to MAX(COUNT(phone_brand = 'OPPO')); OPPO users refers to phone_brand = 'OPPO';\nWhat is the age group of most OPPO 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.`group` FROM ( SELECT T1.`group`, COUNT(T1.`group`) AS num 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' GROUP BY T1.`group` ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.`group` FROM ( SELECT T1.`group`, COUNT(T1.`group`) AS num 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' GROUP BY T1.`group` ) AS T ORDER BY T.num DESC LIMIT 1", "index": 560, "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 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 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 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 `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: ['OPPO', '小米', '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 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 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: ['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 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);\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; most OPPO users refers to MAX(COUNT(phone_brand = 'OPPO')); OPPO users refers to phone_brand = 'OPPO';\nWhat is the age group of most OPPO 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 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 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_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 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 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 `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 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 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 `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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndevice models that are commonly used refers to MAX(COUNT(device_model)); female refers to gender = 'F';\nList at least 5 device models that are commonly used by female 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.device_model FROM ( SELECT T2.device_model, COUNT(T2.device_model) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 5", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.device_model FROM ( SELECT T2.device_model, COUNT(T2.device_model) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 5", "index": 561, "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_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 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 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 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 `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 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 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 `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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndevice models that are commonly used refers to MAX(COUNT(device_model)); female refers to gender = 'F';\nList at least 5 device models that are commonly used by female 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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['90s Japanese comic', '80s Japanese comic', '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 age integer, -- example: [24, 36]\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 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 `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 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 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);\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 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 longitude real, -- example: [121.0, 104.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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nratio in percentage = DIVIDE(SUM(IF(category = '80s Japanese comic',1,0)), COUNT(app_id)) as '80s'; DIVIDE(SUM(IF(category = '90s Japanese comic',1,0)), COUNT(app_id)) as '90s'; 80s Japanese comic refers to category = '80s Japanese comic'; 90s Japanese comic refers to category = '80s Japanese comic';\nCalculate the ratio in percentage between the average number of app users belonging to \"80s Japanese comic\" and \"90s Japanese comic\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 = '80s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J8 , SUM(IIF(T1.category = '90s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J9 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 = '80s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J8 , SUM(IIF(T1.category = '90s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J9 FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id", "index": 562, "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: ['90s Japanese comic', '80s Japanese comic', '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 age integer, -- example: [24, 36]\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 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 `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 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 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);\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 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 longitude real, -- example: [121.0, 104.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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nratio in percentage = DIVIDE(SUM(IF(category = '80s Japanese comic',1,0)), COUNT(app_id)) as '80s'; DIVIDE(SUM(IF(category = '90s Japanese comic',1,0)), COUNT(app_id)) as '90s'; 80s Japanese comic refers to category = '80s Japanese comic'; 90s Japanese comic refers to category = '80s Japanese comic';\nCalculate the ratio in percentage between the average number of app users belonging to \"80s Japanese comic\" and \"90s Japanese comic\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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_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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (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: ['R815T', '红米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_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: ['F', 'M']\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);\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'; percentage = DIVIDE(SUM(IF(phone_brand = 'OPPO',1,0)), SUM(IF(device_id = 'R815T',1,0))); R815T refers to device_id = 'R815T';\nAmong the female users that uses OPPO as their phone brand, what is the percentage of them of the user that uses R815T model to install 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(T1.phone_brand = 'OPPO', 1, 0)) / SUM(IIF(T1.device_id = 'R815T', 1, 0)) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.phone_brand = 'OPPO', 1, 0)) / SUM(IIF(T1.device_id = 'R815T', 1, 0)) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F'", "index": 563, "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 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_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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F33-42` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M29-31` real, -- example: [0.0833]\n PRIMARY KEY (device_id)\n);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['model', 'Phone', 'phone', 'game-game type', 'game-Game themes']\n PRIMARY KEY (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: ['R815T', '红米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_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: ['F', 'M']\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);\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'; percentage = DIVIDE(SUM(IF(phone_brand = 'OPPO',1,0)), SUM(IF(device_id = 'R815T',1,0))); R815T refers to device_id = 'R815T';\nAmong the female users that uses OPPO as their phone brand, what is the percentage of them of the user that uses R815T model to install 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 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 `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 `F33-42` 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 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 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 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: ['小米', '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 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 `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.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:\nevent no. refers to event_id; event_id = '887711';\nGive the time stamp for event No.887711.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 timestamp FROM events WHERE event_id = '887711'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT timestamp FROM events WHERE event_id = '887711'", "index": 564, "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 gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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 `F33-42` 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 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 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 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: ['小米', '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 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 `timestamp` datetime, -- example: ['2016-05-01 00:55:25.0', '2016-05-01 00:54:12.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:\nevent no. refers to event_id; event_id = '887711';\nGive the time stamp for event No.887711.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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 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 `M23-26` real, -- example: [0.0833]\n `M27-28` 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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (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 `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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2016/5/6 refers to timestamp = '2016/5/6 XX:XX:XX';\nProvide the number of events that happened on 2016/5/6.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-06'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-06'", "index": 565, "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 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 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 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 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 `M23-26` real, -- example: [0.0833]\n `M27-28` 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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (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 `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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2016/5/6 refers to timestamp = '2016/5/6 XX:XX:XX';\nProvide the number of events that happened on 2016/5/6.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `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 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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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 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 (\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat 23:55:16 on 2016/5/7 refers to timestamp = '2016/5/7 23:55:16'; location coordinate (113, 28) refers to longitude = '113' AND latitude = '28';\nFor the event which happened at 23:55:16 on 2016/5/7, in the location coordinate(113, 28), on what device did it happen? Give the name of the 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 T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.event_id WHERE T2.longitude = '113' AND T2.latitude = '28' AND T2.timestamp = '2016-05-07 23:55:16'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.event_id WHERE T2.longitude = '113' AND T2.latitude = '28' AND T2.timestamp = '2016-05-07 23:55:16'", "index": 566, "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 `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 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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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 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 (\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat 23:55:16 on 2016/5/7 refers to timestamp = '2016/5/7 23:55:16'; location coordinate (113, 28) refers to longitude = '113' AND latitude = '28';\nFor the event which happened at 23:55:16 on 2016/5/7, in the location coordinate(113, 28), on what device did it happen? Give the name of the 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 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_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 `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 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 `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 (\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 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);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-Fishing', 'game', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngame-Fishing refers to category = 'game-Fishing';\nGive the number of \"game-Fishing\" apps.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 = 'game-Fishing'", "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 = 'game-Fishing'", "index": 567, "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 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 `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 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 `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 (\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 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);\n\nCREATE TABLE label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['game-Fishing', 'game', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngame-Fishing refers to category = 'game-Fishing';\nGive the number of \"game-Fishing\" apps.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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 `M22-` 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 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 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 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_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n30-year-old refers to age = '30'; active refers to is_active = 1; on 2016/5/2 refers to timestamp = '2016/5/2 XX:XX:XX';\nGive the number of 30-year-old users who were active in the events on 2016/5/2.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.device_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-02' AND T1.is_active = 1 AND T3.age = '30'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T3.device_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-02' AND T1.is_active = 1 AND T3.age = '30'", "index": 568, "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_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 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 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 `M22-` 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 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 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 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_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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n30-year-old refers to age = '30'; active refers to is_active = 1; on 2016/5/2 refers to timestamp = '2016/5/2 XX:XX:XX';\nGive the number of 30-year-old users who were active in the events on 2016/5/2.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `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 (\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 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_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 `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_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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat 23:33:34 on 2016/5/6 refers to timestamp = '2016/5/6 23:33:34'; installed refers to is_installed = '1';\nFor the event which happened at 23:33:34 on 2016/5/6, how many installed apps were involved?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.event_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE SUBSTR(T2.`timestamp`, 1, 10) = '2016-05-06' AND T1.is_installed = '1'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.event_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE SUBSTR(T2.`timestamp`, 1, 10) = '2016-05-06' AND T1.is_installed = '1'", "index": 569, "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `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 (\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 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_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 `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_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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nat 23:33:34 on 2016/5/6 refers to timestamp = '2016/5/6 23:33:34'; installed refers to is_installed = '1';\nFor the event which happened at 23:33:34 on 2016/5/6, how many installed apps were involved?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['E派', '小米', '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);\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 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);\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 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 `M23-26` real, -- example: [0.0833]\n `M27-28` 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: ['F', 'M']\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);\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'; E派 brand refers to phone_brand = 'E派';\nGive the number of female users of \"E派\" brand devices.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.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.phone_brand = 'E派'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T2.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T2.phone_brand = 'E派'", "index": 570, "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 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 phone_brand_device_model2 (\n device_id integer, -- example: [-9223321966609553846, -9223067244542181226]\n phone_brand text, -- example: ['E派', '小米', '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);\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 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);\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 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 `M23-26` real, -- example: [0.0833]\n `M27-28` 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: ['F', 'M']\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);\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'; E派 brand refers to phone_brand = 'E派';\nGive the number of female users of \"E派\" brand devices.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` 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 `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 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 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);\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 S5', 'Galaxy S', 'S5', 'Galaxy S7', '红米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);\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';\nHow many male users of the \"Galaxy S5\" 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 COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T1.device_model = 'Galaxy S5' AND T2.gender = 'M'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T1.device_model = 'Galaxy S5' AND T2.gender = 'M'", "index": 571, "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 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_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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` 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 `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 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 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);\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 S5', 'Galaxy S', 'S5', 'Galaxy S7', '红米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);\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';\nHow many male users of the \"Galaxy S5\" 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 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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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_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);\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 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 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:\nbrand vivo refers to phone_brand = 'vivo';\nHow many devices are of the brand 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 COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo'", "index": 572, "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_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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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_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);\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 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 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:\nbrand vivo refers to phone_brand = 'vivo';\nHow many devices are of the brand 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 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);\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 `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_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: ['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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F29-32` 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 `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 `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_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);\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 device refers to device_id; youngest user refers to MIN(age);\nWhat is the ID of the device used by the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 WHERE age = ( SELECT MIN(age) FROM gender_age )", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )", "index": 573, "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 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 (\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 `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_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: ['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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F29-32` 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 `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 `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_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);\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 device refers to device_id; youngest user refers to MIN(age);\nWhat is the ID of the device used by the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `M23-26` 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 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 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_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_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: ['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_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_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 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'; over 30 refers to age > 30;\nAmong the female users of the devices, how many of them are over 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(device_id) FROM gender_age WHERE age > 30 AND gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM gender_age WHERE age > 30 AND gender = 'F'", "index": 574, "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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `M23-26` 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 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 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_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_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: ['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_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_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 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'; over 30 refers to age > 30;\nAmong the female users of the devices, how many of them are over 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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: ['F', 'M']\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 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 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: ['F', 'M']\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 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: ['小米', '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 PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMAX(Age) AND gender = 'M' means that the oldest device user is male; MAX(Age) AND gender = 'F' means that the oldest device user is female;\nIs the oldest device user male or female?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 gender FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age )", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT gender FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age )", "index": 575, "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: ['F', 'M']\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 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 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: ['F', 'M']\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 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: ['小米', '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 PRIMARY KEY (event_id)\n);\n\nCREATE TABLE sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMAX(Age) AND gender = 'M' means that the oldest device user is male; MAX(Age) AND gender = 'F' means that the oldest device user is female;\nIs the oldest device user male or female?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['F', 'M']\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 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 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 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 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 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_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 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 `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` 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 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:\nyoungest refers to MIN(age); female refers to gender = 'F';\nWhat is the age of the youngest female device user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 MIN(age) FROM gender_age WHERE gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT MIN(age) FROM gender_age WHERE gender = 'F'", "index": 576, "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: ['F', 'M']\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 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 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 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 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 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_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 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 `F24-26` real, -- example: [0.0833]\n `F27-28` real, -- example: [0.0833]\n `F33-42` 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 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:\nyoungest refers to MIN(age); female refers to gender = 'F';\nWhat is the age of the youngest female device user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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 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 PRIMARY KEY (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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\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:\nvivo device refers to phone_brand = 'vivo'; youngest refers to MIN(age);\nAmong all the users who use a vivo device, what is the age of the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.age 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' ORDER BY T1.age LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.age 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' ORDER BY T1.age LIMIT 1", "index": 577, "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 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 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 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 PRIMARY KEY (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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F33-42` real, -- example: [0.0833]\n `M32-38` real, -- example: [0.0833]\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:\nvivo device refers to phone_brand = 'vivo'; youngest refers to MIN(age);\nAmong all the users who use a vivo device, what is the age of the youngest user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\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 `M23-26` 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 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 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 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 (\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:55:27.0', '2016-05-01 00:55:22.0', '2016-05-01 00:55:28.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_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_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:\non 2016/5/1 at 0:55:25 refers to timestamp = '2016-05-01 00:55:25';\nFor the device with an event occurring on 2016/5/1 at 0:55:25, what is the gender of its user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.gender FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-01 00:55:25'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.gender FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-01 00:55:25'", "index": 578, "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 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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\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 `M23-26` 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 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 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 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 (\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:55:27.0', '2016-05-01 00:55:22.0', '2016-05-01 00:55:28.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_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_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:\non 2016/5/1 at 0:55:25 refers to timestamp = '2016-05-01 00:55:25';\nFor the device with an event occurring on 2016/5/1 at 0:55:25, what is the gender of its user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `M23-26` 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 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 gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M23-26', '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 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 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_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 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 `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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin 2016 refers to year(timestamp) = 2016; M23-26 user group refers to `group` = 'M23-26';\nAmong the devices with an event occurring in 2016, how many of them are owned by a user in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 events AS T2 ON T1.device_id = T2.device_id WHERE STRFTIME('%Y', T2.timestamp) = '2016' AND T1.`group` = 'M23-26'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE STRFTIME('%Y', T2.timestamp) = '2016' AND T1.`group` = 'M23-26'", "index": 579, "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `M23-26` 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 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 gender text, -- example: ['M', 'F']\n age integer, -- example: [29, 31]\n `group` text, -- example: ['M23-26', '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 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 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_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 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 `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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin 2016 refers to year(timestamp) = 2016; M23-26 user group refers to `group` = 'M23-26';\nAmong the devices with an event occurring in 2016, how many of them are owned by a user in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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_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 `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 `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 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 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 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 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: ['M23-26', '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 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:\nbrand of the device refers to phone_brand; M23-26 user group refers to `group` = 'M23-26';\nWhat is the brand of the device used by the most users in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'M23-26' GROUP BY T2.phone_brand ) 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(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'M23-26' GROUP BY T2.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1", "index": 580, "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 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 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_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 `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 `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 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 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 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 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: ['M23-26', '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 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:\nbrand of the device refers to phone_brand; M23-26 user group refers to `group` = 'M23-26';\nWhat is the brand of the device used by the most users in the M23-26 user group?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['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 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 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 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 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 `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 PRIMARY KEY (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_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: ['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 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:\nmodels of the devices refers to device_model; female refers to gender = 'F';\nPlease list all the models of the devices used by a female user.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F'", "index": 581, "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: ['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 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 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 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 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 `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 PRIMARY KEY (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_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: ['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 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:\nmodels of the devices refers to device_model; female refers to gender = 'F';\nPlease list all the models of the devices used by a female user.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_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 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 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 `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 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 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 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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Property Industry 1.0', 'Property Industry new', 'Property Industry 2.0', '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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nAmong the app users who were not active when event no.2 happened, how many of them belong to the category Property Industry 1.0?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.is_active = 0 AND T1.category = 'Property Industry 1.0' AND T3.event_id = 2", "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 INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.is_active = 0 AND T1.category = 'Property Industry 1.0' AND T3.event_id = 2", "index": 582, "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_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 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 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 `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 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 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 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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Property Industry 1.0', 'Property Industry new', 'Property Industry 2.0', '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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot active refers to is_active = 0; event no. refers to event_id; event_id = 2;\nAmong the app users who were not active when event no.2 happened, how many of them belong to the category Property Industry 1.0?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M23-26` 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 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 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: ['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 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 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 PRIMARY KEY (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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale users refers to gender = 'F'; most female users refers to MAX(COUNT(gender = 'F')); over 30 refers to age > 30;\nWhat is the device model used by the most female users over 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T.device_model FROM ( SELECT T2.device_model, COUNT(T2.device_model) 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 > 30 AND T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.device_model FROM ( SELECT T2.device_model, COUNT(T2.device_model) 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 > 30 AND T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 1", "index": 583, "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: ['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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` real, -- example: [0.0833]\n `F43+` real, -- example: [0.0833]\n `M23-26` 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 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 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: ['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 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 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 PRIMARY KEY (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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale users refers to gender = 'F'; most female users refers to MAX(COUNT(gender = 'F')); over 30 refers to age > 30;\nWhat is the device model used by the most female users over 30?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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 (\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_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 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_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 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 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 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_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 `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 `M27-28` 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:\nmost app users refers to MAX(COUNT(app_id));\nWhat are the top 3 categories with the most app 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.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id GROUP BY T2.category ) AS T ORDER BY T.num DESC LIMIT 3", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id GROUP BY T2.category ) AS T ORDER BY T.num DESC LIMIT 3", "index": 584, "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 (\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_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 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_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 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 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 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_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 `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 `M27-28` 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:\nmost app users refers to MAX(COUNT(app_id));\nWhat are the top 3 categories with the most app 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 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: ['F', 'M']\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_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 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: ['小米', '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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyoungest refers to MIN(age); female refers to gender = 'F';\nHow many events have happened on the device of the youngest female user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.event_id) FROM events AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F' GROUP BY T1.event_id, T2.age ORDER BY T2.age LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.event_id) FROM events AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F' GROUP BY T1.event_id, T2.age ORDER BY T2.age LIMIT 1", "index": 585, "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 (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['F', 'M']\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_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 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: ['小米', '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 label_categories (\n label_id integer, -- example: [1, 2]\n PRIMARY KEY (label_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` real, -- example: [0.0833]\n `F33-42` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyoungest refers to MIN(age); female refers to gender = 'F';\nHow many events have happened on the device of the youngest female user?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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: ['Securities', 'Finance', '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 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 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 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 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 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_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 `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:\nmore app users refers to SUBTRACT(IF(SUM(category = 'Securities'), SUM(category = 'Finance')) > 0,'Securities','Finance') as more;\nWhich category has more app users, Securities or Finance?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T2.category = 'Securities', 1, 0)) - SUM(IIF(T2.category = 'Finance', 1, 0)) > 0, 'Securities', 'Finance') AS diff FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT IIF(SUM(IIF(T2.category = 'Securities', 1, 0)) - SUM(IIF(T2.category = 'Finance', 1, 0)) > 0, 'Securities', 'Finance') AS diff FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id", "index": 586, "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: ['Securities', 'Finance', '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 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 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 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 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 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_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 `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:\nmore app users refers to SUBTRACT(IF(SUM(category = 'Securities'), SUM(category = 'Finance')) > 0,'Securities','Finance') as more;\nWhich category has more app users, Securities or Finance?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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_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 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_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_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);\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 `M22-` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nratio = DIVIDE(SUM(gender = 'M' WHERE phone_brand = 'vivo'), SUM(gender = 'F' WHERE phone_brand = 'vivo')); female refers to gender = 'F'; male refers to gender = 'M'; vivo device refers to phone_brand = 'vivo';\nWhat is the ratio of female users to male users who uses a vivo device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 = 'M', 1, 0)) / SUM(IIF(T1.gender = 'F', 1, 0)) 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 = 'M', 1, 0)) / SUM(IIF(T1.gender = 'F', 1, 0)) 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": 587, "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 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 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_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 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_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_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);\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 `M22-` 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nratio = DIVIDE(SUM(gender = 'M' WHERE phone_brand = 'vivo'), SUM(gender = 'F' WHERE phone_brand = 'vivo')); female refers to gender = 'F'; male refers to gender = 'M'; vivo device refers to phone_brand = 'vivo';\nWhat is the ratio of female users to male users who uses a vivo device?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 events (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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 `M22-` 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 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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\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: ['Securities', 'Finance', '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 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 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:\nratio = DIVIDE(SUM(category = 'Securities'), SUM(category = 'Finance'));\nWhat is the ratio of the number of app users that belong to the Securities category to the number of app users that belong to the Finance 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 SUM(IIF(T2.category = 'Securities', 1, 0)) / SUM(IIF(T2.category = 'Finance', 1, 0)) AS per FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T2.category = 'Securities', 1, 0)) / SUM(IIF(T2.category = 'Finance', 1, 0)) AS per FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id", "index": 588, "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 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 events (\n event_id integer, -- example: [1, 2]\n PRIMARY KEY (event_id)\n);\n\nCREATE TABLE gender_age_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\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 `M22-` 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 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 gender_age (\n device_id integer, -- example: [-9221086586254644858, -9221079146476055829]\n gender text, -- example: ['M', 'F']\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: ['Securities', 'Finance', '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 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 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:\nratio = DIVIDE(SUM(category = 'Securities'), SUM(category = 'Finance'));\nWhat is the ratio of the number of app users that belong to the Securities category to the number of app users that belong to the Finance 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 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_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 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_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 `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `M22-` 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 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 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_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 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:\nratio = DIVIDE(SUM(is_active = 1), SUM(is_active = 0)); active refers to is_active = 1; inactive refers to is_active = 0;\nWhat is the ratio of active and inactive app users of the event ID \"58\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_active = 1, 1, 0)) / SUM(IIF(is_active = 0, 1, 0)) AS per FROM app_events WHERE event_id = 58", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(is_active = 1, 1, 0)) / SUM(IIF(is_active = 0, 1, 0)) AS per FROM app_events WHERE event_id = 58", "index": 589, "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 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 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_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 `F27-28` real, -- example: [0.0833]\n `F29-32` real, -- example: [0.0833]\n `M22-` 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 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 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_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 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:\nratio = DIVIDE(SUM(is_active = 1), SUM(is_active = 0)); active refers to is_active = 1; inactive refers to is_active = 0;\nWhat is the ratio of active and inactive app users of the event ID \"58\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 `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 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 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 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 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_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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many events did the device ID \"3915082290673130000\" join?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(event_id) FROM events WHERE device_id = 3915082290673130000", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM events WHERE device_id = 3915082290673130000", "index": 590, "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 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 `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 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 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 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 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_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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many events did the device ID \"3915082290673130000\" join?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_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 (\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 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 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 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 `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 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 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 `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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many events were participated by the users at longitude of \"-156\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(event_id) FROM events WHERE longitude = -156", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(event_id) FROM events WHERE longitude = -156", "index": 591, "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_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 (\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 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 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 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 `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 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 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 `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_train (\n device_id integer, -- example: [-9223067244542181226, -9222956879900151005]\n gender text, -- example: ['M', 'F']\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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHow many events were participated by the users at longitude of \"-156\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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', 'Word games', '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 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 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 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 (\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncategory names refers to category; start with the word game refers to category like 'game%';\nHow many category names start with the word \"game\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(label_id) FROM label_categories WHERE category LIKE 'game%'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(label_id) FROM label_categories WHERE category LIKE 'game%'", "index": 592, "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 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 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', 'Word games', '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 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 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 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 (\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_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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncategory names refers to category; start with the word game refers to category like 'game%';\nHow many category names start with the word \"game\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "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: ['Chinese Classical Mythology', 'classical', 'Classical 1', '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 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 (\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 `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 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 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_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 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);\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 label IDs and app IDs of the Chinese Classical Mythology 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 T1.label_id, T2.app_id FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'Chinese Classical Mythology'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T1.label_id, T2.app_id FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'Chinese Classical Mythology'", "index": 593, "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: ['Chinese Classical Mythology', 'classical', 'Classical 1', '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 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 (\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 `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 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 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_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 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);\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 label IDs and app IDs of the Chinese Classical Mythology 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 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 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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `M32-38` 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 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 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 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 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 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:\nOPPO refers to phone_brand = 'OPPO'; around 12 AM on 1st May, 2016 refers to timestamp is '2016-05-01'\nHow many OPPO users participated in events which were held around 12 AM on 1st 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 COUNT(T1.device_id) FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'OPPO' AND STRFTIME('%Y-%m-%d', T1.`timestamp`) = '2016-05-01'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(T1.device_id) FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'OPPO' AND STRFTIME('%Y-%m-%d', T1.`timestamp`) = '2016-05-01'", "index": 594, "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_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 (\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\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 `M32-38` 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 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 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 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 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 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:\nOPPO refers to phone_brand = 'OPPO'; around 12 AM on 1st May, 2016 refers to timestamp is '2016-05-01'\nHow many OPPO users participated in events which were held around 12 AM on 1st 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 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 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 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: ['HTC', '小米', '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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F27-28` real, -- example: [0.0833]\n `F29-32` 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 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 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_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: ['F', 'M']\n age integer, -- example: [24, 36]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHTC refers to phone_brand = 'HTC'; percentage = DIVIDE(SUM(gender = 'F' AND age > 80), COUNT(device_id)); female refers to gender = 'F'; over 80 refers to age > 80\nAmong the HTC users, calculate the percentage of female users who are over 80.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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' AND T1.age > 80, 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 = 'HTC'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT SUM(IIF(T1.gender = 'F' AND T1.age > 80, 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 = 'HTC'", "index": 595, "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 label_categories (\n label_id integer, -- example: [1, 2]\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 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: ['HTC', '小米', '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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F27-28` real, -- example: [0.0833]\n `F29-32` 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 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 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_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: ['F', 'M']\n age integer, -- example: [24, 36]\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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHTC refers to phone_brand = 'HTC'; percentage = DIVIDE(SUM(gender = 'F' AND age > 80), COUNT(device_id)); female refers to gender = 'F'; over 80 refers to age > 80\nAmong the HTC users, calculate the percentage of female users who are over 80.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` 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 `M32-38` 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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\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 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 `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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmodel refers to device_model;\nWhich phone brand and model was used for event ID \"6701\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.event_id = 6701", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.event_id = 6701", "index": 596, "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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F24-26` 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 `M32-38` 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 label_categories (\n label_id integer, -- example: [1, 2]\n category text, -- example: ['Phone', 'phone', 'model', 'game-game type', 'game-Game themes']\n PRIMARY KEY (label_id)\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 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 `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 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 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 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);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmodel refers to device_model;\nWhich phone brand and model was used for event ID \"6701\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 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 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: ['红米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 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_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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` 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 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:\nmore events refers to MAX(COUNT(event_id));\nBetween device ID of \"-9215352913819630000\" and \"-9222956879900150000\", mention the age and gender of device user who participated more events.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.age, T.gender FROM ( SELECT T2.age, T2.gender, COUNT(T1.device_id) AS num FROM events AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T1.device_id BETWEEN -9215352913819630000 AND -9222956879900150000 GROUP BY T2.age, T2.gender ) AS T ORDER BY T.num DESC LIMIT 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT T.age, T.gender FROM ( SELECT T2.age, T2.gender, COUNT(T1.device_id) AS num FROM events AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T1.device_id BETWEEN -9215352913819630000 AND -9222956879900150000 GROUP BY T2.age, T2.gender ) AS T ORDER BY T.num DESC LIMIT 1", "index": 597, "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 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 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: ['红米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 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_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 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_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 sample_submission (\n device_id integer, -- example: [-9223321966609553846, -9223042152723782980]\n `F23-` real, -- example: [0.0833]\n `F24-26` 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 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:\nmore events refers to MAX(COUNT(event_id));\nBetween device ID of \"-9215352913819630000\" and \"-9222956879900150000\", mention the age and gender of device user who participated more events.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `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 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_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-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 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 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 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 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:\nactive refers to is_active = 1;\nHow many active users are there in the event?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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_events WHERE is_active = 1", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(app_id) FROM app_events WHERE is_active = 1", "index": 598, "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 `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 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_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-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 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 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 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 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:\nactive refers to is_active = 1;\nHow many active users are there in the event?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `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 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: ['A51', '红米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 age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\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 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);\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_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 events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.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:\nmodel refers to device_model; device_model = 'A51';\nHow many devices belong to model \"A51\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 device_model = 'A51'", "style": "rule" }
{ "db_id": "talkingdata.sqlite", "gt_sql": "SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE device_model = 'A51'", "index": 599, "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 `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 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: ['A51', '红米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 age integer, -- example: [24, 36]\n `group` text, -- example: ['M23-26', 'M32-38']\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 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);\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_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 events (\n event_id integer, -- example: [1, 2]\n device_id integer, -- example: [29182687948017175, -6401643145415154744]\n longitude real, -- example: [121.0, 104.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:\nmodel refers to device_model; device_model = 'A51';\nHow many devices belong to model \"A51\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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" }