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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_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 publishers are in the USA?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(pub_id) FROM publishers WHERE country = 'USA'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT COUNT(pub_id) FROM publishers WHERE country = 'USA'", "index": 100, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_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 publishers are in the USA?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher name refers to pub_name; New Moon Books is a publisher name\nWhat is the publisher's information of New Moon Books?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books'", "index": 101, "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 titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher name refers to pub_name; New Moon Books is a publisher name\nWhat is the publisher's information of New Moon Books?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_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 job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date)\nWhat is the highest level of job to get to for the employee who got hired the earliest?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.max_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.hire_date LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.max_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.hire_date LIMIT 1", "index": 102, "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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_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 job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date)\nWhat is the highest level of job to get to for the employee who got hired the earliest?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n city text, -- example: ['Seattle', 'Tustin']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; highest sales quantity refers to MAX(qty)\nIn which city is the store with the highest total sales quantity located?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.city FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id GROUP BY T2.city ORDER BY SUM(T1.qty) DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.city FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id GROUP BY T2.city ORDER BY SUM(T1.qty) DESC LIMIT 1", "index": 103, "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 jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n city text, -- example: ['Seattle', 'Tustin']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; highest sales quantity refers to MAX(qty)\nIn which city is the store with the highest total sales quantity located?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)\nWhat is the price of the book that sells the best?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.price FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id ORDER BY T1.qty DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.price FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id ORDER BY T1.qty DESC LIMIT 1", "index": 104, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)\nWhat is the price of the book that sells the best?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore name refers to stor_name\nPlease list the stores that ordered the book \"Life Without Fear\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.stor_name FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T3.title = 'Life Without Fear'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.stor_name FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T3.title = 'Life Without Fear'", "index": 105, "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 sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore name refers to stor_name\nPlease list the stores that ordered the book \"Life Without Fear\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMassachusetts is a state\nAmong the stores that have ordered the book \"Life Without Fear\", how many of them are located in Massachusetts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.stor_id) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT COUNT(T1.stor_id) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts'", "index": 106, "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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMassachusetts is a state\nAmong the stores that have ordered the book \"Life Without Fear\", how many of them are located in Massachusetts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLife Without Fear is book title\nIn which country is the publisher of the book \"Life Without Fear\" located?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.country FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Life Without Fear'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.country FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Life Without Fear'", "index": 107, "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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Life Without Fear', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLife Without Fear is book title\nIn which country is the publisher of the book \"Life Without Fear\" located?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 discounts (\n stor_id text, -- store id, example: ['8042']\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n city text, -- example: ['Menlo Park', 'Oakland']\n PRIMARY KEY (au_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 expensive book refers to MAX(price)\nWhat is the publisher that has published the most expensive book?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T1.price DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T1.price DESC LIMIT 1", "index": 108, "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 discounts (\n stor_id text, -- store id, example: ['8042']\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n city text, -- example: ['Menlo Park', 'Oakland']\n PRIMARY KEY (au_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 expensive book refers to MAX(price)\nWhat is the publisher that has published the most expensive book?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nare over $15 refers to price>15\nAmong the publishers in the USA, how many of them have published books that are over $15?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.pub_id) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA' AND T1.price > 15", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT COUNT(DISTINCT T1.pub_id) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA' AND T1.price > 15", "index": 109, "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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nare over $15 refers to price>15\nAmong the publishers in the USA, how many of them have published books that are over $15?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMassachusetts is a state; business books refers to type = 'business'\nHow many books on business have the bookstores in Massachusetts ordered?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(T1.qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts' AND T3.type = 'business'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT SUM(T1.qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts' AND T3.type = 'business'", "index": 110, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMassachusetts is a state; business books refers to type = 'business'\nHow many books on business have the bookstores in Massachusetts ordered?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_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 pre-paid amount refers to MAX(advance)\nWhich type of book had the most pre-paid amount?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 type FROM titles ORDER BY advance DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT type FROM titles ORDER BY advance DESC LIMIT 1", "index": 111, "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 pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n city text, -- example: ['Seattle', 'Tustin']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_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 pre-paid amount refers to MAX(advance)\nWhich type of book had the most pre-paid amount?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: [\"O'Rourke\", 'Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob level refers to job_lvl\nWhich job level is O'Rourke at?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 job_lvl FROM employee WHERE lname = 'O''Rourke'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'", "index": 112, "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 jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: [\"O'Rourke\", 'Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob level refers to job_lvl\nWhich job level is O'Rourke at?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_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 employee refers to employee with the highest job level; MAX(job_lvl)\nShow me the employ id of the highest employee who doesn't have a middle name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1", "index": 113, "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 stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_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 employee refers to employee with the highest job level; MAX(job_lvl)\nShow me the employ id of the highest employee who doesn't have a middle name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n PRIMARY KEY (stor_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 job level refers to MAX(job_lvl)\nWhich publisher had the highest job level? Give his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.fname, T1.minit, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.job_lvl DESC LIMIT 1", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.fname, T1.minit, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.job_lvl DESC LIMIT 1", "index": 114, "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 pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n PRIMARY KEY (stor_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 job level refers to MAX(job_lvl)\nWhich publisher had the highest job level? Give his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Pedro', 'Aria', 'Annette']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Afonso', 'Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob title means job description which refers to job_desc\nWhat's Pedro S Afonso's job title?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Pedro' AND T1.minit = 'S' AND T1.lname = 'Afonso'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Pedro' AND T1.minit = 'S' AND T1.lname = 'Afonso'", "index": 115, "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 titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Pedro', 'Aria', 'Annette']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Afonso', 'Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob title means job description which refers to job_desc\nWhat's Pedro S Afonso's job title?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\norder happened on refers to ord_date\nWhat's on the notes for the order happened on 1994/9/14?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1994-09-14'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1994-09-14'", "index": 116, "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 titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\norder happened on refers to ord_date\nWhat's on the notes for the order happened on 1994/9/14?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsold on refers to ord_date\nList the type of the book for the order which was sold on 1993/5/29.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.type FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1993-05-29'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT DISTINCT T1.type FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1993-05-29'", "index": 117, "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 pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['M', 'R']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsold on refers to ord_date\nList the type of the book for the order which was sold on 1993/5/29.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Silicon Valley Gastronomic Treats', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher name refers to pub_name; Silicon Valley Gastronomic Treats is the title of a book\nWhat's the publisher of the book \"Silicon Valley Gastronomic Treats\"? Give the publisher's name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Silicon Valley Gastronomic Treats'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Silicon Valley Gastronomic Treats'", "index": 118, "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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n stor_address text, -- store address, example: ['788 Catamaugus Ave.', '567 Pasadena Ave.']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'New Hire - Job not specified', 'Chief Executive Officer']\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: ['Silicon Valley Gastronomic Treats', \"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher name refers to pub_name; Silicon Valley Gastronomic Treats is the title of a book\nWhat's the publisher of the book \"Silicon Valley Gastronomic Treats\"? Give the publisher's name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Remulade', 'Seattle', 'Tustin']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nRemulade is a city; sales in the store refers to ord_num\nHow many sales did the store in Remulade make?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.ord_num) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T2.city = 'Remulade'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT COUNT(T1.ord_num) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T2.city = 'Remulade'", "index": 119, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n city text, -- example: ['Menlo Park', 'Oakland']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Remulade', 'Seattle', 'Tustin']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nRemulade is a city; sales in the store refers to ord_num\nHow many sales did the store in Remulade make?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Portland', 'Fremont', 'Seattle', 'Tustin']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE(\nSUBTRACT(SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)), \nSUM(qty where city = ‘Portland’ and year(ord_date = 1993))), SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)) *100\nFor the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) - SUM(CASE WHEN T2.city = 'Portland' THEN qty END) AS REAL) * 100 / SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE STRFTIME('%Y', T1.ord_date) = '1993'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) - SUM(CASE WHEN T2.city = 'Portland' THEN qty END) AS REAL) * 100 / SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE STRFTIME('%Y', T1.ord_date) = '1993'", "index": 120, "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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Portland', 'Fremont', 'Seattle', 'Tustin']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE(\nSUBTRACT(SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)), \nSUM(qty where city = ‘Portland’ and year(ord_date = 1993))), SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)) *100\nFor the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'Designer', 'New Hire - Job not specified', 'Chief Executive Officer']\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'))\nAmong all the employees, how many percent more for the publishers than designers?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id", "index": 121, "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 publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Publisher', 'Designer', 'New Hire - Job not specified', 'Chief Executive Officer']\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'))\nAmong all the employees, how many percent more for the publishers than designers?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage royalty rate = DIVIDE(SUM(royalty), COUNT(title_id))\nWhich titles has above average royalty rate? Give those title's name, type and price?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.title, T1.type, T1.price FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.royalty > ( SELECT CAST(SUM(royalty) AS REAL) / COUNT(title_id) FROM roysched )", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.royalty > ( SELECT CAST(SUM(royalty) AS REAL) / COUNT(title_id) FROM roysched )", "index": 122, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n minit text, -- example: ['S', 'M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n state text, -- example: ['MA', 'DC']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage royalty rate = DIVIDE(SUM(royalty), COUNT(title_id))\nWhich titles has above average royalty rate? Give those title's name, type and price?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nEric the Read Books is a publisher which refers to pub_name;\nList the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books' ORDER BY T1.price", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books' ORDER BY T1.price", "index": 123, "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 roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nEric the Read Books is a publisher which refers to pub_name;\nList the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nUS publisher refers publisher in the US where country = 'USA';\nIn the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id WHERE T2.country = 'USA' ORDER BY T1.royalty DESC", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id WHERE T2.country = 'USA' ORDER BY T1.royalty DESC", "index": 124, "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 jobs (\n job_id integer, -- example: [1, 2]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n royalty integer, -- example: [10, 12]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n state text, -- example: ['CA', 'KS']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n royalty integer, -- example: [10, 24]\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nUS publisher refers publisher in the US where country = 'USA';\nIn the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Marketing Manager', 'Publisher', 'Editor', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMarketing manager is a job description which refers to job_desc; US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; job level refers to job_lvl; average level = AVG(job_lvl)\nCalculate the average level difference between the Marketing editors hired by the US and non-US publishers?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T1.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers AS T1 INNER JOIN employee AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T2.job_id = T3.job_id WHERE T3.job_desc = 'Managing Editor'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT (CAST(SUM(CASE WHEN T1.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers AS T1 INNER JOIN employee AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T2.job_id = T3.job_id WHERE T3.job_desc = 'Managing Editor'", "index": 125, "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 roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n pub_id text, -- publisher id, example: ['1389', '0736']\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n stor_id text, -- store id, example: ['8042']\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n job_desc text, -- job description, example: ['Marketing Manager', 'Publisher', 'Editor', 'New Hire - Job not specified', 'Chief Executive Officer']\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n au_ord integer, -- author ordering, example: [1, 2]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n state text, -- example: ['WA', 'CA']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMarketing manager is a job description which refers to job_desc; US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; job level refers to job_lvl; average level = AVG(job_lvl)\nCalculate the average level difference between the Marketing editors hired by the US and non-US publishers?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher refers to pub_name; about the title refers to notes\nWhich title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'", "index": 126, "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 employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n minit text, -- example: ['M', 'R']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n job_lvl integer, -- job level, example: [87, 152]\n pub_id text, -- publisher id, example: ['1389', '9999']\n hire_date datetime, -- example: ['1991-10-26 00:00:00.0', '1990-02-21 00:00:00.0']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n max_lvl integer, -- max level, example: [10, 250]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_lname text, -- author last name, example: ['White', 'Green']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n zip text, -- example: ['94025', '94618']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n type text, -- example: ['business', 'mod_cook']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n advance real, -- example: [5000.0, 10125.0]\n royalty integer, -- example: [10, 24]\n ytd_sales integer, -- year to date sales, example: [4095, 3876]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n pubdate datetime, -- publication date, example: ['1991-06-12 00:00:00.0', '1991-06-09 00:00:00.0']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n pub_name text, -- publisher name, example: ['New Moon Books', 'Binnet & Hardley']\n city text, -- example: ['Boston', 'Washington']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n lorange integer, -- low range, example: [0, 5001]\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['WA', 'CA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n royaltyper integer, -- example: [100, 40]\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n logo blob, -- example: ['0x4749463839618B002F00B30F00000000800000', '0x474946383961C2001D00B30F00000000800000']\n pr_info text, -- publisher's information, example: ['This is sample text data for Binnet & Ha', 'This is sample text data for Algodata In']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npublisher refers to pub_name; about the title refers to notes\nWhich title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['CA', 'MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['CA', 'WA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA\"\nName the top five titles that sold more than average and list them in descending order of the number of sales in California stores?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T2.qty > ( SELECT CAST(SUM(qty) AS REAL) / COUNT(title_id) FROM sales ) AND T3.state = 'CA' ORDER BY T2.qty DESC LIMIT 5", "style": "rule" }
{ "db_id": "book_publishing_company.sqlite", "gt_sql": "SELECT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T2.qty > ( SELECT CAST(SUM(qty) AS REAL) / COUNT(title_id) FROM sales ) AND T3.state = 'CA' ORDER BY T2.qty DESC LIMIT 5", "index": 127, "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 authors (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n au_fname text, -- author first name, example: ['Johnson', 'Marjorie']\n phone text, -- example: ['408 496-7223', '415 986-7020']\n address text, -- example: ['10932 Bigge Rd.', '309 63rd St. #411']\n city text, -- example: ['Menlo Park', 'Oakland']\n state text, -- example: ['CA', 'KS']\n contract text, -- example: ['0']\n PRIMARY KEY (au_id)\n);\n\nCREATE TABLE jobs (\n job_id integer, -- example: [1, 2]\n min_lvl integer, -- min level, example: [10, 200]\n PRIMARY KEY (job_id)\n);\n\nCREATE TABLE publishers (\n pub_id text, -- publisher id, example: ['0736', '0877']\n state text, -- example: ['CA', 'MA', 'DC']\n country text, -- example: ['USA', 'Germany']\n PRIMARY KEY (pub_id)\n);\n\nCREATE TABLE titleauthor (\n au_id text, -- author id, example: ['172-32-1176', '213-46-8915']\n title_id text, -- example: ['PS3333', 'BU1032']\n PRIMARY KEY (au_id, title_id),\n CONSTRAINT fk_titleauthor_au_id FOREIGN KEY (au_id) REFERENCES authors (au_id),\n CONSTRAINT fk_titleauthor_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE sales (\n stor_id text, -- store id, example: ['6380', '7066']\n ord_num text, -- order number, example: ['6871', '722a']\n ord_date datetime, -- order date, example: ['1994-09-14 00:00:00.0', '1994-09-13 00:00:00.0']\n qty integer, -- quantity, example: [5, 3]\n payterms text, -- example: ['Net 60', 'Net 30']\n title_id text, -- example: ['BU1032', 'PS2091']\n PRIMARY KEY (stor_id, ord_num, title_id),\n CONSTRAINT fk_sales_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id),\n CONSTRAINT fk_sales_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\n\nCREATE TABLE employee (\n emp_id text, -- employee id, example: ['A-C71970F', 'A-R89858F']\n fname text, -- first name, example: ['Aria', 'Annette']\n lname text, -- last name, example: ['Cruz', 'Roulet']\n job_id integer, -- example: [10, 6]\n pub_id text, -- publisher id, example: ['1389', '9999']\n PRIMARY KEY (emp_id),\n CONSTRAINT fk_employee_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id),\n CONSTRAINT fk_employee_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE stores (\n stor_id text, -- store id, example: ['6380', '7066']\n stor_name text, -- store name, example: ['Eric the Read Books', \"Barnum's\"]\n city text, -- example: ['Seattle', 'Tustin']\n state text, -- example: ['CA', 'WA']\n zip text, -- example: ['98056', '92789']\n PRIMARY KEY (stor_id)\n);\n\nCREATE TABLE titles (\n title_id text, -- example: ['BU1032', 'BU1111']\n title text, -- example: [\"The Busy Executive's Database Guide\", 'Cooking with Computers: Surreptitious Ba']\n pub_id text, -- publisher id, example: ['1389', '0736']\n price real, -- example: [19.99, 11.95]\n notes text, -- example: ['An overview of available database system', 'Helpful hints on how to use your electro']\n PRIMARY KEY (title_id),\n CONSTRAINT fk_titles_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE pub_info (\n pub_id text, -- publication id, example: ['0877', '1389']\n PRIMARY KEY (pub_id),\n CONSTRAINT fk_pub_info_pub_id FOREIGN KEY (pub_id) REFERENCES publishers (pub_id)\n);\n\nCREATE TABLE discounts (\n discounttype text, -- example: ['Initial Customer', 'Volume Discount']\n stor_id text, -- store id, example: ['8042']\n lowqty integer, -- low quantity, example: [100]\n highqty integer, -- high quantity, example: [1000]\n discount real, -- example: [10.5, 6.7]\n CONSTRAINT fk_discounts_stor_id FOREIGN KEY (stor_id) REFERENCES stores (stor_id)\n);\n\nCREATE TABLE roysched (\n title_id text, -- example: ['BU1032', 'PC1035']\n hirange integer, -- high range, example: [5000, 50000]\n CONSTRAINT fk_roysched_title_id FOREIGN KEY (title_id) REFERENCES titles (title_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nqty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA\"\nName the top five titles that sold more than average and list them in descending order of the number of sales in California stores?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-22', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-03-22', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2017-03-22', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nearliest complaint refers to oldest ser_start; on 2017/3/22 refers to \"Date received\" = '2017-03-22';\nWhen did the earliest complaint start on 2017/3/22?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'", "index": 128, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-22', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-03-22', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2017-03-22', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nearliest complaint refers to oldest ser_start; on 2017/3/22 refers to \"Date received\" = '2017-03-22';\nWhen did the earliest complaint start on 2017/3/22?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n middle text, -- example: ['Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR2405641', 'CR2400594', 'CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR2405641', 'CR2400594', 'CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmore urgent refers to MAX(priority);\nWhich complaint is more urgent, complaint ID CR2400594 or ID CR2405641?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 CASE WHEN SUM(CASE WHEN `Complaint ID` = 'CR2400594' THEN priority END) > SUM(CASE WHEN `Complaint ID` = 'CR2405641' THEN priority END) THEN 'CR2400594' ELSE 'CR2405641' END FROM callcenterlogs", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CASE WHEN SUM(CASE WHEN `Complaint ID` = 'CR2400594' THEN priority END) > SUM(CASE WHEN `Complaint ID` = 'CR2405641' THEN priority END) THEN 'CR2400594' ELSE 'CR2405641' END FROM callcenterlogs", "index": 129, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n middle text, -- example: ['Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR2405641', 'CR2400594', 'CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR2405641', 'CR2400594', 'CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmore urgent refers to MAX(priority);\nWhich complaint is more urgent, complaint ID CR2400594 or ID CR2405641?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull names = first, middle, last; male refers to sex = 'Male'; year > 1990;\nPlease list the full names of all the male clients born after the year 1990.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 first, middle, last FROM client WHERE year > 1990", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT first, middle, last FROM client WHERE year > 1990", "index": 130, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull names = first, middle, last; male refers to sex = 'Male'; year > 1990;\nPlease list the full names of all the male clients born after the year 1990.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2014-07-03', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Diesel', 'Emma', 'Noah']\n last text, -- example: ['Galloway', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-03', '2014-07-07', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndetailed product refers to \"sub-product\"; on 2014/7/3 refers to \"Date received\" = '2014-07-03';\nWhat is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway' AND T2.`Date received` = '2014-07-03'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway' AND T2.`Date received` = '2014-07-03'", "index": 131, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2014-07-03', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Diesel', 'Emma', 'Noah']\n last text, -- example: ['Galloway', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-03', '2014-07-07', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndetailed product refers to \"sub-product\"; on 2014/7/3 refers to \"Date received\" = '2014-07-03';\nWhat is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Matthew', 'Pierce', 'Emma', 'Noah']\n middle text, -- example: ['Matthew', 'Pierce', 'Avaya', 'Everest']\n last text, -- example: ['Pierce', 'Matthews', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2016-10-28', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2016-10-28', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2016-10-28', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\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/10/28 refers to Date received = '2016-10-28'; \"Consumer consent provided?\" in (null, 'N/A', 'Empty') means that the company didn't get the permission of consent; \"Consumer consent provided?\" not in (null, 'N/A', 'Empty') means that customers provide the consent for this tag;\nWas the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', 'Empty') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Matthew' AND T1.last = 'Pierce' AND T2.`Date received` = '2016-10-28'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', 'Empty') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Matthew' AND T1.last = 'Pierce' AND T2.`Date received` = '2016-10-28'", "index": 132, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Matthew', 'Pierce', 'Emma', 'Noah']\n middle text, -- example: ['Matthew', 'Pierce', 'Avaya', 'Everest']\n last text, -- example: ['Pierce', 'Matthews', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2016-10-28', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2016-10-28', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2016-10-28', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\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/10/28 refers to Date received = '2016-10-28'; \"Consumer consent provided?\" in (null, 'N/A', 'Empty') means that the company didn't get the permission of consent; \"Consumer consent provided?\" not in (null, 'N/A', 'Empty') means that customers provide the consent for this tag;\nWas the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['York', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['New York City', 'Albuquerque']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAmong all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Issue) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Issue = 'Deposits and withdrawals' AND T1.city = 'New York City'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T2.Issue) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Issue = 'Deposits and withdrawals' AND T1.city = 'New York City'", "index": 133, "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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['York', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['New York City', 'Albuquerque']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAmong all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['In progress', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name = first, middle, last; complaints are still in progress refers to \"Company response to consumer\" = 'In progress';\nPlease list the full names of all the clients whose complaints are still in progress.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'In progress'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'In progress'", "index": 134, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['In progress', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name = first, middle, last; complaints are still in progress refers to \"Company response to consumer\" = 'In progress';\nPlease list the full names of all the clients whose complaints are still in progress.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Untimely response', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['York', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not receive a timely response refers to \"Timely response?\" = 'No'; New York refers to city = 'New York';\nAmong the clients who did receive a timely response for their complaint, how many of them are from New York?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.city) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'No' AND T1.city = 'New York City'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.city) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'No' AND T1.city = 'New York City'", "index": 135, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Untimely response', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['York', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not receive a timely response refers to \"Timely response?\" = 'No'; New York refers to city = 'New York';\nAmong the clients who did receive a timely response for their complaint, how many of them are from New York?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['York', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage = AVG(Complaint ID); credit cards refers to Product = 'Credit card'; New York refers to city = 'New York'; 3 consecutive years starting from 2015 refers to \"Date received\" BETWEEN 2015 AND 2017;\nWhat is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T2.`Complaint ID`) AS REAL) / 3 AS average FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) BETWEEN '2015' AND '2017' AND T1.city = 'New York City' AND T2.Product = 'Credit card'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(COUNT(T2.`Complaint ID`) AS REAL) / 3 AS average FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) BETWEEN '2015' AND '2017' AND T1.city = 'New York City' AND T2.Product = 'Credit card'", "index": 136, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['York', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage = AVG(Complaint ID); credit cards refers to Product = 'Credit card'; New York refers to city = 'New York'; 3 consecutive years starting from 2015 refers to \"Date received\" BETWEEN 2015 AND 2017;\nWhat is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage of increase = MULTIPLY(DIVIDE(SUBTRACT(SUM(year(\"Date received\") = 2017), SUM(year(\"Date received\") = 2016)), SUM(year(\"Date received\") = 2016)), 1.0); New York refers to city = 'New York'; year(\"Date received\") BETWEEN 2016 AND 2017;\nWhat is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 100.0 * (SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2017' THEN 1 ELSE 0 END) - SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END)) / SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT 100.0 * (SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2017' THEN 1 ELSE 0 END) - SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END)) / SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City'", "index": 137, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage of increase = MULTIPLY(DIVIDE(SUBTRACT(SUM(year(\"Date received\") = 2017), SUM(year(\"Date received\") = 2016)), SUM(year(\"Date received\") = 2016)), 1.0); New York refers to city = 'New York'; year(\"Date received\") BETWEEN 2016 AND 2017;\nWhat is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00007127', 'C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-02-22', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00007127', 'C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-02-22', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00007127', 'C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserve time refers to ser_time; longer ser_time means more verbose or longer complaint; on 2017/2/22 refers to \"Date received\" = '2017-02-22';\nWhat was the serve time for the complaint call from client \"C00007127\" on 2017/2/22?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.ser_time FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Client_ID = 'C00007127' AND T1.`Date received` = '2017-02-22'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.ser_time FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Client_ID = 'C00007127' AND T1.`Date received` = '2017-02-22'", "index": 138, "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 client (\n client_id text, -- example: ['C00007127', 'C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-02-22', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00007127', 'C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-02-22', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00007127', 'C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserve time refers to ser_time; longer ser_time means more verbose or longer complaint; on 2017/2/22 refers to \"Date received\" = '2017-02-22';\nWhat was the serve time for the complaint call from client \"C00007127\" on 2017/2/22?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['wyatt.collins@gmail.com', 'emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name of the state refers to state_name;\nWhich state does the owner of \"wyatt.collins@gmail.com\" live in? Give the full name of the state.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = 'wyatt.collins@gmail.com'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = 'wyatt.collins@gmail.com'", "index": 139, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['wyatt.collins@gmail.com', 'emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name of the state refers to state_name;\nWhich state does the owner of \"wyatt.collins@gmail.com\" live in? Give the full name of the state.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Taylor', 'Emely', 'Lyric', 'Emma', 'Noah']\n middle text, -- example: ['Taylor', 'Emely', 'Lyric', 'Avaya', 'Everest']\n last text, -- example: ['Taylor', 'Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['MS', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['MS', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2016-05-20', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2016-05-20', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['MS', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2016-05-20', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2016-05-20', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMs refers to sex = 'Female'; \"Consumer consent provided?\" in (null, 'N/A', 'Empty') means that the company didn't get the permission of consent; \"Consumer consent provided?\" not in (null, 'N/A', 'Empty') means the customers provide the consent; on 2016/5/20 refers to Date received = '2016-05-20';\nDid Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', '') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lyric' AND T1.middle = 'Emely' AND T1.last = 'Taylor' AND T1.sex = 'Female' AND T2.`Date received` = '2016-05-20'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', '') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lyric' AND T1.middle = 'Emely' AND T1.last = 'Taylor' AND T1.sex = 'Female' AND T2.`Date received` = '2016-05-20'", "index": 140, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Taylor', 'Emely', 'Lyric', 'Emma', 'Noah']\n middle text, -- example: ['Taylor', 'Emely', 'Lyric', 'Avaya', 'Everest']\n last text, -- example: ['Taylor', 'Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['MS', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['MS', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2016-05-20', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2016-05-20', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['MS', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2016-05-20', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2016-05-20', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMs refers to sex = 'Female'; \"Consumer consent provided?\" in (null, 'N/A', 'Empty') means that the company didn't get the permission of consent; \"Consumer consent provided?\" not in (null, 'N/A', 'Empty') means the customers provide the consent; on 2016/5/20 refers to Date received = '2016-05-20';\nDid Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Brantley', 'Stanley', 'Julian', 'Emma', 'Noah']\n middle text, -- example: ['Brantley', 'Stanley', 'Julian', 'Avaya', 'Everest']\n last text, -- example: ['Brantley', 'Stanley', 'Day', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2012-05-18', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2012-05-18', '2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Date sent to company` text, -- example: ['2012-05-18', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndays delay for the complaint = SUBTRACT(\"date sent to company\", \"Date received\"); Mr refers to sex = 'Male'; on 2012/5/18 refers to \"Date received\" = '2012-05-18';\nHow many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 365 * (strftime('%Y', T2.`Date sent to company`) - strftime('%Y', T2.`Date received`)) + 30 * (strftime('%M', T2.`Date sent to company`) - strftime('%M', T2.`Date received`)) + (strftime('%d', T2.`Date sent to company`) - strftime('%d', T2.`Date received`)) AS days FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2012-05-18' AND T1.sex = 'Male' AND T1.first = 'Brantley' AND T1.middle = 'Julian' AND T1.last = 'Stanley'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT 365 * (strftime('%Y', T2.`Date sent to company`) - strftime('%Y', T2.`Date received`)) + 30 * (strftime('%M', T2.`Date sent to company`) - strftime('%M', T2.`Date received`)) + (strftime('%d', T2.`Date sent to company`) - strftime('%d', T2.`Date received`)) AS days FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2012-05-18' AND T1.sex = 'Male' AND T1.first = 'Brantley' AND T1.middle = 'Julian' AND T1.last = 'Stanley'", "index": 141, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Brantley', 'Stanley', 'Julian', 'Emma', 'Noah']\n middle text, -- example: ['Brantley', 'Stanley', 'Julian', 'Avaya', 'Everest']\n last text, -- example: ['Brantley', 'Stanley', 'Day', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2012-05-18', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2012-05-18', '2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Date sent to company` text, -- example: ['2012-05-18', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndays delay for the complaint = SUBTRACT(\"date sent to company\", \"Date received\"); Mr refers to sex = 'Male'; on 2012/5/18 refers to \"Date received\" = '2012-05-18';\nHow many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n city text, -- example: ['Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2017-07-22', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2018/9/11 refers to Date = '2017-07-22';\nWhich district did the review on 2018/9/11 come from? Give the name of the city.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.district_id, T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Date = '2018-09-11'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.district_id, T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Date = '2018-09-11'", "index": 142, "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 callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n city text, -- example: ['Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2017-07-22', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\non 2018/9/11 refers to Date = '2017-07-22';\nWhich district did the review on 2018/9/11 come from? Give the name of the city.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Indianapolis', 'Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-04-04', '2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Indianapolis', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2013-04-06', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2013-04-04', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Date sent to company` text, -- example: ['2013-04-04', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIndianapolis refers to state = 'Indianapolis'; on 2016/10/7 refers to Date = '2013-04-04';\nWhich product received a review from Indianapolis on 2016/10/7?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Product FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' AND T1.Date = '2016-10-07'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.Product FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' AND T1.Date = '2016-10-07'", "index": 143, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Indianapolis', 'Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-04-04', '2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Indianapolis', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2013-04-06', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2013-04-04', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Date sent to company` text, -- example: ['2013-04-04', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nIndianapolis refers to state = 'Indianapolis'; on 2016/10/7 refers to Date = '2013-04-04';\nWhich product received a review from Indianapolis on 2016/10/7?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n age integer, -- example: [29, 54]\n first text, -- example: ['Javen', 'Mason', 'Emma', 'Noah']\n middle text, -- example: ['Javen', 'Mason', 'Avaya', 'Everest']\n last text, -- example: ['Lopez', 'Mason', 'Smith', 'Thompson']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(\"Consumer consent provided?\" = 'Consent provided'), COUNT(client_id)), 1.0); Mr refers to sex = 'Male'; consent provided by the customer refers to \"Consumer consent provided?\" = 'Consent provided';\nWhat is the percentage of the complaint calls from Mr Mason Javen Lopez has got the consent provided by the customer?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.`Consumer consent provided?` = 'Consent provided' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Consumer consent provided?`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.first = 'Mason' AND T1.middle = 'Javen' AND T1.last = 'Lopez'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.`Consumer consent provided?` = 'Consent provided' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Consumer consent provided?`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.first = 'Mason' AND T1.middle = 'Javen' AND T1.last = 'Lopez'", "index": 144, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n age integer, -- example: [29, 54]\n first text, -- example: ['Javen', 'Mason', 'Emma', 'Noah']\n middle text, -- example: ['Javen', 'Mason', 'Avaya', 'Everest']\n last text, -- example: ['Lopez', 'Mason', 'Smith', 'Thompson']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(\"Consumer consent provided?\" = 'Consent provided'), COUNT(client_id)), 1.0); Mr refers to sex = 'Male'; consent provided by the customer refers to \"Consumer consent provided?\" = 'Consent provided';\nWhat is the percentage of the complaint calls from Mr Mason Javen Lopez has got the consent provided by the customer?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-01-31', '2017-01-01', '2017-01-05', '2017-01-04', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-01-31', '2017-01-01', '2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2017-01-31', '2017-01-01', '2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nurgent complaints refers to priority = 2; march of 2017 refers to \"Date received\" BETWEEN '2017-01-01' AND '2017-01-31';\nHow many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs )", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs )", "index": 145, "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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-01-31', '2017-01-01', '2017-01-05', '2017-01-04', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2017-01-31', '2017-01-01', '2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2017-01-31', '2017-01-01', '2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nurgent complaints refers to priority = 2; march of 2017 refers to \"Date received\" BETWEEN '2017-01-01' AND '2017-01-31';\nHow many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost five stars refers to MAX(COUNT(stars = 5));\nWhich product got the most five stars, and how many?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T", "index": 146, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost five stars refers to MAX(COUNT(stars = 5));\nWhich product got the most five stars, and how many?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['HANG', 'AGENT']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemail id refers to email; calls were hung refers to outcome = 'Hang';\nWhat is the email id of clients whose calls were hung?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.outcome = 'HANG'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.outcome = 'HANG'", "index": 147, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['HANG', 'AGENT']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemail id refers to email; calls were hung refers to outcome = 'Hang';\nWhat is the email id of clients whose calls were hung?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['Midwest', 'South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age);\nCalculate the average age of clients from the Midwest region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest'", "index": 148, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['Midwest', 'South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age);\nCalculate the average age of clients from the Midwest region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Submitted via` text, -- example: ['Phone', 'Fax', 'Email']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name = first, middle, last; submitted the complaint via fax refers to \"Submitted via\" = 'fax';\nList the full name and phone number of clients who submitted the complaint via fax.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Fax'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Fax'", "index": 149, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Submitted via` text, -- example: ['Phone', 'Fax', 'Email']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name = first, middle, last; submitted the complaint via fax refers to \"Submitted via\" = 'fax';\nList the full name and phone number of clients who submitted the complaint via fax.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCredit cards refers to Product = 'Credit card'; female refers to sex = 'female';\nWhat is the number of complaints related to Credit cards came from female clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T2.Product = 'Credit card'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T2.Product = 'Credit card'", "index": 150, "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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nCredit cards refers to Product = 'Credit card'; female refers to sex = 'female';\nWhat is the number of complaints related to Credit cards came from female clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Houston', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Houston', 'Avaya', 'Everest']\n last text, -- example: ['Houston', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Houston', 'Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(\"Consumer disputed?\" = 'Yes' AND city = 'Houston'), COUNT(client_id)), 1.0); Houston refers to city = 'Houston';\nWhat percentage of consumers from Houston disputed complaints?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T2.`Consumer disputed?` = 'Yes' AND T1.city = 'Houston' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T2.`Consumer disputed?` = 'Yes' AND T1.city = 'Houston' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID", "index": 151, "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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Houston', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Houston', 'Avaya', 'Everest']\n last text, -- example: ['Houston', 'Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Houston', 'Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(\"Consumer disputed?\" = 'Yes' AND city = 'Houston'), COUNT(client_id)), 1.0); Houston refers to city = 'Houston';\nWhat percentage of consumers from Houston disputed complaints?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Syracuse', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Syracuse', 'Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nservice members refers to client.client_id; Syracuse refers to city = 'Syracuse';\nFind the number of service members who complained in Syracuse.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'", "index": 152, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Syracuse', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Syracuse', 'Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nservice members refers to client.client_id; Syracuse refers to city = 'Syracuse';\nFind the number of service members who complained in Syracuse.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['Northeast', 'South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndifference in the average = SUBTRACT(AVG(age BETWEEN 35 AND 55), AVG( age > 65)); elderly refers to age > 65; middle-aged refers to age BETWEEN 35 AND 55;\nCalculate the difference in the average age of elderly and middle-aged clients in the Northeast region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T1.age BETWEEN 35 AND 55 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.age > 65 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Northeast'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT (CAST(SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.age > 65 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Northeast'", "index": 153, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['Northeast', 'South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndifference in the average = SUBTRACT(AVG(age BETWEEN 35 AND 55), AVG( age > 65)); elderly refers to age > 65; middle-aged refers to age BETWEEN 35 AND 55;\nCalculate the difference in the average age of elderly and middle-aged clients in the Northeast region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Other', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemail account other than gmail.com refers to email not like '%@gmail.com';\nHow many clients have an email account other than gmail.com?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(email) FROM client WHERE email NOT LIKE '%@gmail.com'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com'", "index": 154, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Other', 'N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemail account other than gmail.com refers to email not like '%@gmail.com';\nHow many clients have an email account other than gmail.com?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not give their consent permission refers to Consumer consent provided is null, 'N/A', or empty;\nIdentify by their ID all clients who did not give their consent permission.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 Client_ID FROM events WHERE `Consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = ''", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT Client_ID FROM events WHERE `Consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = ''", "index": 155, "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 `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Consent provided', 'N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndid not give their consent permission refers to Consumer consent provided is null, 'N/A', or empty;\nIdentify by their ID all clients who did not give their consent permission.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList priority 2 complaints by date received.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC", "index": 156, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList priority 2 complaints by date received.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_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 in process with an agent refers to outcome ! = 'AGENT';\nHow many complaints are not in process with an agent?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'", "index": 157, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_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 in process with an agent refers to outcome ! = 'AGENT';\nHow many complaints are not in process with an agent?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['(CD) Certificate of deposit', 'Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 problems with Certificate refers to MAX(COUNT(\"Sub-product\" = '(CD) Certificate of deposit'));\nIn what years were the clients who demanded more problems with Certificate of deposit born?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.year FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Sub-product` = '(CD) Certificate of deposit' GROUP BY T1.year ORDER BY COUNT(T1.year) DESC LIMIT 1", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.year FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Sub-product` = '(CD) Certificate of deposit' GROUP BY T1.year ORDER BY COUNT(T1.year) DESC LIMIT 1", "index": 158, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['(CD) Certificate of deposit', 'Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 problems with Certificate refers to MAX(COUNT(\"Sub-product\" = '(CD) Certificate of deposit'));\nIn what years were the clients who demanded more problems with Certificate of deposit born?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Massachusetts', 'Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 sex = 'Male';\nHow many male clients are from the state of Massachusetts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.sex) FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN client AS T3 ON T2.district_id = T3.district_id WHERE T1.state = 'Massachusetts' AND T3.sex = 'Male'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T3.sex) FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN client AS T3 ON T2.district_id = T3.district_id WHERE T1.state = 'Massachusetts' AND T3.sex = 'Male'", "index": 159, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Massachusetts', 'Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 sex = 'Male';\nHow many male clients are from the state of Massachusetts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['PS', 'NW']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['TOVA', 'MICHAL']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPS-type complaint refers to type = 'PS'; served by refers to server;\n\n\nLists the last name of all clients who made a PS-type complaint and were served by TOVA.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS' AND T2.server = 'TOVA'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT t1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS' AND T2.server = 'TOVA'", "index": 160, "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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['PS', 'NW']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['TOVA', 'MICHAL']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPS-type complaint refers to type = 'PS'; served by refers to server;\n\n\nLists the last name of all clients who made a PS-type complaint and were served by TOVA.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlargest number of complaints refers to MAX(COUNT(\"Complaint ID\") WHERE priority = 0);\nWhat is the name of the state in which there have been the largest number of complaints with priority 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 T2.state FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T1.priority = 0 GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.state FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T1.priority = 0 GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1", "index": 161, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlargest number of complaints refers to MAX(COUNT(\"Complaint ID\") WHERE priority = 0);\nWhat is the name of the state in which there have been the largest number of complaints with priority 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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['DORIT', 'MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:05:05', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserved in 5 minutes or less refers to ser_time < '00:05:00'; DORIT refers to server = 'DORIT'; responded with an explanation refers to \"Company response to consumer\" = 'Closed with explanation'; made by refers to \"Submitted via\";\nHow many complaints were served in 5 minutes or less by DORIT and responded to the customer with an explanation, were made by phone?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time < '00:05:00' AND T1.server = 'DORIT' AND T2.`Submitted via` = 'Phone' AND T2.`Company response to consumer` = 'Closed with explanation'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time < '00:05:00' AND T1.server = 'DORIT' AND T2.`Submitted via` = 'Phone' AND T2.`Company response to consumer` = 'Closed with explanation'", "index": 162, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['DORIT', 'MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:05:05', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserved in 5 minutes or less refers to ser_time < '00:05:00'; DORIT refers to server = 'DORIT'; responded with an explanation refers to \"Company response to consumer\" = 'Closed with explanation'; made by refers to \"Submitted via\";\nHow many complaints were served in 5 minutes or less by DORIT and responded to the customer with an explanation, were made by phone?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbetween 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';\nHow many reviews by people between 30 and 50 years include the word 'great'?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Reviews) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T2.age BETWEEN 30 AND 50 AND T1.Reviews LIKE '%great%'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.Reviews) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T2.age BETWEEN 30 AND 50 AND T1.Reviews LIKE '%great%'", "index": 163, "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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbetween 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';\nHow many reviews by people between 30 and 50 years include the word 'great'?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Star', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Oregon', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage = DIVIDE(SUM(State = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';\nWhat is the average number of stars given by Oregon clients in their reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T3.Stars) AS REAL) / COUNT(T3.Stars) AS average FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN reviews AS T3 ON T2.district_id = T3.district_id WHERE T1.State = 'Oregon'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(T3.Stars) AS REAL) / COUNT(T3.Stars) AS average FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN reviews AS T3 ON T2.district_id = T3.district_id WHERE T1.State = 'Oregon'", "index": 164, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Star', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Oregon', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage = DIVIDE(SUM(State = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';\nWhat is the average number of stars given by Oregon clients in their reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Norwalk', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n city text, -- example: ['Norwalk', 'Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age); Norwalk refers to city = 'Norwalk';\nWhat is the average age of Norwalk clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk'", "index": 165, "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 callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Norwalk', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n city text, -- example: ['Norwalk', 'Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = AVG(age); Norwalk refers to city = 'Norwalk';\nWhat is the average age of Norwalk clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['HI', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Kyran', 'Emma', 'Noah']\n last text, -- example: ['Muller', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['HI', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['HI', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 it was submitted refers to \"Submitted via\";\nHow did Kyran Muller submit his complaint?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.`Submitted via` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kyran' AND T1.last = 'Muller'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT DISTINCT T2.`Submitted via` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kyran' AND T1.last = 'Muller'", "index": 166, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['HI', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Kyran', 'Emma', 'Noah']\n last text, -- example: ['Muller', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['HI', 'NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['HI', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 it was submitted refers to \"Submitted via\";\nHow did Kyran Muller submit his complaint?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear > 2005;\nWhat are the products that people who were born after 2005 complain about?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year > 2005", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year > 2005", "index": 167, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear > 2005;\nWhat are the products that people who were born after 2005 complain about?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlongest server time refers to MAX(ser_time);\nWhat was the issue that the client with the longest server time faced?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Issue FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.Issue FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )", "index": 168, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlongest server time refers to MAX(ser_time);\nWhat was the issue that the client with the longest server time faced?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Fax', 'Email']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n server text, -- example: ['MICHAL', 'TOVA']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n city text, -- example: ['New York City', 'Albuquerque']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsubmitted complaints via fax refers to \"Submitted via\" = 'Fax';\nHow many clients who live in New York City submitted their complaints via fax?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City' AND T2.`Submitted via` = 'Fax'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City' AND T2.`Submitted via` = 'Fax'", "index": 169, "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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Fax', 'Email']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['New York', 'Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n server text, -- example: ['MICHAL', 'TOVA']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n city text, -- example: ['New York City', 'Albuquerque']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsubmitted complaints via fax refers to \"Submitted via\" = 'Fax';\nHow many clients who live in New York City submitted their complaints via fax?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(sex = 'Male'), COUNT(client_id)), 1.0); male refers to sex = 'Male'; credit cards refers to Product = 'Credit card';\nWhat is the percentage of male clients complaining about their credit cards?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T1.sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T1.sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card'", "index": 170, "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 Product text, -- example: ['Credit card', 'Bank account or service']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage = MULTIPLY(DIVIDE(SUM(sex = 'Male'), COUNT(client_id)), 1.0); male refers to sex = 'Male'; credit cards refers to Product = 'Credit card';\nWhat is the percentage of male clients complaining about their credit cards?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Untimely response', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nno dispute refers to Consumer disputed? = 'No'; non-timely response refers to Timely response? = 'No'\nHow many times does the consumer have no dispute over a non-timely response from the company?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(`Timely response?`) FROM events WHERE `Timely response?` = 'No' AND `Consumer disputed?` = 'No'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(`Timely response?`) FROM events WHERE `Timely response?` = 'No' AND `Consumer disputed?` = 'No'", "index": 171, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Company response to consumer` text, -- example: ['Untimely response', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Avaya', 'Everest']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nno dispute refers to Consumer disputed? = 'No'; non-timely response refers to Timely response? = 'No'\nHow many times does the consumer have no dispute over a non-timely response from the company?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:15:00', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlonger than 15 minutes refers to ser_time > '00:15:00'\nHow many of the complaints are longer than 15 minutes?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(ser_time) FROM callcenterlogs WHERE strftime('%M', ser_time) > '15'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(ser_time) FROM callcenterlogs WHERE strftime('%M', ser_time) > '15'", "index": 172, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:15:00', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlonger than 15 minutes refers to ser_time > '00:15:00'\nHow many of the complaints are longer than 15 minutes?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Pacific', 'Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, last\nList the full names of all clients who live in the Pacific division.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.first, T2.middle, T2.last FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.division = 'Pacific'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.first, T2.middle, T2.last FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.division = 'Pacific'", "index": 173, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Pacific', 'Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, last\nList the full names of all clients who live in the Pacific division.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Person', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsocial number refers to social; most complaints refers to max(count(event.Client_ID))\nWhat is the social number of the person who made the most complaints?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.social FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID GROUP BY T1.client_id ORDER BY COUNT(T1.client_id) DESC LIMIT 1", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.social FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID GROUP BY T1.client_id ORDER BY COUNT(T1.client_id) DESC LIMIT 1", "index": 174, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Person', 'Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsocial number refers to social; most complaints refers to max(count(event.Client_ID))\nWhat is the social number of the person who made the most complaints?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Star', 'Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_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 refers to max(count(state_abbrev)); 1 star review refers to Stars = 1\nWhich is the city where most of the 1 star reviews come from?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 1 GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 1 GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1", "index": 175, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Star', 'Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_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 refers to max(count(state_abbrev)); 1 star review refers to Stars = 1\nWhich is the city where most of the 1 star reviews come from?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n first text, -- example: ['Elliott', 'Kaitlyn', 'Eliza', 'Emma', 'Noah']\n middle text, -- example: ['Elliott', 'Kaitlyn', 'Eliza', 'Avaya', 'Everest']\n last text, -- example: ['Elliott', 'Smith', 'Thompson']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList all the issues of the complaints made by Kaitlyn Eliza Elliott.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kaitlyn' AND T1.middle = 'Eliza' AND T1.last = 'Elliott'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT DISTINCT T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kaitlyn' AND T1.middle = 'Eliza' AND T1.last = 'Elliott'", "index": 176, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n first text, -- example: ['Elliott', 'Kaitlyn', 'Eliza', 'Emma', 'Noah']\n middle text, -- example: ['Elliott', 'Kaitlyn', 'Eliza', 'Avaya', 'Everest']\n last text, -- example: ['Elliott', 'Smith', 'Thompson']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList all the issues of the complaints made by Kaitlyn Eliza Elliott.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2013-09-11', '2014-07-03', '2012-04-12']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2013-09-11', '2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n first text, -- example: ['Moriah', 'Emma', 'Noah']\n middle text, -- example: ['Moriah', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-09-11', '2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2013-09-11', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MORIAH', 'MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nowner refers to first, middle, last; on 9/11/2013 refers to Date received = '2013-09-11'\nWho is the owner of the final phone number for the complaints on server \"MORIAH\" on 9/11/2013?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.server = 'MORIAH' AND T2.`Date received` = '2013-09-11'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.server = 'MORIAH' AND T2.`Date received` = '2013-09-11'", "index": 177, "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 `Date received` date, -- example: ['2013-09-11', '2014-07-03', '2012-04-12']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2013-09-11', '2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n first text, -- example: ['Moriah', 'Emma', 'Noah']\n middle text, -- example: ['Moriah', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-09-11', '2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2013-09-11', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MORIAH', 'MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nowner refers to first, middle, last; on 9/11/2013 refers to Date received = '2013-09-11'\nWho is the owner of the final phone number for the complaints on server \"MORIAH\" on 9/11/2013?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Max', 'Avaya', 'Everest']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nteenager refers to 13 < age < = 19; adult refers to 19 < age < = 65; elder refers to age < = 65; highest average time per complaint = max(divide(sum(ser_time), count(ser_time)))\nCompute the average time in minute for each 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 CAST(SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END) AS teenagerAverageMins, CAST(SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adultAverageMins , CAST(SUM(CASE WHEN T1.age > 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS elderAverageMins FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client`", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END) AS teenagerAverageMins, CAST(SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adultAverageMins , CAST(SUM(CASE WHEN T1.age > 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS elderAverageMins FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client`", "index": 178, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n age integer, -- example: [29, 54]\n middle text, -- example: ['Max', 'Avaya', 'Everest']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nteenager refers to 13 < age < = 19; adult refers to 19 < age < = 65; elder refers to age < = 65; highest average time per complaint = max(divide(sum(ser_time), count(ser_time)))\nCompute the average time in minute for each 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 events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Other', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Other', 'N/A', 'Consent not provided']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nteenager refers to 13 < age < = 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com'\nAmong the teenager clients who use Google account and Microsoft account, which group of client is more than the other?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 CASE WHEN SUM(CASE WHEN email LIKE '%@gmail.com' THEN 1 ELSE 0 END) > SUM(CASE WHEN email LIKE '%@outlook.com' THEN 1 ELSE 0 END) THEN 'Google account' ELSE 'Microsoft account' END FROM client WHERE age BETWEEN 13 AND 19", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CASE WHEN SUM(CASE WHEN email LIKE '%@gmail.com' THEN 1 ELSE 0 END) > SUM(CASE WHEN email LIKE '%@outlook.com' THEN 1 ELSE 0 END) THEN 'Google account' ELSE 'Microsoft account' END FROM client WHERE age BETWEEN 13 AND 19", "index": 179, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Other', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['Other', 'N/A', 'Consent not provided']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nteenager refers to 13 < age < = 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com'\nAmong the teenager clients who use Google account and Microsoft account, which group of client is more than the other?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emily.garcia43@outlook.com', 'emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first middle last\nWhat is the full name of client whose email address is emily.garcia43@outlook.com?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 first, middle, last FROM client WHERE email = 'emily.garcia43@outlook.com'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT first, middle, last FROM client WHERE email = 'emily.garcia43@outlook.com'", "index": 180, "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 district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emily.garcia43@outlook.com', 'emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first middle last\nWhat is the full name of client whose email address is emily.garcia43@outlook.com?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfirst name refers to first; highest priority refers to priority = 2\nWhat is the first name of clients who have the highest priority?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = ( SELECT MAX(priority) FROM callcenterlogs )", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.first FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = ( SELECT MAX(priority) FROM callcenterlogs )", "index": 181, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfirst name refers to first; highest priority refers to priority = 2\nWhat is the first name of clients who have the highest priority?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n last text, -- example: ['York', 'Smith', 'Thompson']\n city text, -- example: ['New York City', 'Albuquerque']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNew York City refers to city = 'New York City'\nHow many clients who live in New York City have the complaint outcome as \"AGENT\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.`rand client`) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.city = 'New York City' AND T2.outcome = 'AGENT'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T2.`rand client`) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.city = 'New York City' AND T2.outcome = 'AGENT'", "index": 182, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n age integer, -- example: [29, 54]\n last text, -- example: ['York', 'Smith', 'Thompson']\n city text, -- example: ['New York City', 'Albuquerque']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNew York City refers to city = 'New York City'\nHow many clients who live in New York City have the complaint outcome as \"AGENT\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfirst name start with alphabet \"B\" refers to first like 'B%'\nWrite down the call id of clients whose first name start with alphabet \"B\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.call_id FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.first LIKE 'B%'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.call_id FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.first LIKE 'B%'", "index": 183, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfirst name start with alphabet \"B\" refers to first like 'B%'\nWrite down the call id of clients whose first name start with alphabet \"B\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n age integer, -- example: [29, 54]\n first text, -- example: ['Alexander', 'Lewis', 'Bronx', 'Emma', 'Noah']\n middle text, -- example: ['Alexander', 'Lewis', 'Bronx', 'Avaya', 'Everest']\n last text, -- example: ['Alexander', 'Lewis', 'Smith', 'Thompson']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the product complained by Alexander Bronx Lewis?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Alexander' AND T1.middle = 'Bronx' AND T1.last = 'Lewis'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Alexander' AND T1.middle = 'Bronx' AND T1.last = 'Lewis'", "index": 184, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n age integer, -- example: [29, 54]\n first text, -- example: ['Alexander', 'Lewis', 'Bronx', 'Emma', 'Noah']\n middle text, -- example: ['Alexander', 'Lewis', 'Bronx', 'Avaya', 'Everest']\n last text, -- example: ['Alexander', 'Lewis', 'Smith', 'Thompson']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhat is the product complained by Alexander Bronx Lewis?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_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 complaints refers to max(client_id); elder client refers to age > 65\nWhich product received the most complaints from elder clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.age > 65 ORDER BY T1.client_id DESC LIMIT 1", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.age > 65 ORDER BY T1.client_id DESC LIMIT 1", "index": 185, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n outcome text, -- example: ['AGENT', 'HANG']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_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 complaints refers to max(client_id); elder client refers to age > 65\nWhich product received the most complaints from elder clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:10:00', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserver time of below 10 minutes refers to ser_time < '00:10:00'\nList down the issues for complaint with server time of below 10 minutes.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.Issue FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE strftime('%M', T1.ser_time) < '10'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.Issue FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE strftime('%M', T1.ser_time) < '10'", "index": 186, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:10:00', '00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nserver time of below 10 minutes refers to ser_time < '00:10:00'\nList down the issues for complaint with server time of below 10 minutes.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with relief', 'Closed', 'Closed with explanation']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = avg(age where Company response to consumer = 'Closed with relief'); response \"Closed with relief\" refers to Company response to consumer = 'Closed with relief'\nCalculate the average age of clients whose response is \"Closed with relief\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 AVG(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'Closed with relief'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT AVG(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'Closed with relief'", "index": 187, "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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with relief', 'Closed', 'Closed with explanation']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage age = avg(age where Company response to consumer = 'Closed with relief'); response \"Closed with relief\" refers to Company response to consumer = 'Closed with relief'\nCalculate the average age of clients whose response is \"Closed with relief\".\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-01-01', '2014-12-30', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-01-01', '2014-12-30', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-01-01', '2014-12-30', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['AVIDAN', 'MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n social text, -- example: ['926-93-2157', '806-94-5725']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfinal phone number refers to phonefinal; from 1/1/2014 to 12/30/2014 refers to Date received between '2014-01-01' and '2014-12-30'\nWrite the complaint ID, call ID, and final phone number of complaints through AVIDAN server from 1/1/2014 to 12/30/2014.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Complaint ID`, call_id, phonefinal FROM callcenterlogs WHERE strftime('%Y', `Date received`) = '2014' AND server = 'AVIDAN'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT `Complaint ID`, call_id, phonefinal FROM callcenterlogs WHERE strftime('%Y', `Date received`) = '2014' AND server = 'AVIDAN'", "index": 188, "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 state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-01-01', '2014-12-30', '2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-01-01', '2014-12-30', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-01-01', '2014-12-30', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n server text, -- example: ['AVIDAN', 'MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n social text, -- example: ['926-93-2157', '806-94-5725']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ID', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfinal phone number refers to phonefinal; from 1/1/2014 to 12/30/2014 refers to Date received between '2014-01-01' and '2014-12-30'\nWrite the complaint ID, call ID, and final phone number of complaints through AVIDAN server from 1/1/2014 to 12/30/2014.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Credit card', 'Bank account or service']\n Issue text, -- example: ['Overlimit fee', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card customer refers to product = 'Credit card'; about overlimit fees refers to issue = 'Overlimit fee'\nHow many times per year does a credit card customer complain about overlimit fees?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT strftime('%Y', `Date received`), COUNT(`Date received`) FROM events WHERE product = 'Credit card' AND issue = 'Overlimit fee' GROUP BY strftime('%Y', `Date received`) HAVING COUNT(`Date received`)", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT strftime('%Y', `Date received`), COUNT(`Date received`) FROM events WHERE product = 'Credit card' AND issue = 'Overlimit fee' GROUP BY strftime('%Y', `Date received`) HAVING COUNT(`Date received`)", "index": 189, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Credit card', 'Bank account or service']\n Issue text, -- example: ['Overlimit fee', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card customer refers to product = 'Credit card'; about overlimit fees refers to issue = 'Overlimit fee'\nHow many times per year does a credit card customer complain about overlimit fees?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n middle text, -- example: ['Star', 'Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n5-star rating refers to Stars = 5; in 2016 refers to Date like '2016%'; most reviews refers to max(count(city))\nList the top five cities in terms of the number of 5-star ratings in 2016 reviews, in descending order.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 AND T1.Date LIKE '2016%' ORDER BY T1.Date DESC LIMIT 5", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 AND T1.Date LIKE '2016%' ORDER BY T1.Date DESC LIMIT 5", "index": 190, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n middle text, -- example: ['Star', 'Max', 'Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n5-star rating refers to Stars = 5; in 2016 refers to Date like '2016%'; most reviews refers to max(count(city))\nList the top five cities in terms of the number of 5-star ratings in 2016 reviews, in descending order.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ME', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n phone text, -- example: ['100-121-8371', '367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ME', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ME', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsocial number refers to social\nGive me the social number and state of the client whose phone number is 100-121-8371.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.social, T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.phone = '100-121-8371'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.social, T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.phone = '100-121-8371'", "index": 191, "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 reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['ME', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n phone text, -- example: ['100-121-8371', '367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['ME', 'NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['ME', 'AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsocial number refers to social\nGive me the social number and state of the client whose phone number is 100-121-8371.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Pacific', 'Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, middle, last; the Pacific refers to division = 'Pacific'\nList the full names and phone numbers of clients that were from the Pacific.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific'", "index": 192, "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 district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Pacific', 'Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfull name refers to first, middle, last; the Pacific refers to division = 'Pacific'\nList the full names and phone numbers of clients that were from the Pacific.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_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 age refers to max(age); male refers to sex = 'Male'\nWhat is the oldest age of male clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 client WHERE sex = 'Male'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT MAX(age) FROM client WHERE sex = 'Male'", "index": 193, "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 client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Male', 'Female']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Max', 'Emma', 'Noah']\n last text, -- example: ['Smith', 'Thompson']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n type text, -- example: ['NW', 'PS']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_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 age refers to max(age); male refers to sex = 'Male'\nWhat is the oldest age of male clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\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 sex = 'Female'; the Middle Atlantic refers to division = 'Middle Atlantic'; percentage = divide(count(client_id where sex = 'Female' and division = 'Middle Atlantic') , count(client_id where division = 'Middle Atlantic')) * 100%\nWhat is the percentage of female clients in the Middle Atlantic?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 T1.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T1.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic'", "index": 194, "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 callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\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 sex = 'Female'; the Middle Atlantic refers to division = 'Middle Atlantic'; percentage = divide(count(client_id where sex = 'Female' and division = 'Middle Atlantic') , count(client_id where division = 'Middle Atlantic')) * 100%\nWhat is the percentage of female clients in the Middle Atlantic?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 reviews (\n `Date` date, -- example: ['2014-07-03', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-03', '2014-07-07', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n7/3/2014 refers to Date received = '2014-07-03'\nPlease list the emails of the clients whose complaint date received is 7/3/2014.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.email FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2014-07-03'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.email FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2014-07-03'", "index": 195, "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 reviews (\n `Date` date, -- example: ['2014-07-03', '2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n first text, -- example: ['Emma', 'Noah']\n middle text, -- example: ['Avaya', 'Everest']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Albuquerque', 'New York City']\n state text, -- example: ['NM', 'NY']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n Region text, -- example: ['South', 'West']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n call_id integer, -- example: [34536, 34537]\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2014-07-07', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer complaint narrative` text, -- example: ['Deposited a XXXX check into my account, ', \"I called Eagle National Bank 's customer\"]\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-03', '2014-07-07', '2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n7/3/2014 refers to Date received = '2014-07-03'\nPlease list the emails of the clients whose complaint date received is 7/3/2014.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfrom 2012 to 2015 refers to Date received BETWEEN 2012 AND 2015; submitted via email refers to Submitted via = 'Email'; female refers to sex = 'Female'\nFrom 2012 to 2015, how many complaints were submitted via email from female clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) BETWEEN '2012' AND '2015' AND T2.`Submitted via` = 'Email' AND T1.sex = 'Male'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) BETWEEN '2012' AND '2015' AND T2.`Submitted via` = 'Email' AND T1.sex = 'Male'", "index": 196, "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 `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Tags text, -- example: ['Older American', 'Older American, Servicemember']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n type text, -- example: ['NW', 'PS']\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfrom 2012 to 2015 refers to Date received BETWEEN 2012 AND 2015; submitted via email refers to Submitted via = 'Email'; female refers to sex = 'Female'\nFrom 2012 to 2015, how many complaints were submitted via email from female clients?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['In progress', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 progress refers to Company response to consumer = 'In progress'\nPlease list all clients' phone numbers and complaint IDs which are still in progress.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.phone, T2.`Complaint ID` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'In progress'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT T1.phone, T2.`Complaint ID` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'In progress'", "index": 197, "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 state (\n StateCode text, -- example: ['ID', 'AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n sex text, -- example: ['Female', 'Male']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n last text, -- example: ['Smith', 'Thompson']\n phone text, -- example: ['367-171-6840', '212-423-7734']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Sub-product` text, -- example: ['Checking account', 'Savings account']\n Issue text, -- example: ['Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Phone', 'Email', 'Fax']\n `Date sent to company` text, -- example: ['2014-07-09', '2012-04-13']\n `Company response to consumer` text, -- example: ['In progress', 'Closed with explanation', 'Closed with relief']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n Product text, -- example: ['Eagle National Mortgage', 'Eagle National Bank']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['New York City', 'Jacksonville']\n state_abbrev text, -- example: ['ID', 'NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n outcome text, -- example: ['AGENT', 'HANG']\n server text, -- example: ['MICHAL', 'TOVA']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_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 progress refers to Company response to consumer = 'In progress'\nPlease list all clients' phone numbers and complaint IDs which are still in progress.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Billing disputes', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Portland', 'Billings', 'Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Portland', 'Billings', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin 2015 refers to Date received LIKE'2015%'; about Billing disputes refers to Issue = 'Billing disputes'; Portland refers to city = 'Portland'\nIn 2015, how many complaints about Billing disputes were sent by clients in Portland?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'Portland' AND T2.`Date received` LIKE '2015%' AND T2.Issue = 'Billing disputes'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'Portland' AND T2.`Date received` LIKE '2015%' AND T2.Issue = 'Billing disputes'", "index": 198, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n State text, -- example: ['Alabama', 'Arkansas']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n Product text, -- example: ['Bank account or service', 'Credit card']\n Issue text, -- example: ['Billing disputes', 'Deposits and withdrawals', 'Account opening, closing, or management']\n `Sub-issue` text,\n `Consumer consent provided?` text, -- Tags Consumer consent provided?, example: ['N/A', 'Consent not provided']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Timely response?` text, -- example: ['Yes', 'No']\n `Consumer disputed?` text, -- example: ['No', 'Yes']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Stars integer, -- example: [5, 1]\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `month` integer, -- example: [12, 2]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n social text, -- example: ['926-93-2157', '806-94-5725']\n middle text, -- example: ['Avaya', 'Everest']\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n address_1 text, -- example: ['387 Wellington Ave.', '75 W. Berkshire St.']\n address_2 text, -- example: ['Unit 1', 'Unit 6']\n city text, -- example: ['Portland', 'Billings', 'Albuquerque', 'New York City']\n zipcode integer, -- example: [47246, 10040]\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n phonefinal text, -- example: ['977-806-9726', '322-598-7152']\n `vru+line` text, -- voice response unit line, example: ['AA0103', 'AA0205']\n priority integer, -- example: [0, 2]\n type text, -- example: ['NW', 'PS']\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_exit text, -- server exit, example: ['13:40:23', '11:16:10']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n city text, -- example: ['Portland', 'Billings', 'New York City', 'Jacksonville']\n state_abbrev text, -- example: ['NY', 'FL']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin 2015 refers to Date received LIKE'2015%'; about Billing disputes refers to Issue = 'Billing disputes'; Portland refers to city = 'Portland'\nIn 2015, how many complaints about Billing disputes were sent by clients in Portland?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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 state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n city text, -- example: ['Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreceived in 2012 refers to Date received LIKE '2012%'; submitted through email refers to Submitted via = 'Email'\nIn the complains received in 2012, how many of them are submitted through email?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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(`Submitted via`) FROM events WHERE strftime('%Y', `Date received`) = '2012' AND `Submitted via` = 'Email'", "style": "rule" }
{ "db_id": "retail_complains.sqlite", "gt_sql": "SELECT COUNT(`Submitted via`) FROM events WHERE strftime('%Y', `Date received`) = '2012' AND `Submitted via` = 'Email'", "index": 199, "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 state (\n StateCode text, -- example: ['AL', 'AR']\n PRIMARY KEY (StateCode)\n);\n\nCREATE TABLE client (\n client_id text, -- example: ['C00000001', 'C00000002']\n `day` integer, -- example: [13, 4]\n `year` integer, -- example: [1990, 1965]\n age integer, -- example: [29, 54]\n email text, -- example: ['emma.smith@gmail.com', 'noah.thompson@gmail.com']\n city text, -- example: ['Albuquerque', 'New York City']\n district_id integer, -- example: [18, 1]\n PRIMARY KEY (client_id),\n CONSTRAINT fk_client_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE reviews (\n `Date` date, -- example: ['2013-02-04', '2013-02-06']\n Reviews text, -- example: ['Great job, Eagle National! Each person w', 'Matthew Richardson is professional and h']\n district_id integer, -- example: [65, 66]\n PRIMARY KEY (`Date`),\n CONSTRAINT fk_reviews_district_id FOREIGN KEY (district_id) REFERENCES district (district_id)\n);\n\nCREATE TABLE callcenterlogs (\n `Date received` date, -- example: ['2017-03-27', '2017-03-23']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n `rand client` text, -- example: ['C00004587', 'C00003328']\n priority integer, -- example: [0, 2]\n ser_start text, -- server start, example: ['13:34:11', '10:58:22']\n ser_time text, -- server time, example: ['00:06:12', '00:17:48']\n PRIMARY KEY (`Complaint ID`),\n CONSTRAINT fk_callcenterlogs_rand_client FOREIGN KEY (`rand client`) REFERENCES client (client_id)\n);\n\nCREATE TABLE district (\n district_id integer, -- example: [1, 2]\n state_abbrev text, -- example: ['NY', 'FL']\n division text, -- example: ['Middle Atlantic', 'South Atlantic']\n PRIMARY KEY (district_id),\n CONSTRAINT fk_district_state_abbrev FOREIGN KEY (state_abbrev) REFERENCES state (StateCode)\n);\n\nCREATE TABLE events (\n `Date received` date, -- example: ['2014-07-03', '2012-04-12']\n `Submitted via` text, -- example: ['Email', 'Fax']\n `Complaint ID` text, -- example: ['CR0000072', 'CR0000084']\n Client_ID text, -- example: ['C00003714', 'C00001366']\n PRIMARY KEY (`Complaint ID`, Client_ID),\n CONSTRAINT fk_events_complaint_id FOREIGN KEY (`Complaint ID`) REFERENCES callcenterlogs (`Complaint ID`),\n CONSTRAINT fk_events_client_id FOREIGN KEY (Client_ID) REFERENCES client (client_id)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nreceived in 2012 refers to Date received LIKE '2012%'; submitted through email refers to Submitted via = 'Email'\nIn the complains received in 2012, how many of them are submitted through email?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\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" }