Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Average Without @avg
00:00
5 left

Average Without @avg

MediumSQL · PostgreSQL

Problem

If you did not have the AVG function, how would you find the average for cells A1-A10?

Assume the cells are stored as rows in PostgreSQL. Treat NULL cell values as blank cells that should be excluded from the calculation, and return NULL if every selected cell is blank.

Output

  1. Return one row with one column named average_value.
  2. Calculate the result only from cells A1 through A10.
  3. Return the average as a numeric value rounded to four decimal places.

Schema

spreadsheet_cells
ColumnTypeDescription
cell_idPKINTUnique identifier for the stored cell
cell_labelVARCHAR(10)Spreadsheet-style cell label
cell_valueNUMERIC(12,4)Numeric value stored in the cell, or NULL for a blank cell
Tablesspreadsheet_cells
Interviewer

Your question is Average Without @avg. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.