Database schema:
CREATE TABLE customers (
  Id NUMBER PRIMARY KEY,
  LastName TEXT,
  FirstName TEXT
);
CREATE TABLE goods (
  Id TEXT PRIMARY KEY,
  Flavor TEXT,
  Food TEXT,
  Price NUMBER
);
CREATE TABLE items (
  Receipt NUMBER PRIMARY KEY,
  Ordinal NUMBER,
  Item TEXT,
  FOREIGN KEY (Item) REFERENCES goods(Id)
);
CREATE TABLE receipts (
  ReceiptNumber NUMBER PRIMARY KEY,
  Date TEXT,
  CustomerId NUMBER,
  FOREIGN KEY (CustomerId) REFERENCES customers(Id)
);

Question: What is the average price for each food type?
SQL: SELECT avg(price) ,  food FROM goods GROUP BY food

Question: What is the cheapest cookie and its flavor?
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cookie" ORDER BY price LIMIT 1

Question: Give the ids of Cookies or Cakes that cost between 3 and 7 dollars.
SQL: SELECT id FROM goods WHERE food  =  "Cookie" OR food  =  "Cake" AND price BETWEEN 3 AND 7

Question: Find the ids of customers whose average spending for each good is above 5.
SQL: SELECT T3.CustomerId FROM goods AS T1 JOIN items AS T2 ON T1.id  =  T2.item JOIN receipts AS T3 ON T2.receipt  =  T3.ReceiptNumber GROUP BY T3.CustomerId HAVING avg(T1.price)  >  5

Question: What are the flavors available for Cake but not for Tart?
SQL: SELECT DISTINCT flavor FROM goods WHERE food  =  "Cake" EXCEPT SELECT DISTINCT flavor FROM goods WHERE food  =  "Tart"

Question: Give me the distinct id and price for all goods whose price is below the average of all goods?
SQL: SELECT DISTINCT id ,  price FROM goods WHERE price  <  (SELECT avg(price) FROM goods)

Question: What are all the distinct items bought by customer 15?
SQL: SELECT DISTINCT T1.item FROM items AS T1 JOIN receipts AS T2 ON T1.receipt  =  T2.ReceiptNumber WHERE T2.CustomerId  =  15

Question: What are the average prices of goods with blackberry or blueberry flavor?
SQL: SELECT avg(price) FROM goods WHERE flavor  =  "Blackberry" OR flavor  =  "Blueberry"

Question: Give the flavors of Cakes that are not available for Tart.
SQL: SELECT DISTINCT flavor FROM goods WHERE food  =  "Cake" EXCEPT SELECT DISTINCT flavor FROM goods WHERE food  =  "Tart"

Question: What is the receipt number and date corresponding to the receipt for which the most expensive item was purchased?
SQL: SELECT T1.ReceiptNumber ,  T1.Date FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id ORDER BY T3.price DESC LIMIT 1

Question: What are the three dates for which the most receipts were given?
SQL: SELECT date FROM receipts GROUP BY date ORDER BY count(*) DESC LIMIT 3

Question: Return the lowest and highest prices of goods grouped and ordered by food type.
SQL: SELECT min(price) ,  max(price) ,  food FROM goods GROUP BY food ORDER BY food

Question: What are the ids of goods that cost less than 3 dollars?
SQL: SELECT id FROM goods WHERE price  <  3

Question: What is the three most popular goods in this bakery?
SQL: SELECT item FROM items GROUP BY item ORDER BY COUNT (*) DESC LIMIT 3

Question: What is the receipt number and date of the receipt in which the most expensive item was bought?
SQL: SELECT T1.ReceiptNumber ,  T1.Date FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id ORDER BY T3.price DESC LIMIT 1

Question: Give me a list of all the distinct items bought by the customer number 15.
SQL: SELECT DISTINCT T1.item FROM items AS T1 JOIN receipts AS T2 ON T1.receipt  =  T2.ReceiptNumber WHERE T2.CustomerId  =  15

Question: Give the ids of cookes that are cheaper than any croissant.
SQL: SELECT id FROM goods WHERE food  =  "Cookie" AND price  <  (SELECT min(price) FROM goods WHERE food  =  'Croissant')

