11 Cigna SQL Interview Questions (Updated 2024)

Updated on

August 11, 2024

At Cigna, SQL is essential for extracting and analyzing healthcare data, allowing them to create predictive models that identify potential health risks for patients. It is also used for developing effective health management strategies and improving patient care by tailoring services to individual needs, that is the reason why Cigna asks SQL questions during interviews for Data Science, Data Engineering, and Data Analytics jobs.

To help you prep for the Cigna SQL interview, we've curated 11 Cigna SQL interview questions – can you solve them?

Cigna SQL Interview Questions

11 Cigna SQL Interview Questions

SQL Question 1: Identify VIP Users for Cigna

Cigna is a health service company that's committed to their customers' long-lasting health and well-being. Assume you have access to their customer database where you have a table that keeps track of all user interactions with their services. Particularly, it records the , , , and of the interaction. Let's say for Cigna, power (VIP) users are defined as users who frequently engage with Cigna's health checkups and consultations, with the total cost of their activities within the last month exceed $5000.

Write a SQL query to identify these VIP users.

Example Input:

activity_iduser_idtimestampactivitycost
101100109/01/2022 00:00:00Health Checkup750
102100209/01/2022 00:00:00Consultation100
103100109/05/2022 00:00:00Health Checkup750
104100309/15/2022 00:00:00Vaccination50
105100109/20/2022 00:00:00Health Checkup750

Example Output:

vip_user_id
1001

Answer:


In this solution, we first filter out the to only consider activities from the last month. Then, we limit it to the activities of interest - 'Health Checkup' and 'Consultation'. By grouping the records by and summing the for each user, we can identify those users whose total cost exceed $5000, who are considered as VIP users.

To practice a related customer analytics question on DataLemur's free interactive coding environment, try this recently asked Microsoft SQL interview question: Microsoft SQL Interview Question: Teams Super User

Dive into Cigna's newsroom to discover the latest updates and initiatives that are shaping the future of health services! Staying informed about their efforts can provide you with valuable insights into how they are addressing the challenges in the healthcare landscape.

SQL Question 2: Highly-Paid Employees

Given a table of Cigna employee salary information, write a SQL query to find employees who earn more money than their direct boss.

Cigna 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.

Test your SQL query for this problem directly within the browser 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 code above is hard to understand, you can find a detailed solution here: Employees Earning More Than Their Boss.

SQL Question 3: How does the RANK() window function differ from DENSE_RANK()?

In SQL, both and are used to rank rows within a result set. The key difference between the two functions is how deal with two or more rows having the same value in the ranked column (aka how the break ties).

RANK(): When there's a tie, leaves a gap in the ranking. For example, if three rows are tied for 2nd place, the RANK() function will assign a rank of 2 to the first of these rows, a rank of 3 to the second row, and a rank of 4 to the third row.

DENSE_RANK(): For ties, does not leave a gap in the ranking. Instead, it assigns the same rank to all tied rows, and then makes the next row 1 bigger. Confusing, I know, but here's an example to make it more clear: if three rows are tied for 3rd place, the function will assign a rank of 3 to all three rows, and then assign a rank of 4 to the next row.

Cigna SQL Interview Questions

SQL Question 4: Rank the Clients By Total Claim Amount

Assume that you are working for Cigna, a health services company. They have provided you with a table called containing data about their company's claims. Each row in the Claims table represents a claim made by a client.

The Claims table has the following columns:

  • : The claim's unique ID.
  • : The ID of the client who made the claim.
  • : The date the claim was made.
  • : The amount of the claim.

Write a SQL query that ranks the clients by the total amount they claimed in descending order over the past year (365 days). For clients with the same total claim amount, they should be ranked by the earliest claim date they have. You should return the client ID, the total claim amount, the earliest claim date, and the rank in the output.

Example Input:

ClaimIDClientIDClaimDateClaimAmount
84351232022-06-08500
27912652022-06-10300
52842652022-06-18400
37951232022-07-26800
46103622022-07-05700

