# 10 EPAM Systems SQL Interview Questions (Updated 2024)

Updated on

March 1, 2024

At EPAM Systems, SQL is used quite across many of the Data & AI consulting services EPAM offers. That's why they almost always asks SQL query questions in interviews for Data Analytics, Data Science, and Data Engineering jobs.

So, to help you practice for the EPAM Systems SQL interview, this blog covers 10 EPAM Systems SQL interview questions – how many can you solve?

## 10 EPAM Systems SQL Interview Questions

### SQL Question 1: Compute Total Monthly Revenue per Product

Imagine you work at EPAM Systems and you are given a task where you have to analyze the company's monthly revenue for each product. The company has a sales database that logs every single sale transaction. Write a SQL query to calculate the total monthly revenue for each product.

##### Example Input:
sale_idsale_dateproduct_idunit_pricequantity
1006/01/202011005
2006/02/202025010
3006/15/2020110015
4007/01/2020110010
5007/20/202025020
##### Example Output:
monthproduct_idtotal_revenue
612000
62500
711000
721000

This query uses the window function to sum up all sales revenues per product (calculated as ) per month, by grouping on the month and the . is used to extract the month part of the .

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

### SQL Question 2: Database Design for Employee Time Tracking

As an analyst in EPAM Systems, you are tasked to design and optimize a database for tracking employee working hours. The database should hold information about the employees, their daily check-in and check-out times, and their assigned projects. In addition, a query should be available to compute the total hours logged by each employee per project per month.

An important consideration while designing this system is the capability to process hundreds of check-in and check-out events per day, filter events for specific periods, as well as accommodate addition/modification of employee records and project assignments.

For this task, consider following tables: , , and

##### Example Input:
employee_idfirst_namelast_nameposition
123JohnDoeSoftware Engineer
456JaneSmithQuality Assurance Engineer
789JamesBrownProject Manager
##### Example Input:
project_idproject_namestart_dateend_date
1000Project Alpha05/01/2022 00:00:0007/01/2022 00:00:00
2000Project Beta06/15/2022 00:00:0008/15/2022 00:00:00
3000Project Gamma08/01/2022 00:00:0010/01/2022 00:00:00
##### Example Input:
log_idemployee_idproject_idlog_datestart_timeend_time
500123100006/21/2022 00:00:0009:00:0017:00:00
600456200006/22/2022 00:00:0010:00:0019:00:00
700789300008/03/2022 00:00:0008:00:0016:00:00
800123200006/23/2022 00:00:0009:30:0018:30:00
900123100006/24/2022 00:00:0009:15:0018:00:00

This query joins the ,, and tables using employee_id and project_id, respectively. It then groups the results by , , and , computing the total hours worked by each employee for each project monthly. The extracted 'hour' from and calculates the difference in hours. The function in Postgres allows to extract the month from . The clause ensures the total hours are calculated separately for each employee and each project every month.

### SQL Question 3: Can you describe the meaning of a constraint in SQL in layman's terms?

Think of SQL constraints like the rules of a game. Just like a game needs rules to keep things fair and fun, a database needs constraints to keep things organized and accurate.

There are several types of SQL constraints like:

NOT NULL: This constraint is like a bouncer at a nightclub - it won't let anything NULL through the door. UNIQUE: This constraint is like a VIP list - only special, one-of-a-kind values get in. PRIMARY KEY: This constraint is like an elected official - it's made up of NOT NULL and UNIQUE values and helps identify each row in the table. FOREIGN KEY: This constraint is like a diplomatic ambassador - it helps establish relationships between tables. CHECK: This constraint is like a referee - it makes sure everything follows the rules. DEFAULT: This constraint is like a backup plan - it provides a default value if no other value is specified.

So, whether you're playing a game or organizing a database, constraints are an important part of the process!

### SQL Question 4: Filter Customers Based on Purchase History and Location

EPAM Systems has a wide range of customers. For an upcoming marketing campaign, they are interested in identifying customers living in New York (NY) who have purchased products worth more than 1000 USD in total and whose last purchase was not a 'Laptop'. You are given two tables, and .

The table has the following fields:

• : An identification number for the customer
• : The first name of the customer
• : The last name of the customer
• : The city where the customer lives
• : The state where the customer lives

The table has the following fields:

• : An identification number for the purchase
• : The identification number of the customer who made the purchase
• : The product that was purchased
• : The price of the product at the time of purchase
• : The date when the purchase was made
##### Example Input:
customer_idfirst_namelast_namecitystate
1JohnDoeNew YorkNY
2JaneSmithLos AngelesCA
3SamBrownNew YorkNY
4AliceJohnsonNew YorkNY
##### Example Input:
purchase_idcustomer_idproductpricepurchase_date
500011Laptop120006/08/2022
698522Monitor20006/10/2022
500013Laptop120006/18/2022
698524Keyboard10007/26/2022
698521Mouse5007/05/2022

This query first joins the table with a subquery of the table. The subquery calculates the total amount spent by each customer and identifies the most recent product purchased by each customer. The function is used to rank purchases for each customer by in descending order (most recent purchase first). We filter out the customers who have a total spent more than 1000. The last conditions in the join ensure that only customers from 'NY' who did not purchase 'Laptop' as their last product are selected.

### SQL Question 5: Why would you use the SQL constraint?

The constraint is used to specify a condition that the data in a column must meet. If a row is inserted or updated and the data in the column doesn't meet the condition specified by the CHECK constraint, the operation will sadly fail.

