SQL QuestSQL Interview Questions › Date Functions

Monthly Order Volume in 2024

MediumFreeQuerying BasicsDate FunctionsAggregation & Grouping

The finance team wants a monthly order count for 2024. For each month of 2024, show the month (in YYYY-MM format, e.g. '2024-03') and the order_count. Include only orders where the year portion of order_date is 2024. Sort chronologically.

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 | 42, 2024-02 | 51, ...

Hint

strftime('%Y-%m', order_date) pulls the 'YYYY-MM' prefix. Filter with WHERE strftime('%Y', order_date) = '2024'. GROUP BY the same expression you SELECT.

Concepts

SELECT Date Functions strftime GROUP BY Aggregation

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

In these company practice sets

Airbnb · Apple · Ramp · Revolut · 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 · FreeMonthly Order TrendsMedium · FreeDate Functions: How Long Ago?Medium · 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