This article tackles common SQL Interview Questions asked by EY, offering detailed solutions and explanations to help aspiring data analysts prepare effectively. These SQL Interview Questions, shared by an experienced Data Analyst at EY, cover a range of SQL concepts crucial for success in the interview process.
There are a total of 10 SQL queries with their solution that were asked in the interviews of Data Analyst Post at EY Company. EY (Ernst & Young) is a global leader in professional services, known as one of the “Big Four” accounting organizations alongside Deloitte, KPMG, and PwC.
Note: To help you better understand the SQL solutions presented in this article, we’ve used db-fiddle. This free online tool allows you to execute SQL queries directly against a database and see the results instantly. For each question, you’ll find a link to a corresponding db-fiddle, where you can explore the data, modify the queries, and experiment to solidify your understanding.
SELECT EmployeeID, Name, Salary
FROM Employees
Order by salary desc limit 5
Db-fiddle Link: https://www.db-fiddle.com/f/ezoQvyQwtqYzeYxrg7DDPp/0
SELECT *
FROM Orders
WHERE delivery_date IS NULL;
Db-fiddle Link: https://www.db-fiddle.com/f/bQuPJaJM3A5vCbVuK5SFdy/0
SELECT category_name, SUM(price*quantity) as total_sale, round(avg(discount_percentage),2) as discount_offered
FROM Sales
GROUP BY category_name;
Db-fiddle Link: https://www.db-fiddle.com/f/e6AR8NgeQVSpUvnKiRggzh/0
SELECT
p.project_id,
p.project_name,
p.project_manager_id,
p.status,
e.name as project_manager
FROM Projects p left join Employees e on p.project_manager_id = e.employee_id
WHERE status = 'Completed'
Db-fiddle Link: https://www.db-fiddle.com/f/7d11oXtYacx2LFHQLLdi7x/0
SELECT *
FROM Invoices
WHERE due_date > invoice_date + 15;
Db-fiddle Link: https://www.db-fiddle.com/f/jNt6Z71D7ZGxMSQ2NgThiC/0
SELECT
s.supplier_id,
s.supplier_name,
sum(sr.quantity_supplied) as quantity_supplied
FROM Suppliers s INNER JOIN Supply_Records sr on s.supplier_id = sr.supplier_id
GROUP BY s.supplier_id
HAVING quantity_supplied > 10000;
Db-fiddle Link: https://www.db-fiddle.com/f/xANZi6gDXbGtB5zeV656Bn/0
SELECT transaction_id, customer_id, COUNT(*) AS duplicate_count
FROM Transactions
GROUP BY transaction_id, customer_id
HAVING COUNT(*) > 1;
Db-fiddle Link: https://www.db-fiddle.com/f/MxcEqPENcZbgA6ViJ69Q9/0
Select
p.product_id,
p.product_name,
p.category_id,
sum(oi.quantity*oi.price) as total_sale,
rank() over(partition by p.category_id order by sum(oi.quantity*oi.price) desc ) as sale_rank
FROM Products p inner join Order_Items oi
on p.product_id = oi.product_id
group by product_id, p.product_name, p.category_id;
Db-fiddle Link: https://www.db-fiddle.com/f/93vcg26uxGqEaijxWXkvbw/0
select distinct o.customer_id, c.customer_name
from Orders o inner join Customers c on o.customer_id = c.customer_id
where order_date not between
(select max(order_date) from Orders)
and
(select DATE_SUB(max(order_date), INTERVAL 6 MONTH) from Orders)
or order_date is null;
Db-fiddle Link: https://www.db-fiddle.com/f/2Ar7RoeN65VRf8C7SS24Vo/0
select
e.employee_id,
e.employee_name,
e.employee_name,
case
when d.Department_name = 'Marketing' then round(salary*1.1,2)
else salary
end as salary,
d.department_name
from Employees e join Departments d on e.department_id = d.department_id
order by d.department_name;
Db-fiddle Link: https://www.db-fiddle.com/f/niQryWFvYHkKg5C6gsqwuv/1
Thank you for reading! We hope this article has been helpful in your SQL Interview Questions preparation. If you found it valuable, please share it with your network.
Hi, I am Vishal Jaiswal, I have about a decade of experience of working in MNCs like Genpact, Savista, Ingenious. Currently i am working in EXL as a senior quality analyst. Using my writing skills i want to share the experience i have gained and help as many as i can.
Unlock the secret to lightning-fast SQL queries with covering indexes. Learn how these powerful indexes…
Why are multi-column indexes essential for SQL database performance? This guide answers that question by…
Unlock your potential in data analytics. Discover the essential SQL Interview Questions asked by Swiggy…
Sharpen your Python while loop skills with 20 carefully curated practice questions. This article provides…
These questions were asked in a recent interview Flipkart Business Analyst, these uncovered questions are…
The delete statement in SQL is used to remove existing records from a table, you…