text
stringlengths 0
359
|
---|
Select T1.receipt |
From items as T1 JOIN goods as T2 ON T1.item = T2.id |
Where T2.food = "Cake" |
INTERSECT |
Select T1.receipt |
From items as T1 JOIN goods as T2 ON T1.item = T2.id |
Where T2.food = "Cookie" |
Find all the receipt numbers in which customer id 5 purchased Croissant. |
Select ReceiptNumber |
From receipts |
Where CustomerId = 5 |
INTERSECT |
Select T1.receipt |
From items as T1 JOIN goods as T2 ON T1.item = T2.id |
Where T2.food = "Croissant" |
8. What is the receipt number and date of the receipt in which the most expensive item was bought? |
Select T1.ReceiptNumber, T1.Date |
From receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id |
Order by T3.price Desc |
LIMIT 1 |
What is the item that was bought the least number of times? |
Select item |
From items |
Group by item |
Order by count(*) |
LIMIT 1 |
9. How many goods are available for each food type? |
Select count(*), food |
From goods |
group by food |
What is the average price for each food type? |
Select avg(price), food |
From goods |
group by food |
10. What are the goods that have Apricot flavor and are cheaper than 5 dollars? |
Select id |
From goods |
where flavor = "Apricot" and price < 5 |
Find flavor of cakes that cost more than 10 dollars. |
Select flavor |
From goods |
where food = "Cake" and price > 10 |
11. Give me the distinct id and price for all goods whose price is below the average of all goods? |
Select distinct id, price |
From goods |
where price < (Select avg(price) From goods) |
What are the distinct ids of all goods that are cheaper than some goods of type Tart? |
Select distinct T1.id |
From goods as T1, goods as T2 |
where T1.price < T2.price and T2.food = "Tart" |
12. List distinct receipt numbers for which someone bought a good that costs more than 13 dollars. |
Select distinct T1.ReceiptNumber |
from receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id |
Where T3.price > 13 |
On which date did some customer buy a good that costs more than 15 dollars? |
Select distinct T1.date |
from receipts as T1 JOIN items as T2 JOIN goods as T3 ON T1.ReceiptNumber = T2.receipt and T2.item = T3.id |
Where T3.price > 15 |
13. Give me the list of all goods whose id has "APP". |
Select id |
from goods |
Where id LIKE "%APP%" |
Which good has "70" in its id? And what is its price? |
Select id, price |
from goods |