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
SQL Email Null Handling
00:00
5 left

SQL Email Null Handling

EasySQL · PostgreSQL

Problem

Alcon is reviewing the completeness of contact records used for customer communications. Given the t1 table, write a PostgreSQL query that calculates what percentage of records contain an email address.

Treat an email address as present when email is non-null. The result should be safe against division by zero and should report the percentage rounded to two decimal places.

Requirements

  1. Return the total number of records and the number of records with non-null email addresses.
  2. Calculate the email coverage percentage as records_with_email / total_records * 100.
  3. Round the percentage to two decimal places and avoid integer division or division-by-zero errors.

Schema

t1
ColumnTypeDescription
nameVARCHAR(100)Alcon contact name
emailVARCHAR(255)Contact email address
Tablest1
Interviewer

Your question is SQL Email Null Handling. 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.