NAMASTESQL - DAY 69
100 DAY CODING PROBLEMS
NAMASTESQL - DAY 69
Step - 1 : Problem Statement
🤔𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐭𝐚𝐭𝐞𝐦𝐞𝐧𝐭:
74 - ABOVE AVERAGE EMPLOYEES
You are working as a data analyst at a tech company called
"TechGuru Inc." that specializes in software development
and data science solutions. The HR department has tasked
you with analyzing the salaries of employees. Your goal is to
identify employees who earn above the average salary for
their respective job title but are not among the top 3
earners within their job title. Consider the sum of base_pay,
overtime_pay and other_pay as total salary.
In case multiple employees have same total salary then
ranked them based on higher base pay. Sort the output by
total salary in descending order.
Difficult Level : HARD
100 DAY CODING PROBLEMS
NAMASTESQL - DAY 69
Step - 2 : Identifying The Input Data And Expected
Output
INPUT
EMP_ID EMP_NAME JOB_TITLE
1 John Doe Software Engineer
2 Jane Smith Software Engineer
3 Michael Johnson Software Engineer
4 Emily Brown Software Engineer
5 David Lee Software Engineer
6 Sarah Jones Software Engineer
7 Kevin Davis Software Engineer
8 Emma Wilson Software Engineer
9 Matthew Taylor Software Engineer
10 Olivia Martinez Software Engineer
11 Liam Miller Data Scientist
12 Sophia Wilson Data Scientist
13 Benjamin Davis Data Scientist
14 Mia Taylor Data Scientist
15 William Anderson Data Scientist
16 Ella Martinez Data Scientist
17 James Garcia Data Scientist
18 Ava Lopez Data Scientist
19 Logan Perez Data Scientist
20 Harper Gonzalez Data Scientist
EMP_ID BASE_PAY OVERTIME_PAY OTHER_PAY
1 60000 2000 1000
100 DAY CODING PROBLEMS
NAMASTESQL - DAY 69
2 62000 1800 1200
3 58000 2500 1100
4 57000 2200 1300
5 63000 2300 1400
6 59000 2400 1500
7 61000 2100 1600
8 64000 2000 1700
9 57000 2200 1800
10 65000 2500 1900
11 70000 3000 1500
12 73300 2800 1600
13 68000 3200 1700
14 69000 2900 1800
15 71000 3100 1900
16 73500 2200 2000
17 67000 3300 2100
18 74000 2600 2200
19 68000 3000 2300
20 75000 2800 2400
OUTPUT
TITLE_AV
EMP_NAME JOB_TITLE TOTAL_PAY BASE_PAY G_PAY
Sophia Wilson Data Scientist 77700 73300 75720
William Anderson Data Scientist 76000 71000 75720
Jane Smith Software Engineer 65000 62000 64250
Kevin Davis Software Engineer 64700 61000 64250
100 DAY CODING PROBLEMS
NAMASTESQL - DAY 69
Step - 3 : Writing the sql query to solve the
problem
100 DAY CODING PROBLEMS
NAMASTESQL - DAY 69
100 DAY CODING PROBLEMS