Orders by Day of Week
Break orders down by day of the week. Use SQLite's strftime('%w', date), where 0 is Sunday and 6 is Saturday, as an integer weekday_num. Map it to a weekday_name of Sun, Mon, Tue, Wed, Thu, Fri or Sat. Only weekdays that have orders appear.
- order_count: number of orders
- revenue: sum of amount, ROUND(x, 2)
Return columns weekday_num, weekday_name, order_count, revenue. Order by weekday_num ascending.
Schema
CREATE TABLE orders ( order_id INTEGER PRIMARY KEY, order_date TEXT NOT NULL, amount REAL NOT NULL );
Sample data
orders
| order_id | order_date | amount |
|---|---|---|
| 1 | 2026-03-01 | 120 |
| 2 | 2026-03-02 | 80 |
| 3 | 2026-03-06 | 45.5 |
| 4 | 2026-03-08 | 60 |
| 5 | 2026-03-13 | 210.25 |
| 6 | 2026-03-14 | 33 |
| 7 | 2026-03-09 | 19.99 |
Hint 1
strftime('%w', d) returns text such as '0'; CAST it to INTEGER so the ordering is numeric.
Hint 2
A simple CASE expr WHEN value THEN ... maps the numbers to names.
Good practice for: Data Analyst, Digital Marketing Specialist, Business Analyst, Product Manager
Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.