Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
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

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the one table are in the Question tab.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.