11 Encompass Health SQL Interview Questions (Updated 2024)

Updated on

October 31, 2024

At Encompass Health, SQL is used for extracting and analyzing patient health data to enhance the quality of care provided to patients. They also used SQL to manage large amounts of healthcare databases, making it easier for healthcare professionals to access critical data quickly and efficiently, that is why Encompass Health includes SQL coding questions in interviews for Data Analyst, Data Science, and BI positions.

So, to help you prepare, we've collected 11 Encompass Health SQL interview questions – can you solve them?

Encompass Health SQL Interview Questions

11 Encompass Health SQL Interview Questions

SQL Question 1: Identify High Utilization Patients at Encompass Health

Encompass Health offers inpatient rehabilitation, home health, and hospice services. For their business, a power user (or VIP user, or whale user) might be a patient who frequently utilizes their services.

As an interviewee, you are asked to write a SQL query that identifies customers who have had the highest number of services (across all types of services) in the past one year.

For this question, we will assume that Encompass Health maintains two tables:

Example Input:

patient_idnameregistration_date
1John Doe01-01-2018
2Jane Doe01-04-2017
3Emily Smith01-01-2019

Example Input:

service_idpatient_idservice_typeservice_date
10011Inpatient Rehab01-01-2020
10021Home Health01-03-2020
10032Hospice01-02-2020
10042Inpatient Rehab01-08-2020
10053Home Health02-01-2020
10061Home Health04-01-2020

Answer:

You can make use of the following PostgreSQL query:


This SQL query identifies the top 10 patients who have availed the highest number of services in the past 1 year. It joins the and tables on the column, filters for services utilized in the past one year, counts the number of services per patient, and finally orders the result in decreasing order of service count. The query uses a to include all patients even if they do not appear in the table, but this may be changed to a if only patients who appear in the table are of interest.

To solve a related customer analytics question on DataLemur's free online SQL coding environment, try this Microsoft Azure Cloud SQL Interview Question:

Microsoft SQL Interview Question: Super Cloud Customer

SQL Question 2: Highly-Paid Employees

Given a table of Encompass Health employee salary information, write a SQL query to find all employees who make more than their direct boss.

Encompass Health Example Input:

employee_idnamesalarydepartment_idmanager_id
1Emma Thompson38001
2Daniel Rodriguez2230110
3Olivia Smith800018
4Noah Johnson680028
5Sophia Martinez1750110
8William Davis70002NULL
10James Anderson40001NULL

Example Output:

employee_idemployee_name
3Olivia Smith

This is the output because Olivia Smith earns $8,000, surpassing her manager, William Davis who earns 7,800.

Try this problem interactively on DataLemur:

Employees Earning More Than Their Manager

Answer:

First, we perform a SELF-JOIN where we treat the first table () as the managers' table and the second table () as the employees' table. Then we use a clause to filter the results, ensuring we only get employees whose salaries are higher than their manager's salary.


If the solution above is confusing, you can find a step-by-step solution here: Highly-Paid Employees.

SQL Question 3: What is a cross-join, and when would you use one?

A cross-join, also known as a cartesian join, is a JOIN that produces the cross-product of two tables. In a cross-join, each row from the first table is matched with every row from the second table, resulting in a new table with a row for each possible combination of rows from the two input tables.

Suppose you were building a Neural Network ML model, that tried to score the probability of a customer buying a Encompass Health product. Before you started working in Python and Tensorflow, you might want to do some Exploratory Data Analysis (EDA) in SQL, and generate all pairs of customers and Encompass Health products.

Here's a cross-join query you could use to find all the combos:


Cross-joins are great for generating all possible combinations, but they can also create really big tables if you're not careful. For example, if you had 10,000 potential customers, and Encompass Health had 500 different product SKUs, you'd get 5 million rows as a result!!

Encompass Health SQL Interview Questions

SQL Question 4: Analyze Patient Recoveries using Window Functions

Encompass Health is a company that provides inpatient rehabilitation, home health, and hospice services. Suppose that you are given a table of patient discharges, and you are tasked to analyze the average recovery time by month for each state using SQL window functions.

Here is the data you have:

Example Input:

