Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Nulls and Precision in SQL
00:00
5 left

Nulls and Precision in SQL

MediumSQL · PostgreSQL

Problem

How would you handle null values and data type formatting, including ensuring precision in output, in a complex reporting query for HackerRank?

Use the provided HackerRank challenge, domain, and submission data. Include active challenges even when they have no submissions, and represent missing values consistently.

Output

  1. One row per active challenge, ordered by challenge_id ascending.
  2. Return challenge_id, challenge_name, domain_name, total_submissions, average_score, pass_rate_pct, and average_score_display.
  3. Use zero-valued numeric metrics when no applicable submissions exist, and show domain Unassigned when the domain is missing.

Schema

challenges
ColumnTypeDescription
challenge_idPKINTUnique HackerRank challenge identifier
challenge_nameVARCHAR(120)Challenge display name
domain_idINTOptional associated domain
is_activeBOOLEANWhether the challenge is currently active
domains
ColumnTypeDescription
domain_idPKINTUnique domain identifier
domain_nameVARCHAR(80)Challenge domain name
submissions
ColumnTypeDescription
submission_idPKINTUnique submission identifier
challenge_idINTChallenge associated with the submission
scoreNUMERIC(5,2)Submission score, which may be missing
statusVARCHAR(20)Submission result status
Tableschallengesdomainssubmissions
Interviewer

Your question is Nulls and Precision in SQL. Start with the requirements and the three tables 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.