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
Extract Domain From Emails
00:00
5 left

Extract Domain From Emails

EasySQL · PostgreSQL

Problem

Write a SQL query to extract the domain name from a column containing raw email addresses.

Use the email_records table and handle leading or trailing whitespace, mixed-case addresses, NULL values, and malformed entries.

Output

  1. One row per valid email record, with columns id, raw_email, and domain_name.
  2. Exclude NULL, blank, and malformed email values.
  3. Normalize domains to lowercase and order results by id ascending.

Schema

email_records
ColumnTypeDescription
idPKINTUnique email record identifier
raw_emailVARCHAR(255)Raw email address, which may contain whitespace, mixed case, or invalid values
Tablesemail_records
Interviewer

Your question is Extract Domain From Emails. 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.