discharge_idpatient_idstateadmission_datedischarge_date
12345678Alabama2022-04-012022-04-15
23456789Alabama2022-04-032022-04-20
34567890Alabama2022-05-012022-05-11
45678901California2022-04-102022-04-15
56789012California2022-04-202022-04-30
67892345California2022-05-052022-05-15

and are both in 'YYYY-MM-DD' format. Recovery time is computed as the number of days between and .

Your task is to write a PostgreSQL query that computes the average recovery time by month and by state.

Answer:


This PostgreSQL query uses the window function . For each row, it computes the average difference in days between and , grouping the rows by both state and the month of the . The function is used to get the month at which the occurred, and the is used to compute the number of days that the patient stayed at the facility. The clause then orders the results first by state, then by month.

Pro Tip: Window functions are a frequent SQL interview topic, so practice all the window function problems on DataLemur

DataLemur SQL Questions

SQL Question 5: What are some similarities and differences between unique and non-unique indexes?

Some similarities between unique and non-unique indexes include:

  • Both indexes improve the performance of SQL queries by providing a faster way to lookup the desired data.
  • Both indexes use an additional data which requires more storage space which impacts write performance.
  • Both indexes can be created on one or more columns of a table

Some differences between unique and non-unique indexes include:

  • A unique index enforces the uniqueness of the indexed columns, meaning that no duplicate values are allowed in the indexed columns. A non-unique index allows duplicate values in the indexed columns.
  • A unique index can be used to enforce the primary key of a table, but a non-unique index cannot.
  • A unique index can have a maximum of one NULL value in the indexed columns, but a non-unique index can have multiple NULLs

SQL Question 6: Average Service Rating per Health Facility

Encompass Health wishes to better understand their service quality across different health facilities. They ask you to provide them with the average ratings received by each health facility on a monthly basis.

You are given access to two tables. The table includes a rating id, a patient id, the submit date of the review, the id of the health facility, and the star ratings given. Meanwhile, the table consists of a facility id and its corresponding name.

Example Input:

rating_idpatient_idsubmit_datefacility_idstars
111156708/05/2023 00:00:000015
111289008/10/2023 00:00:000023
111312308/12/2023 00:00:000014
111445608/15/2023 00:00:000022
111578908/20/2023 00:00:000013

Example Input:

facility_idfacility_name
001Encompass Health Hospital A
002Encompass Health Hospital B

Example Output:

mthfacility_nameavg_stars
8Encompass Health Hospital A4.00
8Encompass Health Hospital B2.50

Answer:

The PostgreSQL query to get the solution would look something like this:


The solution first joins the and tables on the . It then groups the data based on the month of the and , and calculates the average for each group. The result is then sorted by and in descending order to get the output.

SQL Question 7: How do you locate records in one table that are absent from another?

To discover records in one table that are not present in another, you can utilize a and filter out any values in the right-side table.

For example, say you had a table of Encompass Health customers and a 2nd table of all purchases made with Encompass Health. To find all customers who did not make a purchase, you'd use the following


This query fetches all rows from the customers table, along with any rows that match in the purchases table. If there is no matching row in the purchases table, values will be returned for all of the right table's columns. The clause then filters out any rows where the column is NULL, leaving only customers who have not made a purchase.

SQL Question 8: Average Patient Recovery Time

For Encompass Health, a key metric could be the average patient recovery time. Here's a question to test your knowledge of function.

"How would you determine the average number of days it takes for a patient to recover, per diagnosis, in the last year?"

Please use the following sample data:#### Example Input:

patient_idadmit_datedischarge_datediagnosis
11232021-01-052021-01-18Stroke
21442021-03-102021-04-07Cardiac Surgery
31542021-07-202021-08-10Stroke
41272021-10-052021-10-15Cardiac Surgery
53622021-12-012022-01-10Stroke

Answer:


This query calculates the average recovery time ( - ) for patients admitted between 2021-01-01 and 2022-01-01. It groups the result by diagnosis to get the average recovery time per diagnosis.

To practice a very similar question try this interactive Amazon Average Review Ratings Question which is similar for calculating average metrics or this Facebook Average Post Hiatus (Part 1) Question which is similar for determining averages over a time period.

SQL Question 9: Calculate the Click-Through-Rate for Digital Health Services Ads

