input
stringlengths 201
2.7k
| output
stringlengths 24
744
|
|---|---|
[INST] Here is a database schema:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
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] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
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] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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
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] [/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:
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 ]
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
Please write me a SQL statement that answers the following question: What is the price of the book that sells the best? [/INST] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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 ]
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
Please write me a SQL statement that answers the following question: Please list the stores that ordered the book "Life Without Fear". [/INST] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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 ]
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
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
Please write me a SQL statement that answers the following question: What is the publisher that has published the most expensive book? [/INST] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
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 ]
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
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] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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 ]
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
Please write me a SQL statement that answers the following question: How many books on business have the bookstores in Massachusetts ordered? [/INST] [/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:
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 ]
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
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] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
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] [/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:
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 ]
Please write me a SQL statement that answers the following question: Which one is the cheapest business book? [/INST] [/INST]
|
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Which type of book had the most pre-paid amount? [/INST] [/INST]
|
SELECT type FROM titles ORDER BY advance DESC LIMIT 1;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: What's the royalty for the bestseller book? [/INST] [/INST]
|
SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Which job level is O'Rourke at? [/INST] [/INST]
|
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke';
|
[INST] Here is a database schema:
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 ]
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] [/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 ]
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 ]
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] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
Please write me a SQL statement that answers the following question: Which publisher had the highest job level? Give his/her full name. [/INST] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
Please write me a SQL statement that answers the following question: What's Pedro S Afonso's job title? [/INST] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
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] [/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:
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 ]
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
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] [/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:
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 ]
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
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
pub_info :
pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id
logo [ BLOB ]
pr_info [ TEXT ]
Please write me a SQL statement that answers the following question: Tell me about the information of the French publisher. [/INST] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
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 ]
Please write me a SQL statement that answers the following question: Which city did Victoria P Ashworth work in? [/INST] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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
Please write me a SQL statement that answers the following question: How many sales did the store in Remulade make? [/INST] [/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:
stores :
stor_id [ TEXT ] primary_key
stor_name [ TEXT ]
stor_address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
zip [ TEXT ]
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
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] [/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:
jobs :
job_id [ INTEGER ] primary_key
job_desc [ TEXT ]
min_lvl [ INTEGER ]
max_lvl [ INTEGER ]
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 ]
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] [/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:
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 ]
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] [/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:
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 ]
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] [/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:
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 ]
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
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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] [/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:
publishers :
pub_id [ TEXT ] primary_key
pub_name [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
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 ]
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
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] [/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:
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
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] [/INST]
|
SELECT first, middle, last FROM client WHERE year > 1990;
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: How many complaints have the client Diesel Galloway filed? [/INST] [/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:
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
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
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] [/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:
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 ]
Please write me a SQL statement that answers the following question: Which division is Diesel Galloway in? [/INST] [/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:
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 ]
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] [/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:
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 ]
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] [/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:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
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
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] [/INST]
|
SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC;
|
[INST] Here is a database schema:
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] [/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 ]
Please write me a SQL statement that answers the following question: List all the states in the South region. [/INST] [/INST]
|
SELECT state FROM state WHERE Region = 'South';
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ 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 ]
Please write me a SQL statement that answers the following question: Calculate the average age of clients from the Midwest region. [/INST] [/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:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
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 ]
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] [/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:
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
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
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] [/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:
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
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
Please write me a SQL statement that answers the following question: Find the number of service members who complained in Syracuse. [/INST] [/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 ]
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 ]
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] [/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:
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
Please write me a SQL statement that answers the following question: How many clients have an email account other than gmail.com? [/INST] [/INST]
|
SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: How many complaints are not in process with an agent? [/INST] [/INST]
|
SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT';
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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] [/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:
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
Please write me a SQL statement that answers the following question: How many cases of billing dispute issues occurred in the Mountain division? [/INST] [/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 ]
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 ]
Please write me a SQL statement that answers the following question: How many male clients are from the state of Massachusetts? [/INST] [/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';
|
[INST] Here is a database schema:
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
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 under the age of 35 gave Eagle National Mortgage 1 star? [/INST] [/INST]
|
SELECT COUNT(T2.age) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle National Mortgage' AND T1.Stars = 1 AND T2.age < 35;
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ 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 ]
Please write me a SQL statement that answers the following question: How many clients with the last name Alvarado are from Maryland? [/INST] [/INST]
|
SELECT COUNT(T2.client_id) FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T1.state_abbrev = T3.StateCode WHERE T2.last = 'Alvarado' AND T2.state = 'MD';
|
[INST] Here is a database schema:
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
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 reviews by people between 30 and 50 years include the word 'great'? [/INST] [/INST]
|
SELECT COUNT(T1.Reviews) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T2.age BETWEEN 30 AND 50 AND T1.Reviews LIKE '%great%';
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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 stars given by Oregon clients in their reviews? [/INST] [/INST]
|
SELECT CAST(SUM(T3.Stars) AS REAL) / COUNT(T3.Stars) AS average FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN reviews AS T3 ON T2.district_id = T3.district_id WHERE T1.State = 'Oregon';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: What is the average age of Norwalk clients? [/INST] [/INST]
|
SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk';
|
[INST] Here is a database schema:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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 who live in Kansas City provided a 1-star review? [/INST] [/INST]
|
SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Kansas City' AND T1.Stars = 1;
|
[INST] Here is a database schema:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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 has the highest number of clients who gave a 5-star review? [/INST] [/INST]
|
SELECT T2.state_abbrev FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 GROUP BY T2.state_abbrev ORDER BY COUNT(T2.state_abbrev) DESC LIMIT 1;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Which region does Noah Thompson live in? [/INST] [/INST]
|
SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Noah' AND T1.last = 'Thompson';
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What are the products that people who were born after 2005 complain about? [/INST] [/INST]
|
SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year > 2005;
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What is the percentage of male clients complaining about their credit cards? [/INST] [/INST]
|
SELECT CAST(SUM(CASE WHEN T1.sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card';
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: What is the birth date of the youngest client? [/INST] [/INST]
|
SELECT day, month, year FROM client ORDER BY year DESC, month DESC, day DESC LIMIT 1;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: How many of the complaints are longer than 15 minutes? [/INST] [/INST]
|
SELECT COUNT(ser_time) FROM callcenterlogs WHERE strftime('%M', ser_time) > '15';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: List the full names of all clients who live in the Pacific division. [/INST] [/INST]
|
SELECT T2.first, T2.middle, T2.last FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.division = 'Pacific';
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What is the social number of the person who made the most complaints? [/INST] [/INST]
|
SELECT T1.social FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID GROUP BY T1.client_id ORDER BY COUNT(T1.client_id) DESC LIMIT 1;
|
[INST] Here is a database schema:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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 is the city where most of the 1 star reviews come from? [/INST] [/INST]
|
SELECT T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 1 GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1;
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: List all the issues of the complaints made by Kaitlyn Eliza Elliott. [/INST] [/INST]
|
SELECT DISTINCT T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kaitlyn' AND T1.middle = 'Eliza' AND T1.last = 'Elliott';
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ 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 ]
Please write me a SQL statement that answers the following question: What is the name of the state that the client with the email "[email protected]" lives in? [/INST] [/INST]
|
SELECT T3.state 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 T3.email = '[email protected]';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Which region has the second most clients? [/INST] [/INST]
|
SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id GROUP BY T2.division ORDER BY COUNT(T2.division) DESC LIMIT 1, 1;
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What percentage of complaints are from the elderly? [/INST] [/INST]
|
SELECT CAST(SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID;
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: Calculate the percentage of male clients from Indianapolis City. [/INST] [/INST]
|
SELECT CAST(SUM(CASE WHEN sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(client_id) FROM client WHERE city = 'Indianapolis';
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: Among the teenager clients who use Google account and Microsoft account, which group of client is more than the other? [/INST] [/INST]
|
SELECT CASE WHEN SUM(CASE WHEN email LIKE '%@gmail.com' THEN 1 ELSE 0 END) > SUM(CASE WHEN email LIKE '%@outlook.com' THEN 1 ELSE 0 END) THEN 'Google account' ELSE 'Microsoft account' END FROM client WHERE age BETWEEN 13 AND 19;
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: What is the full name of client whose email address is [email protected]? [/INST] [/INST]
|
SELECT first, middle, last FROM client WHERE email = '[email protected]';
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What is the product complained by Alexander Bronx Lewis? [/INST] [/INST]
|
SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Alexander' AND T1.middle = 'Bronx' AND T1.last = 'Lewis';
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: Which product received the most complaints from elder clients? [/INST] [/INST]
|
SELECT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.age > 65 ORDER BY T1.client_id DESC LIMIT 1;
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: Complaint about Credit Card mostly came from clients of which age group? [/INST] [/INST]
|
SELECT SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END), SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adult , SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS elder FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card';
|
[INST] Here is a database schema:
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
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
Please write me a SQL statement that answers the following question: What is the full name of clients who have issue about balance transfer? [/INST] [/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.Issue = 'Balance transfer';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Among the clients in Middle Atlantic, how many are them are female and no more than 18 years old? [/INST] [/INST]
|
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Middle Atlantic' AND T1.sex = 'Female' AND T1.age < 18;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Give me the full birthdate, email and phone number of the youngest client in Indianapolis . [/INST] [/INST]
|
SELECT T1.year, T1.month, T1.day, T1.email, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' ORDER BY T1.year DESC, T1.month DESC, T1.day DESC LIMIT 1;
|
[INST] Here is a database schema:
district :
district_id [ INTEGER ] primary_key
city [ TEXT ]
state_abbrev [ TEXT ] district.state_abbrev = state.StateCode
division [ TEXT ]
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 top five cities in terms of the number of 5-star ratings in 2016 reviews, in descending order. [/INST] [/INST]
|
SELECT T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 AND T1.Date LIKE '2016%' ORDER BY T1.Date DESC LIMIT 5;
|
[INST] Here is a database schema:
state :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ 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 ]
Please write me a SQL statement that answers the following question: Give me the social number and state of the client whose phone number is 100-121-8371. [/INST] [/INST]
|
SELECT T1.social, T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.phone = '100-121-8371';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: List the full names and phone numbers of clients that were from the Pacific. [/INST] [/INST]
|
SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific';
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: How many female clients are there older than 30? [/INST] [/INST]
|
SELECT COUNT(sex) FROM client WHERE sex = 'Female' AND age > 30;
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: Please list all first and last names of clients who live in New York city. [/INST] [/INST]
|
SELECT first, last FROM client WHERE city = 'New York City';
|
[INST] Here is a database schema:
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
Please write me a SQL statement that answers the following question: What is the oldest age of male clients? [/INST] [/INST]
|
SELECT MAX(age) FROM client WHERE sex = 'Male';
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: Please calculate the number of clients by each division. [/INST] [/INST]
|
SELECT T2.division, COUNT(T2.division) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id GROUP BY T2.division;
|
[INST] Here is a database schema:
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 ]
Please write me a SQL statement that answers the following question: What is the percentage of female clients in the Middle Atlantic? [/INST] [/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 district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic';
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.