Question: On which day did the bakery sell more than 100 dollars in total.
SQL: SELECT T3.date FROM goods AS T1 JOIN items AS T2 ON T1.id  =  T2.item JOIN receipts AS T3 ON T2.receipt  =  T3.ReceiptNumber GROUP BY T3.date HAVING sum(T1.price)  >  100

Question: What are the minimum and maximum prices of food goods, ordered by food?
SQL: SELECT min(price) ,  max(price) ,  food FROM goods GROUP BY food ORDER BY food

Question: Give the distinct ids for goods that cost less than any Tart.
SQL: SELECT DISTINCT id FROM goods WHERE price  <  (SELECT max(price) FROM goods WHERE food  =  "Tart")

Question: Return a list of the id and flavor for Cakes ordered by flavor.
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cake" ORDER BY flavor

Question: Find flavor of cakes that cost more than 10 dollars.
SQL: SELECT flavor FROM goods WHERE food  =  "Cake" AND price  >  10

Question: On what dates did the bakery sell more than 100 dollars worth of goods in total?
SQL: SELECT T3.date FROM goods AS T1 JOIN items AS T2 ON T1.id  =  T2.item JOIN receipts AS T3 ON T2.receipt  =  T3.ReceiptNumber GROUP BY T3.date HAVING sum(T1.price)  >  100

Question: What is average price of goods whose flavor is blackberry or blueberry?
SQL: SELECT avg(price) FROM goods WHERE flavor  =  "Blackberry" OR flavor  =  "Blueberry"

Question: Give me the ids of Cakes whose price is at least as much as the average price of Tart?
SQL: SELECT id FROM goods WHERE food  =  "Cake" AND price  >=  (SELECT avg(price) FROM goods WHERE food  =  "Tart")

Question: What are the ids, flavors, and food types of goods, ordered by price?
SQL: SELECT id ,  flavor ,  food FROM goods ORDER BY price

Question: What are the ids of cakes that are at least as expensive as the average Tart?
SQL: SELECT id FROM goods WHERE food  =  "Cake" AND price  >=  (SELECT avg(price) FROM goods WHERE food  =  "Tart")

Question: What are the receipt numbers for a customer with the last name Logan who purchased a croissant?
SQL: SELECT T1.ReceiptNumber FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id JOIN customers AS T4 ON T4.Id  =  T1.CustomerId WHERE T3.food  =  "Croissant" AND T4.LastName  =  'LOGAN'

Question: Give the ids of goods that are more than twice as expensive as the average good.
SQL: SELECT id FROM goods WHERE price  >  (SELECT avg(price) FROM goods)

Question: Give the id and flavor of the most expensive cake.
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cake" ORDER BY price DESC LIMIT 1

Question: Give the ids for goods that have Apricot flavor and have a price lower than 5 dollars.
SQL: SELECT id FROM goods WHERE flavor  =  "Apricot" AND price  <  5

Question: What are the distinct ids of all goods that are cheaper than some goods of type Tart?
SQL: SELECT DISTINCT id FROM goods WHERE price  <  (SELECT max(price) FROM goods WHERE food  =  "Tart")

Question: What are all the ids of goods with an id which contains "APP"?
SQL: SELECT id FROM goods WHERE id LIKE "%APP%"

Question: What is the receipt number with the latest date, and what is that date?
SQL: SELECT ReceiptNumber ,  date FROM receipts WHERE date  =  (SELECT date FROM receipts ORDER BY date DESC LIMIT 1)

Question: What is the id and flavor of the cheapest cookie?
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cookie" ORDER BY price LIMIT 1

Question: Which customer shopped most often? How many times?
SQL: SELECT CustomerId ,  count(*) FROM receipts GROUP BY CustomerId ORDER BY count(*) DESC LIMIT 1

Question: Find all receipts which has the latest date. Also tell me that date.
SQL: SELECT ReceiptNumber ,  date FROM receipts WHERE date  =  (SELECT date FROM receipts ORDER BY date DESC LIMIT 1)

Question: Find all the receipt numbers in which customer with last name LOGAN purchased Croissant.
SQL: SELECT T1.ReceiptNumber FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id JOIN customers AS T4 ON T4.Id  =  T1.CustomerId WHERE T3.food  =  "Croissant" AND T4.LastName  =  'LOGAN'