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
- One row per active challenge, ordered by
challenge_id ascending.
- Return
challenge_id, challenge_name, domain_name, total_submissions, average_score, pass_rate_pct, and average_score_display.
- Use zero-valued numeric metrics when no applicable submissions exist, and show domain
Unassigned when the domain is missing.
Output details
- Round
average_score and pass_rate_pct to two decimal places and return them with two decimal places of numeric precision.
- Count every submission in
total_submissions, including submissions whose score is NULL.
- Compute
average_score from non-NULL scores only.
- Define
pass_rate_pct as passed submissions divided by submissions with non-NULL scores, multiplied by 100, rounded to two decimals.
- Count a submission with status
passed in the pass-rate numerator even when its score is NULL.
- Format
average_score_display with exactly two decimal places and no leading padding.