SQL QuestSQL Interview Questions › Date Functions

Monthly Order Trends

MediumFreeQuerying BasicsDate FunctionsAggregation & Grouping

Analyze order trends by month. Show the month (format: YYYY-MM), order_count, and total_revenue (sum of total) for each month. Sort by month ascending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

orders

order_idcustomer_idproductcategoryquantitypricetotalorder_datecountrystatus
11Laptop ProElectronics11299.991299.992024-01-15USAcompleted
22Wireless MouseElectronics249.9999.982024-01-16Canadacompleted
33Office ChairFurniture1349.99349.992024-01-17USAcompleted

Expected output: 2024-01 and 2024-02 with counts and totals

Hint

Use strftime('%Y-%m', order_date) to extract year-month. GROUP BY the same expression. SQLite stores dates as text in YYYY-MM-DD format.

Concepts

SELECT Date Functions GROUP BY Aggregation ORDER BY

Practise the topic: SQL practice questions · Date function practice · GROUP BY exercises

In these company practice sets

Airbnb · Apple · Ramp · Revolut · Shopify · Stripe · Uber · DoorDash

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Employee Tenure BandsMedium · FreeQuarterly Hiring Cohort ReportMedium · FreeCustomer Recency AnalysisMedium · FreeDate Functions: How Long Ago?Medium · FreeMonthly Order Volume in 2024Medium · FreeMulti-Month Active CustomersMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test