Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Average Sales Per Month

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

Your question is SQL Average Sales Per Month. Start with the requirements and the one table 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

Aviso AI wants a monthly view of sales performance for a selected reporting period. Write a PostgreSQL query using the sales table to calculate the average non-null sale amount for each month from January through March 2025.

Requirements

  1. Group sales by calendar month and return the month as YYYY-MM.
  2. Calculate the average sale_amount, rounded to two decimal places, and sort the results chronologically.
  3. Include only sales dated from 2025-01-01 through 2025-03-31.

Schema

sales
ColumnTypeDescription
sale_idPKINTEGERUnique sale identifier
sale_dateDATEDate the sale was recorded
sale_amountNUMERIC(10,2)Sale amount, which may be NULL
sales_channelVARCHAR(30)Channel through which the sale occurred
Tablessales
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results