Database schema:
CREATE TABLE Warehouses (
  Code NUMBER PRIMARY KEY,
  Location TEXT,
  Capacity NUMBER
);
CREATE TABLE Boxes (
  Code TEXT PRIMARY KEY,
  Contents TEXT,
  Value NUMBER,
  Warehouse NUMBER,
  FOREIGN KEY (Warehouse) REFERENCES Warehouses(Code)
);

Question: What are the codes of warehouses that have more boxes than their capacity?
SQL: SELECT T2.code FROM boxes AS T1 JOIN Warehouses AS T2 ON T1.warehouse  =  T2.code GROUP BY T2.code HAVING count(*)  >  T2.capacity

Question: What are the codes and corresponding contents of all the boxes, ordered by their values?
SQL: SELECT code ,  CONTENTS FROM boxes ORDER BY value

Question: What are the codes of boxes stored in warehouses in either Chicago or New York?
SQL: SELECT T1.code FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T2.location  =  'Chicago' OR T2.location  =  'New York'

Question: What types of contents cannot be found in warehouses in New York?
SQL: SELECT CONTENTS FROM boxes EXCEPT SELECT T1.contents FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T2.location  =  'New York'

Question: What are the average and total values across all boxes?
SQL: SELECT avg(value) ,  sum(value) FROM boxes

Question: Find the code and contents of the box with the lowest value.
SQL: SELECT code ,  CONTENTS FROM boxes ORDER BY value LIMIT 1

Question: Find the content that has the highest total values in all boxes.
SQL: SELECT CONTENTS FROM boxes ORDER BY value DESC LIMIT 1

Question: Find the number of all distinct contents in all the boxes.
SQL: SELECT count(DISTINCT CONTENTS) FROM boxes

Question: Select all details of all warehouses.
SQL: SELECT * FROM warehouses

Question: How many boxes are there with each warehouse ?
SQL: select warehouse ,  count(*) from boxes group by warehouse

Question: What are the different contents in boxes?
SQL: SELECT DISTINCT CONTENTS FROM boxes

Question: What is the total value of boxes contained in any location but Chicago?
SQL: SELECT sum(T1.value) FROM boxes AS T1 JOIN Warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T2.location != 'Chicago'

Question: Find the code of all boxes whose value is higher than the value of any boxes with Rocks as content.
SQL: SELECT code FROM boxes WHERE value  >  (SELECT min(value) FROM boxes WHERE CONTENTS  =  'Rocks')

Question: Find the value of the most expensive boxes saved in each warehouse location.
SQL: SELECT max(T1.value) ,  T2.location FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code GROUP BY T2.location

Question: What are the codes of boxes for which the value is greater than the value of any box that contains Rocks?
SQL: SELECT code FROM boxes WHERE value  >  (SELECT min(value) FROM boxes WHERE CONTENTS  =  'Rocks')

Question: For each content, what is the total value and number of boxes?
SQL: SELECT sum(value) ,  count(*) ,  CONTENTS FROM boxes GROUP BY CONTENTS

Question: What is the total value of boxes located in Chicago or New York?
SQL: SELECT sum(T1.value) FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T2.location  =  'Chicago' OR T2.location  =  'New York'

Question: What are the contents of boxes with value greater than 150?
SQL: SELECT CONTENTS FROM boxes WHERE Value  >  150

Question: What are the locations of warehouses that have boxes containing Rocks but not Scissors?
SQL: SELECT T2.location FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T1.contents  =  'Rocks' EXCEPT SELECT T2.location FROM boxes AS T1 JOIN warehouses AS T2 ON T1.warehouse  =  T2.code WHERE T1.contents  =  'Scissors'