SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Bulk Buyers on First and Last Day

Unsolved

A bookstore wants to find customers who started and finished their buying history with a big haul. Group each customer's purchases by calendar day. A customer's first purchase day is their earliest such day and their last purchase day is their latest. A customer qualifies when the total quantity of books bought on the first day is at least 3 and the total on the last day is also at least 3. Customers whose purchases all happened on a single day have no separate last day and never qualify. Write an SQL query that returns customer_id, first_day_books and last_day_books for every qualifying customer. Order the results by customer_id ascending.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Meta

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM book_sales
Full source dataset
21 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine