2.+PracticeExercise+-++Solution
2.+PracticeExercise+-++Solution
-- --------------------------------------------------------------
# Dataset Used: employee_details.csv and Department_Details.csv
# Use subqueries to answer every question
-- --------------------------------------------------------------
1. Retrive employee_id , first_name , last_name and salary details of those employees
whose salary is greater than the average salary of all the employees.(11 Rows)
select EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY from employee_details
where SALARY > (select avg(salary) from employee_details);
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution
prohibited.
6. Write a Query to display the employee_id, first_name, last_name,department_id of
the employees who have been recruited after the middle(avg) hire_date. (10 Rows)
set @mi = (select count(*) from employee_details);
10. Display the employee_id, first_name, last_name, salary and job_id of the employees
who earn maximum salary for every job.( 7Rows)
select EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY, JOB_ID from
employee_details
where salary in (select max(salary) over(partition by JOB_ID) as max_salary from
employee_details);
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution
prohibited.