nl
stringlengths
22
185
sql
stringlengths
22
608
db_id
stringclasses
40 values
table_schema
stringclasses
305 values
Find the details of the teachers who have taught the student with the earliest transcript issuance.
SELECT T1.teacher_details FROM Teachers AS T1 JOIN Classes AS T2 ON T1.teacher_id = T2.teacher_id JOIN Transcripts AS T3 ON T2.student_id = T3.student_id ORDER BY T3.date_of_transcript ASC LIMIT 1
cre_Students_Information_Systems
[{'table_name': 'transcripts', 'table_schema': [{'col_name': 'transcript id'}, {'col_name': 'student id'}, {'col_name': 'date of transcript'}, {'col_name': 'transcript details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['transcript id']}, {'table_name': 'teachers', 'table_schema': [{'col_name': 'teacher id'}, {'col_name': 'teacher details'}], 'foreign_key_columns': [], 'primary_keys': ['teacher id']}, {'table_name': 'classes', 'table_schema': [{'col_name': 'class id'}, {'col_name': 'student id'}, {'col_name': 'teacher id'}, {'col_name': 'class details'}], 'foreign_key_columns': ['teacher id', 'student id'], 'primary_keys': ['class id']}]
How much total loan does each student have ? List the student ids and the amounts .
select student_id , sum(amount_of_loan) from student_loans group by student_id
cre_Students_Information_Systems
[{'table_name': 'student loans', 'table_schema': [{'col_name': 'student loan id'}, {'col_name': 'student id'}, {'col_name': 'date of loan'}, {'col_name': 'amount of loan'}, {'col_name': 'other details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['student loan id']}]
For each student, find the student id and the total amount of loan he or she has.
SELECT student_id , sum(amount_of_loan) FROM Student_Loans GROUP BY student_id
cre_Students_Information_Systems
[{'table_name': 'student loans', 'table_schema': [{'col_name': 'student loan id'}, {'col_name': 'student id'}, {'col_name': 'date of loan'}, {'col_name': 'amount of loan'}, {'col_name': 'other details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['student loan id']}]
How many courses does each student take? List the student id, the student biographical data and the course count.
SELECT T1.student_id , T1.bio_data , count(*) FROM Students AS T1 JOIN Classes AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id
cre_Students_Information_Systems
[{'table_name': 'students', 'table_schema': [{'col_name': 'student id'}, {'col_name': 'bio data'}, {'col_name': 'student details'}], 'foreign_key_columns': [], 'primary_keys': ['student id']}, {'table_name': 'classes', 'table_schema': [{'col_name': 'class id'}, {'col_name': 'student id'}, {'col_name': 'teacher id'}, {'col_name': 'class details'}], 'foreign_key_columns': ['teacher id', 'student id'], 'primary_keys': ['class id']}]
For each student, find the student id, student biographical data, and the number of courses he or she takes.
SELECT T1.student_id , T1.bio_data , count(*) FROM Students AS T1 JOIN Classes AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id
cre_Students_Information_Systems
[{'table_name': 'students', 'table_schema': [{'col_name': 'student id'}, {'col_name': 'bio data'}, {'col_name': 'student details'}], 'foreign_key_columns': [], 'primary_keys': ['student id']}, {'table_name': 'classes', 'table_schema': [{'col_name': 'class id'}, {'col_name': 'student id'}, {'col_name': 'teacher id'}, {'col_name': 'class details'}], 'foreign_key_columns': ['teacher id', 'student id'], 'primary_keys': ['class id']}]
How many students have gone through a detention?
SELECT count(DISTINCT student_id) FROM Detention
cre_Students_Information_Systems
[{'table_name': 'detention', 'table_schema': [{'col_name': 'detention id'}, {'col_name': 'detention type code'}, {'col_name': 'student id'}, {'col_name': 'datetime detention start'}, {'col_name': 'datetime detention end'}, {'col_name': 'detention summary'}, {'col_name': 'other details'}], 'foreign_key_columns': ['detention type code', 'student id'], 'primary_keys': ['detention id']}]
Count the number of students who have a detention record.
SELECT count(DISTINCT student_id) FROM Detention
cre_Students_Information_Systems
[{'table_name': 'detention', 'table_schema': [{'col_name': 'detention id'}, {'col_name': 'detention type code'}, {'col_name': 'student id'}, {'col_name': 'datetime detention start'}, {'col_name': 'datetime detention end'}, {'col_name': 'detention summary'}, {'col_name': 'other details'}], 'foreign_key_columns': ['detention type code', 'student id'], 'primary_keys': ['detention id']}]
What is the code and description of the most common student address type?
SELECT T1.address_type_code , T2.address_type_description FROM Students_Addresses AS T1 JOIN Ref_Address_Types AS T2 WHERE T1.address_type_code = T2.address_type_code GROUP BY T1.address_type_code ORDER BY count(*) DESC LIMIT 1
cre_Students_Information_Systems
[{'table_name': 'students addresses', 'table_schema': [{'col_name': 'student address id'}, {'col_name': 'address id'}, {'col_name': 'address type code'}, {'col_name': 'student id'}, {'col_name': 'date from'}, {'col_name': 'date to'}], 'foreign_key_columns': ['address type code', 'address id', 'student id'], 'primary_keys': ['student address id']}]
What is the most common student address type? Give me the code and description of the address type.
SELECT T1.address_type_code , T2.address_type_description FROM Students_Addresses AS T1 JOIN Ref_Address_Types AS T2 WHERE T1.address_type_code = T2.address_type_code GROUP BY T1.address_type_code ORDER BY count(*) DESC LIMIT 1
cre_Students_Information_Systems
[{'table_name': 'students addresses', 'table_schema': [{'col_name': 'student address id'}, {'col_name': 'address id'}, {'col_name': 'address type code'}, {'col_name': 'student id'}, {'col_name': 'date from'}, {'col_name': 'date to'}], 'foreign_key_columns': ['address type code', 'address id', 'student id'], 'primary_keys': ['student address id']}]
For those students who have gone through an event, who do not have a student loan? List the students' biographical data
SELECT T1.bio_data FROM Students AS T1 JOIN Student_Events AS T2 WHERE T1.student_id = T2.student_id EXCEPT SELECT T1.bio_data FROM Students AS T1 JOIN Student_Loans AS T2 WHERE T1.student_id = T2.student_id
cre_Students_Information_Systems
[{'table_name': 'students', 'table_schema': [{'col_name': 'student id'}, {'col_name': 'bio data'}, {'col_name': 'student details'}], 'foreign_key_columns': [], 'primary_keys': ['student id']}, {'table_name': 'student events', 'table_schema': [{'col_name': 'event id'}, {'col_name': 'event type code'}, {'col_name': 'student id'}, {'col_name': 'event date'}, {'col_name': 'other details'}], 'foreign_key_columns': ['event type code', 'student id'], 'primary_keys': ['event id']}, {'table_name': 'student loans', 'table_schema': [{'col_name': 'student loan id'}, {'col_name': 'student id'}, {'col_name': 'date of loan'}, {'col_name': 'amount of loan'}, {'col_name': 'other details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['student loan id']}]
Among the students who have an event record, who do not have a student loan? Return the students' biographical data.
SELECT T1.bio_data FROM Students AS T1 JOIN Student_Events AS T2 WHERE T1.student_id = T2.student_id EXCEPT SELECT T1.bio_data FROM Students AS T1 JOIN Student_Loans AS T2 WHERE T1.student_id = T2.student_id
cre_Students_Information_Systems
[{'table_name': 'students', 'table_schema': [{'col_name': 'student id'}, {'col_name': 'bio data'}, {'col_name': 'student details'}], 'foreign_key_columns': [], 'primary_keys': ['student id']}, {'table_name': 'student events', 'table_schema': [{'col_name': 'event id'}, {'col_name': 'event type code'}, {'col_name': 'student id'}, {'col_name': 'event date'}, {'col_name': 'other details'}], 'foreign_key_columns': ['event type code', 'student id'], 'primary_keys': ['event id']}, {'table_name': 'student loans', 'table_schema': [{'col_name': 'student loan id'}, {'col_name': 'student id'}, {'col_name': 'date of loan'}, {'col_name': 'amount of loan'}, {'col_name': 'other details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['student loan id']}]
List the start time and the end time of the students' addresses for the students who have 2 transcripts.
SELECT date_from , date_to FROM Students_Addresses WHERE student_id IN ( SELECT student_id FROM Transcripts GROUP BY student_id HAVING count(*) = 2 )
cre_Students_Information_Systems
[{'table_name': 'transcripts', 'table_schema': [{'col_name': 'transcript id'}, {'col_name': 'student id'}, {'col_name': 'date of transcript'}, {'col_name': 'transcript details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['transcript id']}, {'table_name': 'students addresses', 'table_schema': [{'col_name': 'student address id'}, {'col_name': 'address id'}, {'col_name': 'address type code'}, {'col_name': 'student id'}, {'col_name': 'date from'}, {'col_name': 'date to'}], 'foreign_key_columns': ['address type code', 'address id', 'student id'], 'primary_keys': ['student address id']}]
What are the start time and end time of addresses for the students who receive 2 transcripts?
SELECT date_from , date_to FROM Students_Addresses WHERE student_id IN ( SELECT student_id FROM Transcripts GROUP BY student_id HAVING count(*) = 2 )
cre_Students_Information_Systems
[{'table_name': 'transcripts', 'table_schema': [{'col_name': 'transcript id'}, {'col_name': 'student id'}, {'col_name': 'date of transcript'}, {'col_name': 'transcript details'}], 'foreign_key_columns': ['student id'], 'primary_keys': ['transcript id']}, {'table_name': 'students addresses', 'table_schema': [{'col_name': 'student address id'}, {'col_name': 'address id'}, {'col_name': 'address type code'}, {'col_name': 'student id'}, {'col_name': 'date from'}, {'col_name': 'date to'}], 'foreign_key_columns': ['address type code', 'address id', 'student id'], 'primary_keys': ['student address id']}]
When did all the detentions start?
SELECT datetime_detention_start FROM Detention
cre_Students_Information_Systems
[{'table_name': 'detention', 'table_schema': [{'col_name': 'detention id'}, {'col_name': 'detention type code'}, {'col_name': 'student id'}, {'col_name': 'datetime detention start'}, {'col_name': 'datetime detention end'}, {'col_name': 'detention summary'}, {'col_name': 'other details'}], 'foreign_key_columns': ['detention type code', 'student id'], 'primary_keys': ['detention id']}]
Give me the detention start date for all the detention records.
SELECT datetime_detention_start FROM Detention
cre_Students_Information_Systems
[{'table_name': 'detention', 'table_schema': [{'col_name': 'detention id'}, {'col_name': 'detention type code'}, {'col_name': 'student id'}, {'col_name': 'datetime detention start'}, {'col_name': 'datetime detention end'}, {'col_name': 'detention summary'}, {'col_name': 'other details'}], 'foreign_key_columns': ['detention type code', 'student id'], 'primary_keys': ['detention id']}]
List all the author names.
SELECT name FROM Author
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}]
What are the names of all the authors?
SELECT name FROM Author
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}]
Show all Client names and their addresses.
SELECT name , address FROM Client
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
What are the names and addressed of all clients?
SELECT name , address FROM Client
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
List all Book titles, ISBNs, and sale prices.
SELECT title , isbn , SalePrice FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What are the titles, ISBNs, and sale prices for all books?
SELECT title , isbn , SalePrice FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
How many books do we have?
SELECT count(*) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
Count the number of books.
SELECT count(*) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
How many authors are there?
SELECT count(*) FROM Author
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}]
Count the number of authors.
SELECT count(*) FROM Author
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}]
How many clients are there?
SELECT count(*) FROM Client
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
Return the number of clients.
SELECT count(*) FROM Client
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
List names and addresses of all clients in alphabetical order by their names.
SELECT name , address FROM Client ORDER BY name
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
What are the names and addressed of all clients, ordered alphabetically by name?
SELECT name , address FROM Client ORDER BY name
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}]
Show all book titles and corresponding author names.
SELECT T3.title , T1.name FROM Author AS T1 JOIN Author_Book AS T2 ON T2.Author = T1.idAuthor JOIN Book AS T3 ON T2.isbn = T3.isbn
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What are the names of all books and their corresponding authors?
SELECT T3.title , T1.name FROM Author AS T1 JOIN Author_Book AS T2 ON T2.Author = T1.idAuthor JOIN Book AS T3 ON T2.isbn = T3.isbn
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Show all order ids and their client names.
SELECT T1.idOrder , T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What are the ids of all orders and the corresponding client names?
SELECT T1.idOrder , T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
Show all author names and the numbers of books each has written.
SELECT T1.name , count(*) FROM Author AS T1 JOIN Author_Book AS T2 ON T1.idAuthor = T2.Author GROUP BY T1.idAuthor
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What are the names of all the authors, and how many books has each written?
SELECT T1.name , count(*) FROM Author AS T1 JOIN Author_Book AS T2 ON T1.idAuthor = T2.Author GROUP BY T1.idAuthor
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Show all book isbns and the numbers of orders for each.
SELECT isbn , count(*) FROM Books_Order GROUP BY isbn
book_1
[{'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are all isbns for each book, and how many times has each been ordered?
SELECT isbn , count(*) FROM Books_Order GROUP BY isbn
book_1
[{'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show all book isbns and the total amount ordered for each.
SELECT isbn , sum(amount) FROM Books_Order GROUP BY isbn
book_1
[{'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the isbns for all books, and what is the total amount ordered for each?
SELECT isbn , sum(amount) FROM Books_Order GROUP BY isbn
book_1
[{'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show the book title corresponding to the book with the most number of orders.
SELECT T2.title FROM Books_Order AS T1 JOIN Book AS T2 ON T1.isbn = T2.isbn GROUP BY T1.isbn ORDER BY count(*) DESC LIMIT 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What is the title of the book that has been ordered the greatest number of times?
SELECT T2.title FROM Books_Order AS T1 JOIN Book AS T2 ON T1.isbn = T2.isbn GROUP BY T1.isbn ORDER BY count(*) DESC LIMIT 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show the book title and purchase price of the book that has had the greatest amount in orders.
SELECT T2.title , T2.PurchasePrice FROM Books_Order AS T1 JOIN BOOk AS T2 ON T1.isbn = T2.isbn GROUP BY T1.isbn ORDER BY sum(amount) DESC LIMIT 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What is the title and purchase price of the book that has the highest total order amount?
SELECT T2.title , T2.PurchasePrice FROM Books_Order AS T1 JOIN BOOk AS T2 ON T1.isbn = T2.isbn GROUP BY T1.isbn ORDER BY sum(amount) DESC LIMIT 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show the titles of books that have been ordered.
SELECT DISTINCT T1.title FROM book AS T1 JOIN books_order AS T2 ON T1.isbn = T2.isbn
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the different titles of books that have been ordered in the past?
SELECT DISTINCT T1.title FROM book AS T1 JOIN books_order AS T2 ON T1.isbn = T2.isbn
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show the names of clients who have ordered at least once.
SELECT DISTINCT T1.name FROM Client AS T1 JOIN Orders AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What are the names of the different clients who have made an order?
SELECT DISTINCT T1.name FROM Client AS T1 JOIN Orders AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
Show all client names and the number of orders each has made.
SELECT T2.name , count(*) FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient GROUP BY T1.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What are the names of all the clients, and how many times has each of them ordered?
SELECT T2.name , count(*) FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient GROUP BY T1.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What is the name of the client with the most number of orders?
SELECT T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient GROUP BY T1.idClient ORDER BY count(*) DESC LIMIT 1
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
Give the name of the client who has made the most orders.
SELECT T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient GROUP BY T1.idClient ORDER BY count(*) DESC LIMIT 1
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
Show the client names and their total amounts of books ordered.
SELECT T2.name , sum(T3.amount) FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient JOIN Books_Order AS T3 ON T3.idOrder = T1.idOrder GROUP BY T1.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the names of all the clients, and the total amount of books ordered by each?
SELECT T2.name , sum(T3.amount) FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient JOIN Books_Order AS T3 ON T3.idOrder = T1.idOrder GROUP BY T1.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show the client name who has the most total amount of books ordered.
SELECT T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient JOIN Books_Order AS T3 ON T3.idOrder = T1.idOrder GROUP BY T1.idClient ORDER BY sum(T3.amount) DESC LIMIT 1
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What is the name of the client who has ordered the greatest total amount of books?
SELECT T2.name FROM Orders AS T1 JOIN Client AS T2 ON T1.idClient = T2.idClient JOIN Books_Order AS T3 ON T3.idOrder = T1.idOrder GROUP BY T1.idClient ORDER BY sum(T3.amount) DESC LIMIT 1
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show all book titles for books that have no orders.
SELECT title FROM book EXCEPT SELECT T1.title FROM book AS T1 JOIN books_order AS T2 ON T1.isbn = T2.isbn
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the titles of books that have never been ordered?
SELECT title FROM book EXCEPT SELECT T1.title FROM book AS T1 JOIN books_order AS T2 ON T1.isbn = T2.isbn
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show all client names for clients who have not made orders.
SELECT name FROM Client EXCEPT SELECT T1.name FROM Client AS T1 JOIN Orders AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What are the names of clients who have never made an order?
SELECT name FROM Client EXCEPT SELECT T1.name FROM Client AS T1 JOIN Orders AS T2 ON T1.idClient = T2.idClient
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}]
What is the maximum and the minimum sale price?
SELECT max(saleprice) , min(saleprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
Give the maximum and minimum sale price of books.
SELECT max(saleprice) , min(saleprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What is the average purchase price and the average sale price?
SELECT avg(purchaseprice) , avg(saleprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
Give the average purchase price and average sale price for books.
SELECT avg(purchaseprice) , avg(saleprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What is the maximum difference between the sale price and purchase price?
SELECT max(saleprice - purchaseprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
Return the largest difference in sale price and purchase price.
SELECT max(saleprice - purchaseprice) FROM Book
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
List all book titles which have sale prices higher than the average.
SELECT title FROM book WHERE saleprice > (SELECT avg(saleprice) FROM book)
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What are the titles of books with sale prices above the average sale price across all books?
SELECT title FROM book WHERE saleprice > (SELECT avg(saleprice) FROM book)
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
List all book titles which have the lowest sale price .
select title from book order by saleprice asc limit 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What are the titles of books that have a sale price equal to the lowest sale price across all books ?
select title from book order by saleprice asc limit 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
List all book titles which have highest purchase prices .
select title from book order by purchaseprice desc limit 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What are the titles of books with the highest purchase price across all books ?
select title from book order by purchaseprice desc limit 1
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}]
What is the average sale price of books written by George Orwell?
SELECT avg(saleprice) FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "George Orwell"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Give the average sale price of books authored by George Orwell.
SELECT avg(saleprice) FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "George Orwell"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What are sale prices of books written by Plato?
SELECT saleprice FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "Plato"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Return the sale prices of books authored by Plato.
SELECT saleprice FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "Plato"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What is the title of the book written by George Orwell that has the lowest sale price?
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "George Orwell" ORDER BY T1.saleprice LIMIT 1
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Give the title of book by George Orwell that has the lowest saleprice.
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "George Orwell" ORDER BY T1.saleprice LIMIT 1
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What is the title of the book written by Plato has price lower than the average sale price of all books?
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "Plato" AND T1.saleprice < (SELECT avg(saleprice) FROM Book)
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Give the titles of books authored by Plato that have a sale price lower than the average sale price across all books.
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name = "Plato" AND T1.saleprice < (SELECT avg(saleprice) FROM Book)
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Who is the author of the book "Pride and Prejudice"?
SELECT T3.name FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T1.title = "Pride and Prejudice"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
Give the name of the author who wrote the book titled Pride and Prejudice.
SELECT T3.name FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T1.title = "Pride and Prejudice"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
List titles of all books published by an author whose name contains the string 'Plato'?
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name LIKE "%Plato%"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
What are the titles of all books written by an author with a name that contains Plato?
SELECT T1.title FROM Book AS T1 JOIN Author_book AS T2 ON T1.isbn = T2.isbn JOIN Author AS T3 ON T2.Author = T3.idAuthor WHERE T3.name LIKE "%Plato%"
book_1
[{'table_name': 'author', 'table_schema': [{'col_name': 'author id'}, {'col_name': 'name'}], 'foreign_key_columns': [], 'primary_keys': ['author id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'author book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'author'}], 'foreign_key_columns': ['isbn'], 'primary_keys': ['isbn']}]
How many orders do we have for "Pride and Prejudice"?
SELECT count(*) FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "Pride and Prejudice"
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Return the number of orders received for Pride and Prejudice.
SELECT count(*) FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "Pride and Prejudice"
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show ids for orders including both "Pride and Prejudice" and "The Little Prince".
SELECT idOrder FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "Pride and Prejudice" INTERSECT SELECT idOrder FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "The Little Prince"
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the order ids for orders that include both Pride and Prejudice and The Little Prince?
SELECT idOrder FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "Pride and Prejudice" INTERSECT SELECT idOrder FROM Book AS T1 JOIN Books_Order AS T2 ON T1.isbn = T2.isbn WHERE T1.title = "The Little Prince"
book_1
[{'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show all book isbns which were ordered by both client Peter Doe and client James Smith.
SELECT T2.isbn FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient WHERE T3.name = "Peter Doe" INTERSECT SELECT T2.isbn FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient WHERE T3.name = "James Smith"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the isbns of books ordered by both clients named Peter Doe and James Smith?
SELECT T2.isbn FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient WHERE T3.name = "Peter Doe" INTERSECT SELECT T2.isbn FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient WHERE T3.name = "James Smith"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Find the title of books which are ordered by client Peter Doe but not client James Smith.
SELECT T4.title FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN book AS T4 ON T2.ISBN = T4.isbn WHERE T3.name = "Peter Doe" EXCEPT SELECT T4.title FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN book AS T4 ON T2.ISBN = T4.isbn WHERE T3.name = "James Smith"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the titles of books that the client Peter Doe ordered, but the client James Smith did not?
SELECT T4.title FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN book AS T4 ON T2.ISBN = T4.isbn WHERE T3.name = "Peter Doe" EXCEPT SELECT T4.title FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN book AS T4 ON T2.ISBN = T4.isbn WHERE T3.name = "James Smith"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
Show all client names who have orders for "Pride and Prejudice".
SELECT T3.name FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN Book AS T4 ON T4.isbn = T2.isbn WHERE T4.title = "Pride and Prejudice"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
What are the names of clients who have ordered Pride and Prejudice?
SELECT T3.name FROM Orders AS T1 JOIN Books_Order AS T2 ON T1.idOrder = T2.idOrder JOIN Client AS T3 ON T1.idClient = T3.idClient JOIN Book AS T4 ON T4.isbn = T2.isbn WHERE T4.title = "Pride and Prejudice"
book_1
[{'table_name': 'client', 'table_schema': [{'col_name': 'client id'}, {'col_name': 'name'}, {'col_name': 'address'}, {'col_name': 'numcc'}], 'foreign_key_columns': [], 'primary_keys': ['client id']}, {'table_name': 'orders', 'table_schema': [{'col_name': 'order id'}, {'col_name': 'client id'}, {'col_name': 'order date'}, {'col_name': 'date expired'}], 'foreign_key_columns': [], 'primary_keys': ['order id']}, {'table_name': 'book', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'title'}, {'col_name': 'author'}, {'col_name': 'purchase price'}, {'col_name': 'sale price'}], 'foreign_key_columns': [], 'primary_keys': ['isbn']}, {'table_name': 'books order', 'table_schema': [{'col_name': 'isbn'}, {'col_name': 'order id'}, {'col_name': 'amount'}], 'foreign_key_columns': ['order id', 'isbn'], 'primary_keys': ['isbn']}]
How many books are there?
SELECT count(*) FROM book
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
List the titles of books in ascending alphabetical order.
SELECT Title FROM book ORDER BY Title ASC
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
List the titles of books in descending order of pages.
SELECT Title FROM book ORDER BY Pages DESC
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
What are the types and release dates of books?
SELECT TYPE , Release FROM book
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
What are the maximum and minimum number of chapters for each book?
SELECT max(Chapters) , min(Chapters) FROM book
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
What are the titles of books that are not "Poet"?
SELECT Title FROM book WHERE TYPE != "Poet"
book_review
[{'table_name': 'book', 'table_schema': [{'col_name': 'book id'}, {'col_name': 'title'}, {'col_name': 'type'}, {'col_name': 'pages'}, {'col_name': 'chapters'}, {'col_name': 'audio'}, {'col_name': 'release'}], 'foreign_key_columns': [], 'primary_keys': ['book id']}]
What is the average rating in reviews?
SELECT avg(Rating) FROM review
book_review
[{'table_name': 'review', 'table_schema': [{'col_name': 'review id'}, {'col_name': 'book id'}, {'col_name': 'rating'}, {'col_name': 'readers in million'}, {'col_name': 'rank'}], 'foreign_key_columns': ['book id'], 'primary_keys': ['review id']}]