Back to questions
UnitedHealth Group has a program called Advocate4Me, which allows members to call an advocate and receive support for their health care needs – whether that's behavioural, clinical, well-being, health care financing, benefits, claims or pharmacy help.
Calls to the Advocate4Me call centre are categorised, but sometimes they can't fit neatly into a category. These uncategorised calls are labelled “n/a”, or are just empty (when a support agent enters nothing into the category field).
Write a query to find the percentage of calls that cannot be categorised. Round your answer to 1 decimal place.
A total of 5 calls were registered. Out of which 2 calls were not categorised. That makes 40.0% (2/5 x 100.0) of the calls uncategorised.
The dataset you are querying against may have different input & output - this is just an example!
We'll start by defining the formula.
Percentage of uncategorized calls = (Number of uncategorized calls / Total calls) x 100
Let's break this problem into 4 steps:
First, count the calls that are uncategorised i.e. call records with the column having either "n/a" or values which looks like an empty space.
225 calls were recorded without being assigned to a category.
Instead of putting this query into a subquery or CTE which can make the solution a bit lengthy, we're using the clause with the combination of the function. You can read about it in detail here under 4.2.7. Aggregate Expressions section.
Let's use the clause in our query above.
Have a run in the editor - it produces the same result!
In the following step, we will utilise another function to get the number of total calls regardless of the category.
Let's now modify our query to fit into the percentage formula.
Note: It is crucial to multiply by 100.0 instead of 100 since division operations require at least one numeric value to be of the data type. Otherwise, the digits after the decimal will be truncated and the results will be incorrect.
This brings us to our final solution query. Yay!
Solution #1: Using FILTER clause
There are numerous methods to solve this question. Below are 2 more suggested solutions for you to try out.
Solution #2: Using WHERE clause
Solution #3: Using CTE