Day 8 - SQL Commands - YouTube
Day 8 - SQL Commands - YouTube
Find out the names of Employees whose salary is less than the overall average
select * from employee2 where salary < (Select avg(salary) from employee2);
___________________________________________________________________________________
_______________________________
This doesn't work as we are now creating groups on the combination of Department
and Employee.
Output:
"IT" "Ram" 90000
"HR" "Priya" 80000
"IT" "Shilpa" 92000
___________________________________________________________________________________
____________________
select max(salary) from employee2; --- this will give the maximum salary
Suppose we need those salaries which are less than this -
select salary from employee2 where salary < (select max(salary) from employee2);
the second maximum means - the maximum of this new list list -
select max(salary) from employee2 where salary < (select max(salary) from
employee2);
how to get top nth, this would not be an optimum solution, instead we can use this
-
select salary as second_highest_salary from employee2 order by salary desc offset 1
limit 1;
___________________________________________________________________________________
____________________
TRIGGERS