Expected output would look like this:

Example Output:

ClientIDTotalClaimAmountEarliestClaimDateRank
2657002022-06-101
12313002022-06-082
3627002022-07-053

Answer:


This query is using a window function and a clause to aggregate the of and of by . The claim data is filtered to include only the past year claims. The function is applied on the total claim amount in descending order and for claims with same total, it is ranked by the earliest claim date. In the output, it returns the , , , and .

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

DataLemur SQL Questions

SQL Question 5: What sets the 'BETWEEN' and 'IN' operators apart?

The and operators are both used to filter data based on certain criteria, but they work in different ways. is used to select values within a range, while is used to select values that match a list.

For instance, if you have a table called that contains the salary of each employee, along with which country they reside in, you could use the operator to find all employees who make between 130kand130k and 160k:


To find all employees that reside in France and Germany, you could use the operator:


SQL Question 6: Healthcare Provider Database Design

Cigna, being a health insurance company, consistently handles a large number of healthcare provider records which include details about the providers, their specialization, the services they provide and the corresponding cost for those services. A patient is able to consult any provider linked to Cigna.

Design the table structure required to store this information effectively. Each patient can have numerous provider visits, and each provider visit will have a corresponding service provided and its cost.

Sample Input:

provider_idprovider_namespecialization
101Dr. AdamsCardiologist
102Dr. BakerDermatologist
103Dr. CarterOrthopedic

Sample Input:

service_idservice_nameservice_cost
201Heart Checkup$200
202Skin treatment$100
203Bone treatment$150

Sample Input:

patient_idpatient_name
301John Doe
302Jane Doe

Sample Input:

visit_idpatient_idprovider_idservice_idvisit_date
4013011012012023-01-23
4023021022022023-01-24
4033011032032023-02-15

Answer:

Given the database design and samples above, suppose we want to query the total cost of all services a patient has received. We can achieve this with a query in PostgreSQL as shown below:


This query will provide us with a table where for each patient, we have a sum of all service costs that patient has received. We first join and tables on the field. Then, we join the table using the from the table. Finally, we group the results by and sum up the .

SQL Question 7: In SQL, are NULLs treated the same as zero's and blank spaces?

In SQL, a value is NOT the same as a zero or a blank space. A NULL value represents the absence of a value or a missing value, whereas both zero and blank space are actually values.

To handle nulls, the function is often used to check for a null, and if there is a null, you can assign a default value.

SQL Question 8: Calculate the Click-through rate for Cigna's digital marketing campaigns

As a Data Analyst at Cigna Corporation, an American worldwide health services organization, you are tasked with calculating the click-through rate (CTR) for the company's digital marketing campaigns. Click-through rate is the ratio of users who click on a specific link to the number of total users who view a page, email, or advertisement. In this context, you are given 'impressions' that is the total number of views on the ads and 'clicks', which is a count of how many people actually clicked on them.

Use the data provided in the 'ad_campaign' table to calculate the daily click-through-rate for each campaign.

Example Input:

datecampaign_idimpressionsclicks
01/01/20221011000250
02/01/20221011200300
01/01/20221021500375
02/01/20221021800450
01/01/20221031300325
02/01/20221031400350

Answer:


This SQL query calculates the daily CTR for each campaign by taking the ratio of clicks to impressions and then multiplying by 100 to get it in percentage terms. The output is ordered by date and campaign id.

Example Output:

datecampaign_idclicksimpressionsctr
01/01/2022101250100025.00
01/01/2022102375150025.00
01/01/2022103325130025.00
02/01/2022101300120025.00
02/01/2022102450180025.00
02/01/2022103350140025.00

Note, it is assumed that the and fields are numeric types and can be safely converted to float for the division operation.

To practice a similar problem on DataLemur's free interactive coding environment, attempt this Meta SQL interview question:

Facebook Click-through-rate SQL Question

