In this video we solve the following query :
Write a query to find if an employee is earning a salary greater than or less than the average department salary ?
(Without using JOIN's or WINDOW functions)
Given that JOIN and WINDOW function should not be used, so we will be using the concept of subquery to solve the query.
--Create table 'emp_salary'
/*
create table emp_salary(
id int,
name varchar(50),
salary int,
departmentid int
)
*/
--Insert records into 'emp_salary' table
/*
insert into emp_salary(Id,Name,Salary,DepartmentId)
values
(1,'Joe',85000,1),
(2,'Henry',80000,2),
(3,'Sam',60000,2),
(4,'Max',90000,1),
(5,'Janet',69000,1),
(6,'Randy',85000,1),
(7,'Will',70000,1),
(8,'Chris',65000,3),
(9,'cathy',75000,3),
(10,'louis',80000,3)
*/
@dataprojecthub
#data_project_hub
#dataanalytics
#dataprojecthub