Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Counting Order Edits by Day

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Counting Order Edits by Day. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Staffline Solutions uses its order operations data to monitor how frequently orders are changed. Write a PostgreSQL query that returns the number of edits made to orders during the last seven calendar days, grouped by the day on which each edit occurred.

For the sample data, assume the query runs on 2026-08-29. In production, use the database server's current date.

Requirements

  1. Join order_edits to orders using the order identifier.
  2. Include edits from today and the six preceding calendar days, excluding older records and future records.
  3. Group by the calendar date extracted from edited_at and return one row per day with the edit count.
  4. Sort the results chronologically by day.

Schema

orders
ColumnTypeDescription
order_idPKINTEGERUnique identifier for the order
order_statusVARCHAR(30)Current processing status of the order
created_atTIMESTAMPTimestamp when the order was created
order_edits
ColumnTypeDescription
edit_idPKINTEGERUnique identifier for the edit event
order_idINTEGERReferences the edited order
edit_typeVARCHAR(40)Category of change made to the order
editor_nameVARCHAR(100)Staff member who made the edit
edited_atTIMESTAMPTimestamp when the edit occurred
Tablesordersorder_edits
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results