Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Average Sales Per Month
00:00
5 left

SQL Average Sales Per Month

EasySQL · PostgreSQL

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
Interviewer

Your question is SQL Average Sales Per Month. Start with the requirements and the one table in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.