8 McKesson SQL Interview Questions (Updated 2024)

Updated on

October 31, 2024

McKesson employees rely on SQL to extract and analyze patient healthcare data, which helps them understand trends and improve patient outcomes. They also use SQL to keep track of pharmaceutical inventory across various locations, ensuring that the right medications are available when needed, this is why McKesson includes SQL problems in their interviews for Data Analytics, Data Science, and Data Engineering positions.

So, to help you practice for the McKesson SQL interview, here’s 8 McKesson SQL interview questions in this article.

McKesson SQL Interview Questions

8 McKesson SQL Interview Questions

SQL Question 1: Calculate Monthly Average Sales Per Product

McKesson is a multi-national company in the healthcare sector, which trades in pharmaceuticals and medical products along with providing related services. They require regular analysis of their sales data for decision making. For this exercise, we are going to analyze the average monthly sales per product using a window function.

Let's say the data they have is in the following table, , which logs each purchase event:

Example Input:

sale_iddate_of_saleproduct_idunits_soldsale_price_per_unit
100101/05/2022A1232010
100201/05/2022B4563020
100301/18/2022A1231510
100402/05/2022B4562520
100502/18/2022A1232510
100603/05/2022B4564020

Our task is to write a SQL query that calculates the average monthly sales per product.

Answer:

The PostgreSQL query to solve the above question would be:


This query uses the window function to calculate the average monthly sales for each product. The clause is used to divide the sales data into partitions based on the product_id and the month of the sale. The function is used to truncate the date to the nearest month, which allows us to calculate a separate average for each month. The results are then ordered by the month and product_id for easy visualization.

To solve a similar window function interview problem which uses RANK() on DataLemur's free interactive SQL code editor, try this Amazon SQL Interview Question:

Amazon Highest-Grossing Items SQL Analyis Question

Explore McKesson's technology solutions for specialty practices to learn how they are enhancing healthcare delivery through innovative solutions! Understanding McKesson's initiatives can provide valuable insights into the intersection of technology and healthcare.

SQL Question 2: Top Department Salaries

Given a table of McKesson employee salary data, write a SQL query to find the top 3 highest paid employees in each department.

McKesson Example Input:

employee_idnamesalarydepartment_id
1Emma Thompson38001
2Daniel Rodriguez22301
3Olivia Smith20001
4Noah Johnson68002
5Sophia Martinez17501
8William Davis68002
10James Anderson40001

Example Input:

department_iddepartment_name
1Data Analytics
2Data Science

Example Output:

department_namenamesalary
Data AnalyticsJames Anderson4000
Data AnalyticsEmma Thompson3800
Data AnalyticsDaniel Rodriguez2230
Data ScienceNoah Johnson6800
Data ScienceWilliam Davis6800

Code your solution to this interview question directly within the browser on DataLemur:

Top 3 Department Salaries

Answer:

We use the DENSE_RANK() window function to generate unique ranks for each employee's salary within their department, with higher salaries receiving lower ranks. Then, we wrap this up in a CTE and filter the employees with a ranking of 3 or lower.


If the solution above is confusing, you can find a detailed solution with hints here: Top 3 Department Salaries.

SQL Question 3: How does the LEAD() function differ from the LAG() function?

Both window functions are used to find rows at a given offset from the current row. However, will give you the rows AFTER the current row you. On the other hand, will give you the rows BEFORE the current row.

McKesson SQL Interview Questions

SQL Question 4: Designing a Database for a Pharmaceutical Distributor

Suppose you are a DBA (database administrator) for McKesson, a pharmaceutical distribution company. You are tasked with designing a database to track product shipments. Your system should be able to handle the storage of several entities: products, distribution centers, shipments, and customers. Consider the following requirements:

  • Each product has a unique identifier, name, and description.
  • Each distribution center has a unique identifier and location.
  • Each shipment has a unique identifier, a shipment date, and relates to one product from one distribution center to one customer.
  • Each customer has a unique identifier, name, and address.

Design an efficient SQL database schema that can handle these requirements. Also, create a query that can retrieve the total quantity shipped of a specific product in a specific month.

Example Input:

product_idnamedescription
1Drug AProduct description
2Drug BProduct description

Example Input:

center_idlocation
1Chicago
2Los Angeles

Example Input:

shipment_idproduct_idcenter_idcustomer_iddate_shippedquantity
111106/01/2022500
211206/10/2022200
322106/15/2022300
412107/01/2022700

Example Input:

customer_idnameaddress
1John Doe123 Elm St
2Jane Doe456 Oak St

Answer:

The SQL query to retrieve the total quantity shipped of a specific product (here, product_id = 1) in a specific month (here, June 2022) would be as follows:


This query uses the aggregate function to sum up the total quantity of the specified product_id shipped within the specified month and year. The function is used to get the month and year components from the shipment date for the condition in the statement.

SQL Question 5: What's the difference between relational and non-relational databases?

While knowing this answer is beyond the scope of most Data Analyst & Data Science interviews, Data Engineers at McKesson should be at least aware of SQL vs. NoSQL databases.

