text
stringlengths 0
359
|
|---|
Select CustomerId, count(*)
|
From receipts
|
Group by CustomerId
|
Order by count(*)
|
LIMIT 1
|
20. For each date, return how many distinct customers visited on that day.
|
Select date, count (distinct CustomerId)
|
from receipts
|
Group by date
|
Give me the first name and last name of customers who have bought apple flavor Tart.
|
Select distinct T4.FirstName, T4.LastName
|
from goods as T1 JOIN items as T2 JOIN receipts as T3 JOIN customers as T4 ON T1.id = T2.item and T2.receipt = T3.ReceiptNumber and T3.CustomerId = T4.id
|
where T1.flavor = "Apple" and T1.food = "Tart"
|
21. What are the ids of Cookies whose price is lower than any Croissant?
|
Select id
|
From goods
|
where food = "Cookie" and price < (select min(price)
|
from goods
|
where food = 'Croissant')
|
Give me the ids of Cakes whose price is at least three times as much as the average price of Tart?
|
Select id
|
From goods
|
where food = "Cake" and price >= 3 * (select avg(price)
|
from goods
|
where food = "Tart")
|
What are the ids of goods whose price is above twice the average price of all goods?
|
Select id
|
From goods
|
where price > 2 * (select avg(price)
|
from goods)
|
22. List the id, flavor and type of food of goods ordered by price.
|
Select id, flavor, food
|
From goods
|
order by price
|
Return a list of the id and flavor for Cakes ordered by flavor.
|
Select id, flavor
|
From goods
|
where food = "Cake"
|
order by flavor
|
23. Find all the items that have chocolate flavor but were not bought more than 10 times.
|
Select distinct T1.item
|
From items as T1 JOIN goods as T2 ON T1.item = T2.id
|
Where T2.flavor = "Chocolate"
|
EXCEPT
|
Select distinct item
|
From items
|
Group by item
|
having count(*) > 10
|
What are the flavors available for Cake but not for Tart?
|
Select distinct flavor
|
From goods
|
where food = "Cake"
|
EXCEPT
|
Select distinct flavor
|
From goods
|
where food = "Tart"
|
24. What is the three most popular goods in this bakery?
|
Select item
|
From items
|
Group by item
|
Order by count (*) DESC
|
LIMIT 3
|
25. Find the ids of customers who have spent more than 150 dollars in total.
|
Select T3.CustomerId
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.