# 11 Workday SQL Interview Questions (Updated 2024)

Updated on

January 25, 2024

Workday almost always evaluates jobseekers on SQL query questions in interviews for Data Science and Data Engineering positions. They do this because at Workday, SQL is used to analyze product usage data generated from the company's suite of HR, Finance, and Payroll products. SQL also powers the Workforce Analytics platform they have.

So, to help you prepare for the Workday SQL Interview, we've curated 11 Workday SQL interview questions to practice, which are similar to recently asked questions at Workday!

## 11 Workday SQL Interview Questions

### SQL Question 1: Calculating the Average Salary per Department Using Window Function

Suppose you are a data analyst in Workday's Solutions Engineering & Implementation team, and have been tasked by a customer to analyze employee salaries. Your client wants to compare the average salaries of each department to have a better understanding of the payroll distribution. Write a SQL query to calculate the average salary per department.

#### Example Input:

employee_idfirst_namelast_namedepartmentsalary
1756JaneSmithEngineering80000
2853JohnDoeHR60000
6478MattJonesEngineering90000
5241MikeBrownMarketing70000
3852JuliaJohnsonEngineering85000

#### Example Output:

departmentavg_salary
Engineering85000
HR62500
Marketing70000

This SQL query achieves the desired result by using a window function ( OVER ). It calculates the average salary for each department. The clause is used to divide the data into partitions (groups) that share the same . Then, the window function is applied to each partition separately.

### SQL Question 2: Employee Attendance Statistics

Workday is a company that provides human capital management, financial management applications, and workforce management applications. Given that, let's consider a scenario where they want to analyze employee attendance statistics.

The HR department would like to have a report showing the total working days and the days with vacation for each employee for a given month. They have two tables and .

Here is their structure:

##### Example Input:
employee_idfirst_namelast_name
123JaneSmith
456JohnDoe
789EmilyJohnson
##### Example Input:
timesheet_idemployee_idwork_datehours_workedleave_status
11232022-06-018WORKED
21232022-06-028WORKED
31232022-06-030VACATION
44562022-06-018WORKED
54562022-06-020VACATION
67892022-06-018WORKED

Provide a PostgreSQL query that will output a table with columns , , , .

This query first combines the first_name and last_name fields to create a full name, employee_name. It then formats the work_date to 'Mon-YYYY' format to get the month and year. The counting of total working days and vacation days are done via a conditional sum or what is often referred to as a sum aggregation with a case statement. The result is then grouped by employee_name and month_year. The order by clause sorts the result first by employee_name and then by month_year to provide a clean visual.

To practice a related SQL problem on DataLemur's free interactive SQL code editor, try this SQL interview question asked by Facebook:

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

A cross-join, also known as a cartesian join, is like a mad scientist's laboratory experiment gone wild. It takes two tables and mixes them together to create a crazy new table with every possible combination of rows from the original tables.

Here's an example:

If you have 20 products and 10 colors, that's 200 rows right there! Cross-joins are great for generating all possible combinations, but they can also create really big tables if you're not careful. Just like a mad scientist, use your powers wisely!

### SQL Interview Question 4: Average Employee Leave Days

As an HR analytics company, Workday might be interested in tracking how many leave days employees use per year, on average, to monitor employee wellness and understand the company’s operations.

Given the and tables below, write a SQL query to find the average number of leave days taken per employee per year.

##### Example Input:
employee_idfirst_namelast_namestart_date
1JohnDoe2019-05-14
2JaneSmith2020-01-01
3SarahJohnson2020-07-01
4JamesBrown2021-01-01
##### Example Input:
leave_idemployee_idleave_start_dateleave_end_date
112020-05-182020-05-22
222021-08-012021-08-15
332021-12-202022-01-03
412021-05-172021-05-21
542022-01-152022-01-22

The table contains and , which define the start and end of an employee’s leave, respectively.

This query uses the command to merge the and tables based on matching .

The expression retrieves the year from .

The function then calculates the average number of leave days, where the number of leave days is determined as ( - + 1) to include the first day of the leave.

Finally, the keyword groups the result by and Year while the keyword sorts the result by and then by Year.

### SQL Question 5: Could you clarify the difference between a left and a right join?

A join in SQL combines rows from two or more tables based on a shared column or set of columns. To demonstrate the difference between a and , say you had a table of Workday orders and Workday customers.

LEFT JOIN: A retrieves all rows from the left table (in this case, the Orders table) and any matching rows from the right table (the Customers table). If there is no match in the right table, NULL values will be returned for the right table's columns.

RIGHT JOIN: A retrieves all rows from the right table (in this case, the Customers table) and any matching rows from the left table (the Orders table). If there is no match in the left table, NULL values will be returned for the left table's columns.

### SQL Question 6: Calculate the Click-through Conversion Rate for Workday's Digital Products

Workday, a company providing enterprise cloud applications for human resources and finance, tracks every click a user does in their ecosystem. Specifically, they're interested in understanding the clickthrough conversion rate from the point a user views a digital product, to the point they add it to their cart. To perform this analysis, Workday has captured key data in two tables: 'view_logs' and 'add_to_cart_logs'.

The 'view_logs' table records whenever a user views a product, and has three columns: (integer), (integer), and (integer).

Meanwhile, the 'add_to_cart_logs' table records whenever a user adds a product to their cart, and also has three columns: (integer), (integer), and (integer).

You need to write a PostgreSQL query that calculates the clickthrough conversion rate (i.e., the number of users who added a product to their cart after viewing it divided by the total number of users who viewed the product) for each product.

