Use GROUP BY with TRIM to clean trailing whitespace, ORDER BY DESC, and LIMIT
What are our top 10 most common diagnoses by encounter volume? Use the diagnosis_code field. I suspect there may be duplicates from whitespace issues in the EHR extract — our IT team has flagged this before. Clean it up before you count.
Each hint you reveal reduces the XP you can earn. Try the query first.
The diagnosis codes in `fact_encounters` may have trailing spaces — raw grouping will split what should be one code into two
Wrap the code in the function that strips whitespace, then group and count as usual. Only keep the top 10
`SELECT ___(diagnosis_code) AS diagnosis_code, COUNT(*) AS encounter_count FROM fact_encounters GROUP BY ___ ORDER BY ___ DESC LIMIT ___`