For example, you might use a constraint to ensure that a column contains only positive numbers, or that a date is within a certain range.

For example, if you had a table of EPAM Systems employees, here's an example of how to use the CHECK constraint in a CREATE TABLE statement:

### SQL Question 6: Calculate the average bug resolution time

In EPAM Systems, a software consulting and product development company, bug resolution is of utmost importance. As a staff member of the software testing team, you are asked to write a SQL query to find the average time (in days) it takes to resolve bugs.

The database has a table called "bugs" which contains the following columns: bug_id (ID of the bug), creation_date (date when the bug was raised), resolution_date (date when the bug was resolved), project_id (id of the project the bug belongs to).

##### Example Input:
bug_idcreation_dateresolution_dateproject_id
1012022-01-012022-01-031
1022022-01-052022-01-091
1032022-02-012022-02-052
1042022-02-102022-02-152
1052022-03-012022-03-051

We need to find the average resolution time for each project.

##### Example Output:
project_idaverage_resolution_days
13
25

This query first calculates the difference in days between the resolution date and creation date for each bug, then it takes the average of these differences grouped by the project id. The EXTRACT function is used to get the number of days from the date interval. The result is the average bug resolution time for each project.

To practice a very similar question try this interactive Google Median Google Search Frequency Question which is similar for calculating average with date components or this Facebook Average Post Hiatus (Part 1) Question which is similar for calculating difference between dates.

### SQL Question 7: What is the difference between SQL operators ‘BETWEEN’ and ‘IN’?

While both the and operators are used to filter data based on some criteria, selects for values within a given range, whereas for it checks if the value is in a given list of values.

For example, say you had a table called , which had the salary of the employee, along with the country in which they reside.

To find all employees who made between $80k and$120k, you could use the operator:

To find all employees that reside in the US or Canada, you could use the operator:

### SQL Question 8: Click-Through-Rate for EPAM Systems

We have two tables - and . The table records every time a customer clicks on an advertisement. The table tracks every time a product has been added to the cart after viewing an advertisement.

Calculate the click-through conversion rate, which is the number of click events that resulted in a purchase, divided by the total number of click events, expressed as a percentage.

##### Example Input:
click_iduser_idclick_dateproduct_id
000112306/01/2022587
000226506/02/2022724
000318206/02/2022587
000426506/03/2022724
000517806/04/2022587
##### Example Input:
purchase_iduser_idpurchase_dateproduct_id
56018206/02/2022587
58926506/03/2022724
72126206/05/2022724

Here, we're calculating the click-through conversion rate by dividing the count of purchase events after an add click for the same product by the user by the total number of click events, and then expressing the result as a percentage.

To solve a similar problem about calculating rates, try this TikTok SQL question within DataLemur's online SQL coding environment:

### SQL Question 9: Highest Paid Project in each Month

EPAM Systems is a globally recognized provider of software engineering and IT consulting services. They work with clients from different sectors and handle multiple projects at any given time.

Assume you are given a database with information about all the ongoing projects worked on each month. The database tracks the project's ID, the client's name, the first date the project was worked on (start_date), the last date it was worked on (finish_date), and the total cost charged to clients ('price'). You need to write a SQL query to find the project with the highest fee for each month in the year 2022.

##### Example Input:
project_idclient_namestart_datefinish_dateprice
101Walmart01/05/2022 00:00:0001/22/2022 00:00:0070000
102Microsoft01/15/2022 00:00:0002/10/2022 00:00:00120000
104Walmart03/02/2022 00:00:0004/01/2022 00:00:00150000
105Microsoft03/20/2022 00:00:0004/15/2022 00:00:00160000
##### Example Output:
monthproject_idclient_nameprice
1102Microsoft120000
3105Microsoft160000

This PostgreSQL query uses the ROW_NUMBER() function to assign a unique row number to each row. The row number is reset for each month, based on the of the project (extracted using DATE_PART). Projects are ordered in descending order of inside each month. The outer query then filters for the first row in each month, i.e., the one with the highest price.

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

When using , only rows that are identical in both sets will be returned.

For a concrete example, say you were a Data Analyst supporting the Sales Analytics team at EPAM Systems, and data on potential sales leads lived in both Salesforce and Hubspot CRMs. To write a query to analyze leads created before 2023 started, that show up in BOTH CRMs, you would use the command:

### How To Prepare for the EPAM Systems SQL Interview

The best way to prepare for a EPAM Systems SQL interview is to practice, practice, practice. Beyond just solving the earlier EPAM Systems SQL interview questions, you should also solve the 200+ tricky sql questions on DataLemur which come from companies like Facebook, Google, and VC-backed startups.

Each interview question has hints to guide you, full answers and crucially, there is an interactive SQL code editor so you can instantly run your query and have it executed.

To prep for the EPAM Systems SQL interview you can also be useful to practice SQL problems from other tech companies like:

But if your SQL foundations are weak, forget about going right into solving questions – improve your SQL foundations with this free SQL for Data Analytics course.

This tutorial covers SQL topics like aggregate functions like SUM()/COUNT()/AVG() and LAG window function – both of which come up often during EPAM Systems interviews.

### EPAM Systems Data Science Interview Tips

#### What Do EPAM Systems Data Science Interviews Cover?

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

#### How To Prepare for EPAM Systems Data Science Interviews?

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

• 201 interview questions taken from FAANG & startups
• a refresher on SQL, Product-Sense & ML
• over 900+ reviews on Amazon & 4.5-star rating