SQL Question 9: Find the Average Cost of Different Treatment Services per Year

Each patient at the healthcare company Cigna receives various treatment services. For research and analysis purposes, Cigna wants to know the average cost of each treatment service it provides per year. Write a SQL query to find out the average cost on a yearly basis for each treatment service within the database.

Example Input:

record_idpatient_idtreatment_dateservice_idcost
876152301/08/202010001250
341298303/10/202020052150
789337607/18/202010001300
635423109/26/202020052200
933578212/05/202120052180

Example Output:

yearserviceavg_cost
202010001275.00
202020052175.00
202120052180.00

Answer:


This query uses the GROUP BY clause to group the data by the year of the treatment_date and service_id. It calculates the average cost of each service for each year. The AVG() function calculates the average cost of the rows that fall into each group, giving us the average cost of each service Cigna provides on a yearly basis.

SQL Question 10: What's the purpose of the the command?

combines the results from two or more SELECT statements, but only returns the rows that are exactly the same between the two sets.

For example, let's use to find all of Cigna's Facebook video ads with more than 10k views that are also being run on YouTube:


SQL Question 11: Filter Customer Records

As a Database Analyst at Cigna, you are tasked with filtering out the customer records from the database in order to track customers who have a certain pattern in their email addresses. Specifically, you are to write a SQL query that gives you a list of all customer records who have the '@cigna.com' email extension.

The customer database has the following simplified structure:

Example Input:

customer_idfirst_namelast_nameemailsignup_date
101JohnDoejohn.doe@cigna.com01/01/2022 00:00:00
102JaneSmithjane.smith@gmail.com01/05/2022 00:00:00
103SamBrownsam.brown@cigna.com01/10/2022 00:00:00
104EmilyJohnsonemily.johnson@gmail.com01/15/2022 00:00:00
105BobDavisbob.davis@cigna.com01/20/2022 00:00:00

Your task is to return a table in the following format:

Example Output:

customer_idfirst_namelast_nameemail
101JohnDoejohn.doe@cigna.com
103SamBrownsam.brown@cigna.com
105BobDavisbob.davis@cigna.com

Answer:


This query is filtering the customers table to only include rows where the email address ends with '@cigna.com'. The '%' functions as a wildcard character that matches any sequence of characters, ensuring that all email addresses ending with '@cigna.com' are included, regardless of what precedes this string in the email field.

How To Prepare for the Cigna SQL Interview

The best way to prepare for a Cigna SQL interview is to practice, practice, practice. In addition to solving the earlier Cigna SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like FAANG tech companies and tech startups.

DataLemur SQL and Data Science Interview Questions

Each exercise has multiple hints, fully explained answers along with a discussion board to see how others solved it and crucially, there's an online SQL code editor so you can right in the browser run your query and have it executed.

To prep for the Cigna SQL interview it is also wise to solve SQL problems from other healthcare and pharmaceutical companies like:

However, if your SQL skills are weak, forget about going right into solving questions – refresh your SQL knowledge with this SQL tutorial for Data Scientists & Analysts.

DataLemur SQL Tutorial for Data Science

This tutorial covers SQL topics like SQL joins with practice exercises and joining a table to itself – both of which pop up often during SQL job interviews at Cigna.

Cigna Data Science Interview Tips

What Do Cigna Data Science Interviews Cover?

Besides SQL interview questions, the other question categories covered in the Cigna Data Science Interview include:

Cigna Data Scientist

How To Prepare for Cigna Data Science Interviews?

To prepare for Cigna Data Science interviews read the book Ace the Data Science Interview because it's got:

  • 201 interview questions sourced from Facebook, Google, & Amazon
  • a crash course covering Python, SQL & ML
  • over 1000+ 5-star reviews on Amazon

Ace the DS Interview

Don't ignore the behavioral interview – prepare for it using this list of common Data Scientist behavioral interview questions.

© 2024 DataLemur, Inc

Career Resources

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