minktn/spider-data huggingface dataset:
Question: List of books, the publication year of each of them and their authors, ordered by publication year

SQL:
SELECT TITLE, AÑO "YEAR", NAME "Author name"
FROM BOOK NATURAL JOIN AUTHOR_BOOK, AUTHOR
WHERE AUTHOR_BOOK.AUTHOR=AUTHOR.IDAUTHOR
ORDER BY AÑO;
Question: List of books that were published before 01-01-2000.

SQL:
SELECT TITLE, AÑO
FROM BOOK
WHERE AÑO<'2000';
Question: List of clients that have bought at least one book. 

SQL:
SELECT DISTINCT IDCLIENT, NAME
FROM CLIENT NATURAL JOIN ORDERS;
select distinct client.name, Client.IdClient
from Client, Orders where
Client.IdClient=Orders.IdClient;
Question: List of clients that bought the book whose ISBN= 4554672899910.

SQL:
SELECT IDCLIENT, NAME
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER
WHERE ISBN='4554672899910';
Question: List of clients whose name contains  ‘Jo’ and the books that they have bought. 

SQL:
SELECT IDCLIENT, NAME, TITLE
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
WHERE NAME LIKE '%Jo%';
Question: List of clients that have bought at least a book whose price is greater than 10.

SQL:
SELECT DISTINCT IDCLIENT, NAME
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
WHERE BOOK.SALEPRICE>10;
Question: List of clients that have placed more than one order in the same date. 

SQL:
SELECT IDCLIENT, NAME
FROM CLIENT
WHERE IDCLIENT=(
  SELECT IDCLIENT
  FROM ORDERS
  GROUP BY(IDCLIENT,DATEORDER)
  HAVING COUNT(DATEORDER)>1
);
Question: List of clients and dates in which they have placed orders that have not been sent yet. 

SQL:
SELECT IDCLIENT, NAME, DATEORDER
FROM CLIENT NATURAL JOIN ORDERS
WHERE DATEEXPED IS NULL;
Question: List of clients that have not bought books whose price is greater than 10.

SQL:
SELECT DISTINCT IDCLIENT, NAME
FROM CLIENT
WHERE IDCLIENT NOT IN (
  SELECT IDCLIENT
  FROM ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
  WHERE SALEPRICE < 10
);
Question: List of books whose sale price is greater than 30€ or that were published before 2000. 

SQL:
SELECT TITLE, AÑO, SALEPRICE
FROM BOOK
WHERE AÑO<'2000' OR SALEPRICE>30;
Question: List of books and amount of copies of each of them that have been sold. 

SQL:
SELECT TITLE, ISBN, SUM(AMOUNT)
FROM BOOKS_ORDER NATURAL JOIN BOOK
GROUP BY TITLE, ISBN
ORDER BY SUM(AMOUNT) DESC;
Question: List of clients and the total amount that they have spent in the bookstore. 

SQL:
SELECT IDCLIENT, NAME, SUM(AMOUNT*SALEPRICE) "Total"
FROM CLIENT NATURAL JOIN ORDERS NATURAL JOIN BOOKS_ORDER NATURAL JOIN BOOK
GROUP BY IDCLIENT, NAME;
Question: Profits obtained from sales of books. 

SQL:
SELECT SUM(AMOUNT*(SALEPRICE-PURCHASEPRICE)) "Total"
FROM BOOKS_ORDER NATURAL JOIN BOOK;
Question: Orders whose total amount is greater than 100.

SQL:
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "TOTAL"
FROM BOOKS_ORDER NATURAL JOIN BOOK
GROUP BY IDORDER
HAVING SUM(AMOUNT*SALEPRICE)>100
ORDER BY IDORDER;
Question: Orders and the total amount of each of them that contains more than a book (title). 

SQL:
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "TOTAL"
FROM BOOKS_ORDER NATURAL JOIN BOOK
GROUP BY IDORDER
HAVING COUNT(TITLE)>1;
Question: Orders and the total amount of each of them that contains more than 4 copies

SQL:
SELECT IDORDER, SUM(AMOUNT*SALEPRICE) "Total"
FROM BOOKS_ORDER NATURAL JOIN BOOK 
WHERE AMOUNT>4
GROUP BY IDORDER;
Question: List of the most expensive books. 

SQL:
SELECT ISBN, TITLE, SALEPRICE
FROM BOOK
WHERE SALEPRICE IN (SELECT MAX(SALEPRICE) FROM BOOK);
Question: List of books that have not been sold or that have been sold but the profit per copy is less than 5

SQL:
SELECT ISBN, TITLE
FROM BOOK
WHERE(SALEPRICE-PURCHASEPRICE)<5 OR ISBN NOT IN(
  SELECT DISTINCT ISBN FROM BOOKS_ORDER
);
Question: List of clients that have bought more than one copy of a book sometime
SQL:
SELECT NAME
FROM CLIENT NATURAL JOIN ORDERS
WHERE IDORDER IN (
  SELECT IDORDER
  FROM BOOKS_ORDER
  WHERE AMOUNT>1
);