##### Example Input:
log_iduser_idproduct_id
1017672309
1022922309
1036024821
1044993417
1055553417
##### Example Input:
log_iduser_idproduct_id
5017672309
5022922309
5036024821
5045553417
5053823920

This SQL query makes use of a LEFT JOIN to combine 'view_logs' and 'add_to_cart_logs' based on the user_id and product_id. In the SELECT clause, we calculate the clickthrough conversion rate for each product by dividing the number of unique users who added the product to their cart by the total number of unique users who viewed the product. We make use of the GROUP BY clause to accomplish this calculation for each product separately. This will give Workday the clickthrough conversion rate for each of their products.

To solve a related SQL interview question on DataLemur's free online SQL code editor, solve this SQL interview question asked by Facebook:

### SQL Question 7: What does the SQL keyword do?

The keyword removes duplicates from a query.

Suppose you had a table of Workday customers, and wanted to figure out which cities the customers lived in, but didn't want duplicate results.

table:

namecity
AkashSF
BrittanyNYC
CarlosNYC
DiegoSeattle
EvaSF
FayeSeattle

You could write a query like this to filter out the repeated cities:

city
SF
NYC
Seattle

### SQL Question 8: Calculate the Total Payroll and Average Salary per Department

As a large Human Capital Management (HCM) company, Workday needs to keep track of all the employees, their salaries, and departments to manage the payroll better. As part of the analytics team, you've been tasked to write a SQL query to calculate the total payroll and average salary per department in the organization.

##### Example Input:
emp_iddepartment_idsalary
11001200
21001000
32001500
42001300
53001800
dept_iddept_name
100Marketing
200Sales
300Engineering
##### Example Output:
dept_nametotal_payrollavg_salary
Marketing22001100
Sales28001400
Engineering18001800

This query joins and tables based on the department id, and then calculates the total sum of salaries () and average per department (), as specified by .

To practice a similar problem about calculating rates, solve this SQL interview question from TikTok on DataLemur's interactive coding environment:

### SQL Question 9: Find Employees by Department

As part of your role as a database manager at Workday, you need to find all the employees that work in a specific department based on a partial name match. The HR team often needs this information to quickly identify the relevant employees as part of ongoing staff management. You have access to the 'employees' table, with the following structure.

##### Example Input:
emp_idfirst_namelast_namejoin_datedepartment
001JohnDoe01/10/2021Software Engineering
002JaneSmith03/12/2020Data Analysis
003DavidBrown05/15/2019Software Engineering
004SarahJohnson07/21/2021Data Analysis
005MichaelMiller09/16/2020Human Resources

Based on the provided 'employees' table, can you write a SQL query that will return all employees that work in a department containing the word 'Software'?

This SQL query uses the operator to match any records from the table where the field contains the word 'Software'. The '%' either side of 'Software' means that there can be any characters, or none, before and after 'Software'.

For our sample data, this SQL query will return the records of employees 'John Doe' and 'David Brown', as they work in the 'Software Engineering' department.

### SQL Question 10: What does the SQL command do?

is used to combine the output of multiple statements into one big result!

For a concrete example, say you were a Data Analyst supporting the Sales Analytics team at Workday, and data on potential sales leads lived in both Salesforce CRM and Hubspot. To write a query to analyze leads created after 2023 started, across both CRMs, you could use in the following way:

"

### SQL Question 11: Calculate Employee Bonus

In Workday, the HR would like to calculate a bonus for employees based on their performances. If an employee has completed over 120 hours in a month, they will receive a 5% bonus. If they completed over 140 hours, they receive a 10% bonus. For other hours, the bonus is calculated as hours * rate * 0.01. Use the SQL functions ABS(), ROUND(), SQRT(), MOD(), POWER() to calculate the total bonus for each employee.

##### Table:
employee_idmonthyearhours_worked
10112022125
10212022130
10312022145
10122022122
10222022140
10322022130
employee_idrate
10120
10225
10330
##### Expected Output:
employee_idmonthyearbonus
10112022125
10212022162.5
10312022435
10122022122
10222022350
10322022195

In the above query, we are using a JOIN to combine the hours and rates for each employee. Then based on the conditions provided, we are calculating the bonus using a CASE statement by referring to the hours_worked, rate and using the mentioned mathematical functions. We use ROUND to make sure the bonus is a round figure and POWER to calculate the 0.01 multiplication factor.

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

### Preparing For The Workday SQL Interview

The key to acing a Workday SQL interview is to practice, practice, and then practice some more! Beyond just solving the earlier Workday SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Google, Uber, and Microsoft.

Each SQL question has hints to guide you, detailed solutions and best of all, there's an interactive coding environment so you can right in the browser run your SQL query answer and have it graded.

To prep for the Workday SQL interview it is also a great idea to solve interview questions from other tech companies like:

But if your SQL query skills are weak, don't worry about going right into solving questions – improve your SQL foundations with this DataLemur SQL Tutorial.

This tutorial covers topics including filtering on multiple conditions using AND/OR/NOT and cleaning text data – both of these come up frequently in SQL interviews at Workday.

### Workday Data Science Interview Tips

#### What Do Workday Data Science Interviews Cover?

For the Workday Data Science Interview, in addition to SQL query questions, the other types of questions which are covered:

• Statistics and Probability Questions
• Python or R Programming Questions
• Data Case Study Questions
• Machine Learning Questions
• Resume-Based Behavioral Questions

#### How To Prepare for Workday Data Science Interviews?

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

• 201 interview questions sourced from FAANG (FB, Apple, Amazon, Netflix, Google)
• a crash course on SQL, AB Testing & ML
• over 900+ reviews on Amazon & 4.5-star rating

You can also look for insights on their engineering blog, like this article on how they use AWS Aurora Databases.