input
stringlengths
358
16.1k
output
stringlengths
24
805
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the first names of the employees who work as Managing Editor. [/INST]
SELECT T1.fname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Managing Editor';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the highest level of job to get to for the employee who got hired the earliest? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: In which city is the store with the highest total sales quantity located? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the price of the book that sells the best? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the stores that ordered the book "Life Without Fear". [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: In which country is the publisher of the book "Life Without Fear" located? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the publisher that has published the most expensive book? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Among the publishers in the USA, how many of them have published books that are over $15? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Please give more detailed information about the first three books that sell the best. [/INST]
SELECT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id ORDER BY T2.qty DESC LIMIT 3;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: How many books on business have the bookstores in Massachusetts ordered? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average quantity of each order for the book "Life Without Fear"? [/INST]
SELECT CAST(SUM(T2.qty) AS REAL) / COUNT(T1.title_id) FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T1.title = 'Life Without Fear';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average level employees working as Managing Editor are at? How many levels are there between the average level and the highest level? [/INST]
SELECT AVG(T2.job_lvl), T1.max_lvl - AVG(T2.job_lvl) FROM jobs AS T1 INNER JOIN employee AS T2 ON T1.job_id = T2.job_id WHERE T1.job_desc = 'Managing Editor' GROUP BY T2.job_id, T1.max_lvl;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which one is the cheapest business book? [/INST]
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which type of book had the most pre-paid amount? [/INST]
SELECT type FROM titles ORDER BY advance DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What's the royalty for the bestseller book? [/INST]
SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which job level is O'Rourke at? [/INST]
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Show me the employ id of the highest employee who doesn't have a middle name. [/INST]
SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Is the author of "Sushi, Anyone?" on the contract? [/INST]
SELECT T1.contract FROM authors AS T1 INNER JOIN titleauthor AS T2 ON T1.au_id = T2.au_id INNER JOIN titles AS T3 ON T2.title_id = T3.title_id WHERE T3.title = 'Sushi, Anyone?';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which publisher had the highest job level? Give his/her full name. [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What's Pedro S Afonso's job title? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: How many levels are there left for Diego W Roel to reach if he/she could go to the max level for his/her position? [/INST]
SELECT T2.max_lvl - T1.job_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Diego' AND T1.minit = 'W' AND T1.lname = 'Roel';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What's on the notes for the order happened on 1994/9/14? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List the type of the book for the order which was sold on 1993/5/29. [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Tell me about the information of the French publisher. [/INST]
SELECT T1.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'France';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What's the publisher of the book "Silicon Valley Gastronomic Treats"? Give the publisher's name. [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which city did Victoria P Ashworth work in? [/INST]
SELECT T2.city FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.fname = 'Victoria' AND T1.minit = 'P' AND T1.lname = 'Ashworth';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: How many sales did the store in Remulade make? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Among all the employees, how many percent more for the publishers than designers? [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Find and list the full name of employees who were hired between 1990 and 1995. Also, arrange them in the descending order of job level. [/INST]
SELECT fname, minit, lname FROM employee WHERE STRFTIME('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which titles has above average royalty rate? Give those title's name, type and price? [/INST]
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 );
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price. [/INST]
SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T2.ord_date LIKE '1994%' AND T2.Qty < ( SELECT CAST(SUM(T4.qty) AS REAL) / COUNT(T3.title_id) FROM titles AS T3 INNER JOIN sales AS T4 ON T3.title_id = T4.title_id );
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price. [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty. [/INST]
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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Find the difference between the average royalty of titles published by US and non US publishers? [/INST]
SELECT (CAST(SUM(CASE WHEN T2.country = 'USA' THEN T1.royalty ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T2.country != 'USA' THEN T1.royalty ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.country != 'USA' THEN 1 ELSE 0 END)) 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;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average level difference between the Marketing editors hired by the US and non-US publishers? [/INST]
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';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book? [/INST]
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.';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Of the titles, which title is about the Carefully researched study of the effects of strong emotions on the body, which state-based publisher published this book, and what is the year-to-date sale? [/INST]
SELECT T1.title, T2.pub_name, T1.ytd_sales FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores? [/INST]
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;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: On which day was the most verbose complaint received? [/INST]
SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs );
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: When did the earliest complaint start on 2017/3/22? [/INST]
SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which complaint is more urgent, complaint ID CR2400594 or ID CR2405641? [/INST]
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;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Please list the full names of all the male clients born after the year 1990. [/INST]
SELECT first, middle, last FROM client WHERE year > 1990;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many complaints have the client Diesel Galloway filed? [/INST]
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Was the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: For how long was the complaint filed by Matthew Pierce on 2016/10/28 delayed? [/INST]
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`)) 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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the full name of the client whose complaint on 2017/3/27 was received by MICHAL? [/INST]
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.`Date received` = '2017-03-27' AND T2.server = 'MICHAL';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: For how long did the complaint filed on 2017/3/27 by Rachel Hicks last? [/INST]
SELECT T2.ser_time FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.first = 'Rachel' AND T1.last = 'Hicks' AND T2.`Date received` = '2017-03-27';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Please list the full names of all the clients whose complaints are still in progress. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Among the clients who did receive a timely response for their complaint, how many of them are from New York? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many complaints on credit cards in the year 2016 were filed by male clients? [/INST]
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) = '2016' AND T1.sex = 'Male' AND T2.Product = 'Credit card';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which division is Diesel Galloway in? [/INST]
SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Diesel' AND T1.last = 'Galloway';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Please list the full names of all the male clients in the Pacific division. [/INST]
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific' AND T1.sex = 'Male';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What was the serve time for the complaint call from client "C00007127" on 2017/2/22? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which state does the owner of "[email protected]" live in? Give the full name of the state. [/INST]
SELECT T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = '[email protected]';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which detailed product did Mr Lennox Oliver Drake complain about? [/INST]
SELECT DISTINCT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lennox' AND T1.middle = 'Oliver' AND T1.last = 'Drake' AND T1.sex = 'Male';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What was the detailed issue did Mr Gunner Omer Fuller complain about? [/INST]
SELECT T2.`Sub-issue` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Gunner' AND T1.middle = 'Omer' AND T1.last = 'Fuller' AND T1.sex = 'Male';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Did Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which district did the review on 2018/9/11 come from? Give the name of the city. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What was the review context from Jacksonville on 2017/7/22? [/INST]
SELECT T1.Reviews FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Jacksonville' AND T1.Date = '2017-07-22';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which product received a review from Indianapolis on 2016/10/7? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many stars did "Eagle Capital" received from Little Rock on 2013/4/4? [/INST]
SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T2.city = 'Little Rock' AND T1.Date = '2013-04-04';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: For the client who made the complaint call "CR0217298", what was his/her birthday? [/INST]
SELECT T1.month, T1.day FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0217298';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What was the phone of number of the client who made the complaint call "CR0100432" ? [/INST]
SELECT T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0100432';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: For all the complaint callers on 2017/3/27, what percentage of the clients are females? [/INST]
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 events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2017-03-27';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the percentage of the complaint calls from Mr Mason Javen Lopez has got the consent provided by the customer? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints. [/INST]
SELECT COUNT(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs );
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Please list the full name, date of birth, and email id of the elderly clients in descending order of age. [/INST]
SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Which product got the most five stars, and how many? [/INST]
SELECT T.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: List all the states in the South region. [/INST]
SELECT state FROM state WHERE Region = 'South';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the email id of clients whose calls were hung? [/INST]
SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.outcome = 'HANG';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Calculate the average age of clients from the Midwest region. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: List the full name and phone number of clients who submitted the complaint via fax. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Find and list the names of districts which has below-average stars for Eagle Capital. [/INST]
SELECT T2.division FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T1.Stars > ( SELECT AVG(Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id );
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: In the calls from the mountain division, how many are from teenage clients? [/INST]
SELECT COUNT(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.age BETWEEN 12 AND 20 AND T2.division = 'Mountain';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the number of complaints related to Credit cards came from female clients? [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Among the clients born between 1980 and 2000, list the name of male clients who complained through referral. [/INST]
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year BETWEEN 1980 AND 2000 AND T1.sex = 'Male' AND T2.`Submitted via` = 'Referral';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What is the medium through which most complaints are registered in Florida? [/INST]
SELECT T3.`Submitted via` FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.state = 'FL' GROUP BY T1.`Complaint ID` ORDER BY COUNT(T1.`Complaint ID`) DESC LIMIT 1;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Calculate the average number of complaints received from New Bedford each year which are closed with explanation. [/INST]
SELECT STRFTIME('%Y', T3.`Date received`) , CAST(SUM(CASE WHEN T3.`Company response to consumer` = 'Closed with explanation' THEN 1 ELSE 0 END) AS REAL) / COUNT(T3.`Complaint ID`) AS average FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.city = 'New Bedford' GROUP BY strftime('%Y', T3.`Date received`);
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: What percentage of consumers from Houston disputed complaints? [/INST]
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;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Find the number of service members who complained in Syracuse. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Among the calls from California, what percentage are priority 1? [/INST]
SELECT CAST(SUM(CASE WHEN T1.priority = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.priority) 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 T4.State = 'California';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Calculate the difference in the average age of elderly and middle-aged clients in the Northeast region. [/INST]
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';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: List by their ID number the 3 longest complaints. [/INST]
SELECT `Complaint ID` FROM callcenterlogs ORDER BY ser_time DESC LIMIT 3;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many clients have an email account other than gmail.com? [/INST]
SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: Identify by their ID all clients who did not give their consent permission. [/INST]
SELECT Client_ID FROM events WHERE `Consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = '';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: List by their ID the complaints received by the company on 25/09/2014 that took the longest. [/INST]
SELECT `Complaint ID` FROM events WHERE strftime('%J', `Date sent to company`) - strftime('%J', `Date received`) = ( SELECT MAX(strftime('%J', `Date sent to company`) - strftime('%J', `Date received`)) FROM events WHERE `Date sent to company` = '2014-09-25' ) AND `Date sent to company` = '2014-09-25';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: List priority 2 complaints by date received. [/INST]
SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many complaints are not in process with an agent? [/INST]
SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many Credit Card complaints did Sharon handle? [/INST]
SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Product = 'Credit card' AND T1.server = 'SHARON';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: In which region have the most 1-star reviews been done? [/INST]
SELECT T3.Region FROM reviews 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.Stars = 1 GROUP BY T3.Region ORDER BY COUNT(T3.Region) DESC LIMIT 1;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: In what years were the clients who demanded more problems with Certificate of deposit born? [/INST]
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;
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many cases of billing dispute issues occurred in the Mountain division? [/INST]
SELECT COUNT(T1.Issue) FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id WHERE T1.Issue = 'Billing disputes' AND T3.division = 'Mountain';
[INST] Here is a database schema: state : StateCode [ TEXT ] primary_key State [ TEXT ] Region [ TEXT ] callcenterlogs : Date received [ DATE ] Complaint ID [ TEXT ] primary_key rand client [ TEXT ] callcenterlogs.rand client = client.client_id phonefinal [ TEXT ] vru+line [ TEXT ] call_id [ INTEGER ] priority [ INTEGER ] type [ TEXT ] outcome [ TEXT ] server [ TEXT ] ser_start [ TEXT ] ser_exit [ TEXT ] ser_time [ TEXT ] client : client_id [ TEXT ] primary_key sex [ TEXT ] day [ INTEGER ] month [ INTEGER ] year [ INTEGER ] age [ INTEGER ] social [ TEXT ] first [ TEXT ] middle [ TEXT ] last [ TEXT ] phone [ TEXT ] email [ TEXT ] address_1 [ TEXT ] address_2 [ TEXT ] city [ TEXT ] state [ TEXT ] zipcode [ INTEGER ] district_id [ INTEGER ] client.district_id = district.district_id district : district_id [ INTEGER ] primary_key city [ TEXT ] state_abbrev [ TEXT ] district.state_abbrev = state.StateCode division [ TEXT ] events : Date received [ DATE ] Product [ TEXT ] Sub-product [ TEXT ] Issue [ TEXT ] Sub-issue [ TEXT ] Consumer complaint narrative [ TEXT ] Tags [ TEXT ] Consumer consent provided? [ TEXT ] Submitted via [ TEXT ] Date sent to company [ TEXT ] Company response to consumer [ TEXT ] Timely response? [ TEXT ] Consumer disputed? [ TEXT ] Complaint ID [ TEXT ] events.Complaint ID = callcenterlogs.Complaint ID Client_ID [ TEXT ] events.Client_ID = client.client_id reviews : Date [ DATE ] primary_key Stars [ INTEGER ] Reviews [ TEXT ] Product [ TEXT ] district_id [ INTEGER ] reviews.district_id = district.district_id Please write me a SQL statement that answers the following question: How many male clients are from the state of Massachusetts? [/INST]
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';