Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Compute Z Score
00:00
5 left

Compute Z Score

MediumSQL · PostgreSQL

Problem

Calculate Z score on a table with some sales data

Asked in the technical interview stage. SQL on a sales table. Write a query that calculates the z score for each sale using the non-null sales amounts.

Output

  1. One row per sale with a non-null amount
  2. Columns: sale_id, sale_amount, and z_score
  3. Round z_score to four decimal places and order by sale_id ascending

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique identifier for the sale
sale_amountNUMERIC(10,2)Sales amount used in the calculation
Tablessales
Interviewer

Your question is Compute Z Score. 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.