text
stringlengths 0
359
|
|---|
Where id LIKE "%70%"
|
14. List the last names of all customers in an alphabetical oder.
|
Select distinct LastName
|
From customers
|
Order by LastName
|
Return the ordered list of all good ids.
|
Select distinct id
|
From goods
|
Order by id
|
15. Find all receipts in which either apple flavor pie was bought or customer id 12 shopped.
|
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
|
Find all receipts which has the latest date. Also tell me that date.
|
Select ReceiptNumber, date
|
From receipts
|
where date = (Select date From receipts Order by date Desc LIMIT 1)
|
Find all receipts which either has the earliest date or has a good with price above 10.
|
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)
|
16. What are the ids of Cookie and Cake that cost between 3 and 7 dollars.
|
Select id
|
From goods
|
where (food = "Cookie" or food = "Cake") and price between 3 and 7
|
Find the first name and last name of a customer who visited on the earliest date.
|
Select T1.FirstName, T1.LastName
|
From customers as T1 JOIN receipts as T2 ON T1.id = T2.CustomerId
|
Order by T2.date
|
LIMIT 1
|
17. What is average price of goods whose flavor is blackberry or blueberry?
|
Select avg(price)
|
From goods
|
where flavor = "Blackberry" or flavor = "Blueberry"
|
Return the cheapest price for goods with cheese flavor.
|
Select min(price)
|
From goods
|
where flavor = "Cheese"
|
18. What are highest, lowest, and average prices of goods, grouped and ordered by flavor?
|
Select max(price), min(price), avg(price), flavor
|
From goods
|
group by flavor
|
order by flavor
|
Return the lowest and highest prices of goods grouped and ordered by food type.
|
Select min(price), max(price), food
|
From goods
|
group by food
|
order by food
|
19. Find the top three dates when the most goods were sold.
|
Select date
|
From receipts
|
Group by date
|
Order by count(*)
|
LIMIT 3
|
Which customer shopped most often? How many times?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.