Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Average Sales by Region

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

Your question is SQL Average Sales by Region. 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

NCR Atleos uses regional sales data to review performance across its ATM and payment technology business. Write a PostgreSQL query to calculate the average sale amount for each region.

Requirements

  1. Group rows by region and calculate the average of sale_amount using AVG.
  2. Return one row per region, including a NULL region when present, and sort alphabetically with the NULL region last.

Schema

regional_sales
ColumnTypeDescription
sale_idPKINTEGERUnique sale identifier
regionVARCHAR(50)Sales region, or NULL when not assigned
sale_amountNUMERIC(12,2)Sale amount
sale_dateDATEDate of the sale
Tablesregional_sales
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results