Encompass Health is interested in understanding the effectiveness of their digital health services advertisements. For each advertisement, we have information on how many times it was displayed and how many times it was clicked through to the product page.

The task is to calculate the click-through-rate (CTR) for each ad. CTR is calculated as the number of clicks an ad receives divided by the number of times the ad is shown, multiplied by 100% (to get the percentage).

Here's some sample data:

Example Input:

ad_iddisplayed_countclicked_count
110000500
2200002500
315000250
4300004500
55000020000

The task: Write a SQL query that calculates the CTR for each ad.

Answer:


Example Output:

ad_iddisplayed_countclicked_countclick_through_rate
1100005005.00
220000250012.50
3150002501.67
430000450015.00
5500002000040.00

The query calculates the Click-Through-Rate for each ad by dividing the by and then multiplying by 100 to get the percentage. The function is used to convert into a float to ensure accurate division results.

To solve a similar SQL problem on DataLemur's free online SQL code editor, solve this Facebook SQL Interview question:

Facebook Click-through-rate SQL Question

SQL Question 10: What do stored procedures do, and when would you use one?

Stored procedures are like functions in Python – they can accept input params and return values, and are used to encapsulate complex logic.

For example, if you worked as a Data Analyst in support of the Marketing Analytics team at Encompass Health, a common task might be to find the conversion rate for your ads given a specific time-frame. Instead of having to write this query over-and-over again, you could write a stored procedure like the following:


To call this stored procedure, you'd execute the following query:


SQL Question 11: Find Average Patient Recovery Time Per Treatment

Encompass Health offers different health services and treatments to patients. They have a system that tracks patients from the time they start treatment to when they finish their treatment and gain recovery. The intent is to monitor and find an average of how long each of their services takes to effectively heal a patient. Therefore, your task is to write a SQL query to determine the average recovery time per service.

Example Input:

recovery_idpatient_idtreatment_idstart_dateend_date
6012345100106/15/202206/25/2022
7210926200206/08/202206/19/2022
5028568100106/20/202207/04/2022
6096782300306/22/202207/06/2022
4254298200206/29/202207/14/2022

Example Output:

treatmentaverage_recovery_days
100112.5
200213.0
300314.0

Answer:


In this query, we first extract the number of days between the and the for each recovery record. We then use the function to calculate the average number of recovery days for each treatment (by grouping the records by ).

How To Prepare for the Encompass Health SQL Interview

Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Encompass Health SQL interview is to solve as many practice SQL interview questions as you can! Beyond just solving the above Encompass Health SQL interview questions, you should also solve the 200+ SQL questions from real Data Science & Analytics interviews which come from companies like Google, Uber, and Microsoft.

DataLemur Questions

Each exercise has hints to guide you, full answers and crucially, there's an interactive coding environment so you can instantly run your SQL query answer and have it executed.

To prep for the Encompass Health SQL interview it is also a great idea to solve SQL questions from other healthcare and pharmaceutical companies like:

However, if your SQL skills are weak, don't worry about going right into solving questions – improve your SQL foundations with this free SQL tutorial.

SQL tutorial for Data Scientists & Analysts

This tutorial covers SQL topics like filtering data with WHERE and filtering strings based on patterns – both of these show up frequently during SQL job interviews at Encompass Health.

Encompass Health Data Science Interview Tips

What Do Encompass Health Data Science Interviews Cover?

Beyond writing SQL queries, the other types of problems tested in the Encompass Health Data Science Interview are:

Encompass Health Data Scientist

How To Prepare for Encompass Health Data Science Interviews?

To prepare for the Encompass Health Data Science interview make sure you have a firm understanding of the company's values and company principles – this will be clutch for acing the behavioral interview. For technical interviews prepare by reading Ace the Data Science Interview. The book's got:

  • 201 Interview Questions from Google, Microsoft & tech startups
  • A Refresher covering SQL, AB Testing & ML
  • Amazing Reviews (1000+ reviews, 4.5-star rating)

Ace the DS Interview

© 2024 DataLemur, Inc

Career Resources

Free 9-Day Data Interview Crash CourseFree SQL Tutorial for Data AnalyticsUltimate SQL Interview GuideAce the Data Job Hunt Video CourseAce the Data Science InterviewBest Books for Data Analysts