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: Give me the list of ids of all goods whose id has "APP".
SQL: SELECT id FROM goods WHERE id LIKE "%APP%"

Question: Find all receipts in which either apple flavor pie was bought or customer id 12 shopped.
SQL: SELECT T1.receipt FROM items AS T1 JOIN goods AS T2 ON T1.item  =  T2.id WHERE T2.flavor  =  "Apple" AND T2.food  =  "Pie" UNION SELECT ReceiptNumber FROM receipts WHERE CustomerId  =  12

Question: What are ids of the goods that have Apricot flavor and are cheaper than 5 dollars?
SQL: SELECT id FROM goods WHERE flavor  =  "Apricot" AND price  <  5

Question: On which date did some customer buy a good that costs more than 15 dollars?
SQL: SELECT DISTINCT T1.date FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id WHERE T3.price  >  15

Question: What is the item that was bought the least number of times?
SQL: SELECT item FROM items GROUP BY item ORDER BY count(*) LIMIT 1

Question: Give the three most purchased items at this bakery.
SQL: SELECT item FROM items GROUP BY item ORDER BY COUNT (*) DESC LIMIT 3

Question: Return the cheapest price for goods with cheese flavor.
SQL: SELECT min(price) FROM goods WHERE flavor  =  "Cheese"

Question: What are the items with chocolate flavor that were purchased at most 10 times.
SQL: SELECT DISTINCT T1.item FROM items AS T1 JOIN goods AS T2 ON T1.item  =  T2.id WHERE T2.flavor  =  "Chocolate" GROUP BY item HAVING count(*)  <=  10

Question: What are the last names of the customers in alphabetical order?
SQL: SELECT DISTINCT LastName FROM customers ORDER BY LastName

Question: What are the full names of customers who bought apple flavored Tarts?
SQL: SELECT DISTINCT T4.FirstName ,  T4.LastName FROM goods AS T1 JOIN items AS T2 ON T1.id  =  T2.item JOIN receipts AS T3 ON T2.receipt  =  T3.ReceiptNumber JOIN customers AS T4 ON T3.CustomerId  =  T4.id WHERE T1.flavor  =  "Apple" AND T1.food  =  "Tart"

Question: List the distinct ids of all customers who bought a cake with lemon flavor?
SQL: SELECT DISTINCT T3.CustomerId FROM goods AS T1 JOIN items AS T2 ON T1.Id  =  T2.Item JOIN receipts AS T3 ON T2.Receipt  =  T3.ReceiptNumber WHERE T1.Flavor  =  "Lemon" AND T1.Food  =  "Cake"

Question: Find the ids of goods that have apple flavor.
SQL: SELECT id FROM goods WHERE flavor  =  "Apple"

Question: List the id, flavor and type of food of goods ordered by price.
SQL: SELECT id ,  flavor ,  food FROM goods ORDER BY price

Question: Return the ordered list of all good ids.
SQL: SELECT DISTINCT id FROM goods ORDER BY id

Question: Find the top three dates with the most receipts.
SQL: SELECT date FROM receipts GROUP BY date ORDER BY count(*) DESC LIMIT 3

Question: How many customers have bought each food?
SQL: SELECT T1.food ,  count(DISTINCT 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 T1.food

Question: For each type of food, what are the average, maximum and minimum price?
SQL: SELECT food ,  avg(price) ,  max(price) ,  min(price) FROM goods GROUP BY food

Question: Count the number of goods for each food type.
SQL: SELECT count(*) ,  food FROM goods GROUP BY food

Question: What are highest, lowest, and average prices of goods, grouped and ordered by flavor?
SQL: SELECT max(price) ,  min(price) ,  avg(price) ,  flavor FROM goods GROUP BY flavor ORDER BY flavor

Question: Which date corresponds to when a customer purchased a good costing over 15 dollars?
SQL: SELECT DISTINCT T1.date FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id WHERE T3.price  >  15

Question: What are the distinct ids of customers who bought lemon flavored cake?
SQL: SELECT DISTINCT T3.CustomerId FROM goods AS T1 JOIN items AS T2 ON T1.Id  =  T2.Item JOIN receipts AS T3 ON T2.Receipt  =  T3.ReceiptNumber WHERE T1.Flavor  =  "Lemon" AND T1.Food  =  "Cake"

Question: What distinct receipt numbers correspond to someone who bought a good that costs more than 13 dollars?
SQL: SELECT DISTINCT T1.ReceiptNumber FROM receipts AS T1 JOIN items AS T2 ON T1.ReceiptNumber  =  T2.receipt JOIN goods AS T3 ON T2.item  =  T3.id WHERE T3.price  >  13

Question: Which item was bought the fewest times?
SQL: SELECT item FROM items GROUP BY item ORDER BY count(*) LIMIT 1

Question: Give the ids of goods that cost less than 3 dollars.
SQL: SELECT id FROM goods WHERE price  <  3

Question: What are the customer ids of customers who have at least 15 receipts?
SQL: SELECT CustomerId FROM receipts GROUP BY CustomerId HAVING count(*)  >=  15

Question: Find the ids of customers who have spent more than 150 dollars in total.
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 sum(T1.price)  >  150

Question: What are the ids of Cookies whose price is lower than any Croissant?
SQL: SELECT id FROM goods WHERE food  =  "Cookie" AND price  <  (SELECT min(price) FROM goods WHERE food  =  'Croissant')

Question: For each date, return how many distinct customers visited on that day.
SQL: SELECT date ,  COUNT (DISTINCT CustomerId) FROM receipts GROUP BY date

Question: What are the flavors of cakes that cost more than 10 dollars?
SQL: SELECT flavor FROM goods WHERE food  =  "Cake" AND price  >  10

Question: What are the distinct ids and prices for goods that cost less than the average good?
SQL: SELECT DISTINCT id ,  price FROM goods WHERE price  <  (SELECT avg(price) FROM goods)

Question: Which good has "70" in its id? And what is its price?
SQL: SELECT id ,  price FROM goods WHERE id LIKE "%70%"

Question: What is the most expensive cake and its flavor?
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cake" ORDER BY price DESC LIMIT 1

Question: What are the ids of customers who spend more than 5 on average for each good?
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 is the last name of the customers who shopped at the bakery more than 10 times?
SQL: SELECT T2.LastName FROM receipts AS T1 JOIN customers AS T2 ON T1.CustomerId  =  T2.id GROUP BY T2.id HAVING count(*)  >  10

Question: What are the id and price for the good with "70" in its id?
SQL: SELECT id ,  price FROM goods WHERE id LIKE "%70%"

Question: What are all the receipt numbers that have a good with a price above 10 or have the earliest date?
SQL: SELECT T1.Receipt FROM items AS T1 JOIN goods AS T2 ON T1.item  =  T2.id WHERE T2.price  >  10 UNION SELECT ReceiptNumber FROM receipts WHERE date  =  (SELECT date FROM receipts ORDER BY date LIMIT 1)

Question: Give the last names of customers who have been to the bakery more than 10 times?
SQL: SELECT T2.LastName FROM receipts AS T1 JOIN customers AS T2 ON T1.CustomerId  =  T2.id GROUP BY T2.id HAVING count(*)  >  10

Question: Find the id of customers who shopped at the bakery at least 15 times.
SQL: SELECT CustomerId FROM receipts GROUP BY CustomerId HAVING count(*)  >=  15

Question: What are the ids and flavors of cakes, ordered by flavor?
SQL: SELECT id ,  flavor FROM goods WHERE food  =  "Cake" ORDER BY flavor

Question: How many goods are available for each food type?
SQL: SELECT count(*) ,  food FROM goods GROUP BY food