10 Ernst & Young SQL Interview Questions (Updated 2024)

Updated on

August 11, 2024

Data Analysts and Data Engineers at Ernst & Young write SQL queries to analyze financial data, such as revenue growth and expense ratios, for auditing purposes. It is also used to manage databases that track client information, including contact details and engagement history, to ensure accurate and up-to-date records in the consulting division, which is why Ernst & Young includes SQL questions during job interviews.

Thus, to help you practice, we've collected 10 Ernst & Young SQL interview questions – how many can you solve?

Ernst & Young SQL Interview Questions

10 Ernst & Young SQL Interview Questions

SQL Question 1: Identify Ernst & Young's Top Billing Clients

Ernst & Young (EY) is a multinational professional services network. It primarily provides assurance (including financial audit), tax, consulting, and advisory services to its clients. For EY, a VIP user or "whale" would be a client that has substantial expenditures with EY in terms of billing amounts. You are given a database that contains two tables: a "clients" table and a "billings" table.

Please write a SQL query to identify EY's top 10 clients in terms of total billed amount in the past year.

Example Input:
client_idclient_nameindustry
100ABC CorpTechnology
101DEF IncHealthcare
102GHI LLCFinance
Example Input:
bill_idclient_idbilling_dateamount
2001002022-06-2250000.00
2011012022-07-1375000.00
2021022022-05-0836000.00
2031002022-11-1525000.00
2041022022-09-0540000.00

Answer:


In this query, we perform an inner join between the and tables on the column, which is common to both tables. We only take into account the billings done in the past one year. The function is used to compute the total billed amount per client in this time frame. The results are then ordered in descending order of the amount and limited to the top 10, i.e., the clients with the highest total billed amount.

To solve a super-customer analysis question on DataLemur's free interactive coding environment, try this Microsoft SQL Interview problem:

Microsoft SQL Interview Question: Super Cloud Customer

SQL Question 2: 2nd Largest Salary

Given a table of Ernst & Young employee salaries, write a SQL query to find the 2nd highest salary at the company.

Ernst & Young Example Input:

employee_idsalary
12500
2800
31000
41200

Example Output:

second_highest_salary
1200

Check your SQL query for this question and run your code right in the browser:

2nd Highest Salary SQL Interview Question

Answer:


You can find a detailed solution with hints here: 2nd Highest Salary.

SQL Question 3: What is denormalization, and in what situations might it be a useful?

Denormalization is the practice of altering a database schema in a way that breaks the normalization rules (1st, 2nd, 3rd normal forms).

Here's 3 reasons to de-normalize a database at Ernst & Young:

  1. Improved performance: Denormalization can often improve performance by reducing the number of expensive join operations required to retrieve data. This is particularly useful when the database is being used for online analytical processing (OLAP) as frequent joins across multiple tables can be slow and costly.

  2. Scalability: Denormalization can increase the scalability of a database by requiring less data to be read and processed when executing a query. This can be beneficial when the database is expected to handle a high volume of queries.

  3. Simplification: One way to simplify the design of a database is by using denormalization to reduce the number of tables and relationships that need to be managed. This can make the database easier to understand and maintain.

Ernst & Young SQL Interview Questions

SQL Question 4: Calculate the Average Revenue from Each Sector Over Time

Ernst & Young heavily utilizes financial data, specifically analyzing revenue over time in specific sectors. For this hypothetical problem, we have the and tables. contains revenue data over time and describes which company belongs to which sector.

The task is to write a SQL query that calculates the average monthly revenue from each sector in 2020.

Example Input:
transaction_idcompany_idtransaction_daterevenue
101012020-01-155000
102022020-01-208500
103012020-02-104500
104032020-02-209900
105022020-02-257500
Example Input:
company_idsector
01Technology
02Healthcare
03Technology
Example Output:
monthsectoravg_revenue
1Technology5000
1Healthcare8500
2Technology7450
2Healthcare7500

Answer:

The following SQL code block provides the solution to the problem.


This query uses a window function to initially calculate the average revenue per month for each company. This temporary result is then used to calculate the average monthly revenue for each sector, grouping by both the month and the sector. The function helps to work with date and time values by extracting the needed part. In this case, it extracts the month and the year from the .

p.s. Window functions show up super frequently during SQL interviews, so practice the 27+ window function questions on DataLemur

DataLemur SQL Questions

SQL Question 5: What distinguishes an inner join from a full outer join?

An inner join returns only the rows that match the join condition between the two tables, whereas a full outer join returns all rows from both tables, including any unmatched rows.

Example:


Example:


SQL Question 6: Analyzing Consulting Project Performance

Ernst & Young (EY) is a multinational professional services firm and is one of the "Big Four" accounting firms. EY is involved with a number of consulting projects with different clients and the stakeholder wants to understand the consulting project performance. You are provided with the following two tables:

- Each row records information of a project involving a specific client.

project_idclient_idproject_nameproject_start_dateproject_end_date
1101"Project A"2019-01-012019-06-01
2102"Project B"2019-05-012019-11-01
3103"Project C"2019-10-012020-03-01

- Each row records information of billing to the clients for each project.

billing_idproject_idbilling_datebilling_amount
112019-02-015000
212019-05-015000
322019-06-014000
422019-08-014000
532019-12-016000

The stakeholder would like to know:

  1. The total billing amount for each project.
  2. The average monthly billing amount for each project.

Write a SQL PostgreSQL query to help answer the stakeholder's questions.

Answer:


From the above query, the total billing amounts and the average monthly billing amounts for each project are calculated and presented. The average monthly billing amount is derived by dividing the total project billing amount by the project's length in months. This calculation takes into account the possible change in years by utilizing the function. The result will provide the stakeholder with key financial measures related to each project.

SQL Question 7: How does a cross join differ from a natural join?

Cross joins and natural joins are two types of JOIN operations in SQL that are used to combine data from multiple tables. A cross join creates a new table by combining each row from the first table with every row from the second table, and is also known as a cartesian join. On the other hand, a natural join combines rows from two or more tables based on their common columns, forming a new table. One key difference between these types of JOINs is that cross joins do not require common columns between the tables being joined, while natural joins do.

Here's an example of a cross join:


If you have 20 products and 10 colors, that's 200 rows right there!

Here's a natural join example using two tables, Ernst & Young employees and Ernst & Young managers:


This natural join returns all rows from Ernst & Young employees where there is no matching row in managers based on the column.

SQL Question 8: Filter Customer Records Based on Multiple Conditions

Ernst & Young keeps records of all its customers and their interactions with various services. You are tasked to filter out the customers based on the following conditions:

  1. The customers who have actively used 'Audit' service.
  2. The customer age is over 30.
  3. The customer is not from USA.
Example Input:
customer_idnamecountryageservice_used
1201JustinUSA35Tax
1202EmmaAustralia31Audit
1203SophiaCanada45Audit
1204OliverUSA34Audit
1205AvaGermany36Advisory
Example Input:
customer_idservice_idactive
1201101false
1202102true
1203102true
1204102false
1205103true

You need to write a SQL query which can extract the needed information.

Answer:


This query first joins the customer records and service records based on the customer id. Then it applies the specified filters using WHERE clause conditions. The final result will display the customers who are not from USA, are over 30, and have actively used the Audit service.

SQL Question 9: Calculate the Click-Through Rate for Ernst & Young Webinars

Ernst & Young offers free webinars on various business topics. For marketing purposes, they display ad banners on various websites. The data team is interested in investigating how many people actually click on the ad and then register for a webinar. This analysis can help provide insights into the effectiveness of the ad banners. They specifically want to:

  • Calculate the click-through rate (CTR). CTR is the ratio of users who click on a specific link to the number of total users who view the ad (impression).
  • Find the webinar with the highest CTR.

To achieve this, they keep track of ad impressions, ad clicks and webinar registrations in three different tables: , and , which are defined as follows:

Example Input:
impression_idwebinar_iddateuser_id
5621101110/01/2022 00:00:00124
5622192010/01/2022 00:00:00278
5623101110/01/2022 00:00:00345
5624101110/01/2022 00:00:00234
5625192010/01/2022 00:00:00678
Example Input:
click_idwebinar_iddateuser_id
3952101110/01/2022 00:00:00124
3953192010/01/2022 00:00:00278
3954101110/01/2022 00:00:00345
Example Input:
registration_idwebinar_iddateuser_id
182101110/01/2022 00:00:00124
276192010/01/2022 00:00:00278
930101110/02/2022 00:00:00345
431101110/02/2022 00:00:00234
590192010/02/2022 00:00:00678

Answer:


This query uses a CTE () to calculate the number of impressions, clicks, and registrations by webinar. We ensure that a click comes after an impression and a registration comes after a click by the conditions in the WHERE clause. Then, it calculates the CTR for each webinar and returns the results sorted by the CTR in a descending order.

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

SQL interview question asked by Facebook

SQL Question 10: When would you use a clustered index vs. a non-clustered index?

Clustered and non-clustered indexes are both used to improve query performance, but they differ in how they are implemented.

A clustered index determines the physical order of the data rows in a table, while a non-clustered index does not. As a result, a table can have only one clustered index, but it can have multiple non-clustered indexes.

In terms of query efficiency & performance, a clustered index is generally faster for SELECT queries (reads) but updates (writes) to a clustered index are slower, as they require the data rows to be physically rearranged.

Preparing For The Ernst & Young 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. Beyond just solving the earlier Ernst & Young SQL interview questions, you should also solve the 200+ SQL Interview Questions on DataLemur which come from companies like Google, Microsoft and Silicon Valley startups.

DataLemur Question Bank

Each exercise has hints to guide you, 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 easily right in the browser your SQL query answer and have it checked.

To prep for the Ernst & Young SQL interview it is also wise to practice SQL questions from other accounting & consulting companies like:

Discover how Ernst & Young is harnessing the potential of Artificial Intelligence to drive business transformation!

However, if your SQL query skills are weak, don't worry about jumping right into solving questions – refresh your SQL knowledge with this free SQL tutorial.

SQL tutorial for Data Scientists & Analysts

This tutorial covers SQL concepts such as RANK vs. DENSE RANK and finding NULLs – both of which show up routinely in Ernst & Young interviews.

Ernst & Young Data Science Interview Tips

What Do Ernst & Young Data Science Interviews Cover?

In addition to SQL interview questions, the other types of problems to prepare for the Ernst & Young Data Science Interview are:

Ernst & Young Data Scientist

How To Prepare for Ernst & Young Data Science Interviews?

I believe the best way to study for Ernst & Young Data Science interviews is to read the book Ace the Data Science Interview.

It solves 201 data interview questions taken from FAANG tech companies. The book's also got a crash course covering SQL, AB Testing & ML. And finally it's vouched for by the data community, which is why it's earned 1000+ reviews on Amazon and a 4.5-star rating.

Ace the DS Interview

While the book is more technical in nature, it's also crucial to prepare for the Ernst & Young behavioral interview. A good place to start is by understanding 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