Relational databases and non-relational (NoSQL) databases have some key differences, particularly in terms of how data is stored. Whereas relational databases have tables, made up of rows and columns, NoSQL databases use various data models like:

  • Wide-Column Stores – this database uses tables, rows, and columns, but unlike a relational database, the names and format of the columns can vary from row to row within the same table
  • Key-Value Stores – instead of rows and columns, you have keys, where each key is associated with only one value in a collection (similar to a Python dictionary data structure!)
  • Graph Stores – instead of rows of data, you have nodes, and then can also have edges between entities (much like a Graph Data Structure for those who've taken a Computer Science data structures & algorithms class)

This added flexibility makes NoSQL databases well-suited for handling non-tabular data or data with a constantly changing format. However, this flexibility comes at the cost of ACID compliance, which is a set of properties (atomic, consistent, isolated, and durable) that ensure the reliability and integrity of data in a database. While most relational databases are ACID-compliant, NoSQL databases may not provide the same level of guarantees.

SQL Question 6: Computing the Click-Through-Rates for the McKesson Company

McKesson is a healthcare company that offers a number of products and services. To maximize their outreach, they have run several online advertising campaigns. Each campaign showed a specific ad, and when the ad was clicked, it redirected the user to McKesson's website where they could view the product and possibly add it to their cart.

As a data analyst, you have been asked to compute the click-through rate, which is the ratio of users who clicked a specific ad to the total users who viewed the ad. You've been also tasked to compute the conversion rate for each product, which is defined as the ratio of the users who added a product to their cart to the total users who clicked the associated ad.

Here are some example datasets:

Example Input:

ad_idproduct_id
1101
2102
3103

Example Input:

user_idad_idview_date
12312022-07-07
12422022-07-07
12532022-07-07
12612022-07-07
12722022-07-07
Example Input:
user_idad_idclick_date
12312022-07-08
12422022-07-08
12532022-07-08
12612022-07-08
Example Input:
user_idproduct_idadd_to_cart_date
1231012022-07-08
1241022022-07-08
1251032022-07-08

Answer:

Here is a PostgreSQL solution to calculate the click-through rate and the conversion rate for each product:


This query first computes the click-through and conversion rates independently of each other (using the WITH clauses creating and ), and then merges these two results using a LEFT JOIN. The conversion and click-through rates are computed by counting the unique users that performed the positive event (clicking an ad or adding a product to cart) and dividing this by the count of unique users that had the opportunity to perform that action (view an ad or click an ad).

To practice a similar problem on DataLemur's free online SQL coding environment, solve this SQL interview question asked by Facebook: Meta SQL interview question

SQL Question 7: What do foreign key's do?

A foreign key is a field in a database table that links to the primary key of another table, establishing a connection between the two tables. For example, let's analyze McKesson's Google Ads campaigns data:

:

ad_idcampaign_idkeywordclick_count
1201McKesson reviews120
2202McKesson pricing150
3101buy McKesson65
4101McKesson alternatives135

is a foreign key that connects to the of the corresponding Google Ads campaign. This establishes a relationship between the ads and their campaigns, enabling easy querying to find which ads belong to a specific campaign or which campaigns a specific ad belongs to.

The table may also have multiple foreign keys that reference primary keys in other tables. For example, and foreign keys could be used to link each ad to its ad group and the Google Ads account that the campaigns belong to, respectively.

SQL Question 8: Filtering Customer Records Within McKesson Database

Suppose you are working as a Data Analyst in McKesson, a pharmaceutical and medical supplies company. You have been tasked with finding a list of clients in the company's database whose first names start with 'John'. This list should include the clients' full names, addresses, and emails.

For the purpose of this task, assume that the client information is stored in a single table, .

Example Input:

customerIdfirstNamelastNameaddressemail
001JohnDoe1234 Broadway St.john.doe@example.com
002JohnnyAppleseed5678 Main St.johnny.appleseed@example.com
003JaneDoe9012 Park Ave.jane.doe@example.com
004JonathanSmith3456 Oak St.jonathan.smith@example.com
005JackBrown7890 Elm St.jack.brown@example.com

Answer:

In PostgreSQL, you would write the following query to accomplish this task:


This query uses the keyword to filter the rows where the column starts with 'John'. The '%' character is a wildcard that matches any sequence of characters, so 'John%' will match any string that starts with 'John'. The filtered result will consist of all the columns specified within the statement for the matching records.

Expected Output:

firstNamelastNameaddressemail
JohnDoe1234 Broadway St.john.doe@example.com
JohnnyAppleseed5678 Main St.johnny.appleseed@example.com
JonathanSmith3456 Oak St.jonathan.smith@example.com

How To Prepare for the McKesson SQL Interview

The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. In addition to solving the earlier McKesson SQL interview questions, you should also solve the 200+ SQL exercises on DataLemur which come from companies like FAANG tech companies and tech startups.

DataLemur SQL Interview Questions

Each interview question has hints to guide you, step-by-step solutions and most importantly, there's an interactive SQL code editor so you can easily right in the browser your SQL query and have it checked.

To prep for the McKesson SQL interview you can also be useful to practice interview questions from other healthcare and pharmaceutical companies like:

In case your SQL coding skills are weak, forget about jumping right into solving questions – refresh your SQL knowledge with this DataLemur SQL Tutorial.

DataLemur SQL Course

This tutorial covers SQL topics like filtering data with WHERE and GROUP BY – both of these show up often in McKesson SQL assessments.

McKesson Data Science Interview Tips

What Do McKesson Data Science Interviews Cover?

In addition to SQL query questions, the other topics to prepare for the McKesson Data Science Interview are:

McKesson Data Scientist

How To Prepare for McKesson Data Science Interviews?

I think the best way to prep for McKesson Data Science interviews is to read the book I wrote: Ace the Data Science Interview.

It solves 201 interview questions sourced from Facebook, Google & startups. The book's also got a refresher covering Stats, ML, & Data Case Studies. And finally it's helped a TON of people, which is how it's gotten to be an Amazon best-seller with over 1000+ 5-star reviews.

Ace the Data Science Interview

While the book is more technical, it's also key to prepare for the McKesson behavioral interview. A good place to start is by reading the company's culture and values.

© 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