Query to obtain cumulative sum or running total from employee table for salary column.
select Employee_id, Salary,
SUM(Salary) OVER (ORDER BY Employee_id)
As RunningTotal
from employee;
Blogger, Engineer & Entrepreneur
Query to obtain cumulative sum or running total from employee table for salary column.
select Employee_id, Salary,
SUM(Salary) OVER (ORDER BY Employee_id)
As RunningTotal
from employee;
Query to obtain 1st generation and 3rd generation combination based on 2nd and 3rd generation.
Family table
Father | Son
J | K
K | L
M | N
N | O
SELECT m1.Father AS GrandFather, m2.Son AS GrandSon FROM Family m1 join family m2 ON m1.son = m2.father;
Result
Grandfather | Grandson
J | L
K | N
M | O
Query to get department, total salary with respect to a department from employee table.
select DEPARTMENT, sum(SALARY) Total_Salary from employee group by department
Query to get department, total salary with respect to a department from employee table order by total salary descending.
select DEPARTMENT, sum(SALARY) Total_Salary from employee group by department order by Total_Salary desc
Query to get department, number of employees in a department, total salary with respect to a department from employee table order by total salary descending.
select DEPARTMENT, count(FIRST_NAME), sum(SALARY) Total_Salary from employee group by department order by Total_Salary desc
Query to get department wise average salary from employee table order by salary ascending.
select DEPARTMENT, avg(SALARY) AvgSalary from employee group by department order by AvgSalary asc
Query to get department wise maximum salary from employee table order by salary ascending.
select DEPARTMENT, max(SALARY) MaxSalary from employee group by department order by MaxSalary asc
Query to get department wise minimum salary from employee table order by salary ascending.
select DEPARTMENT, min(SALARY) MinSalary from employee group by department order by MinSalary asc
Query to select number of employees joined with respect to year and month from employee table.
select year(JOINING_DATE) Join_Year, month(JOINING_DATE) Join_Month, count(*) Total_Emp from employee group by year(JOINING_DATE), month(JOINING_DATE)
Query to select department, total salary with respect to a department from employee table where total salary greater than 800000 order by Total_Salary descending.
select department, sum(SALARY) Total_Salary from employee group by department having sum(SALARY) > 800000 order by Total_Salary desc
Query to get names of employees from employee table who has ‘%’ in Last_Name.
select FIRST_NAME from employee where Last_Name like '%\%%'
Query to get last name from employee table after replacing special character with white space.
select REPLACE(LAST_NAME,'%',' ') from employee
Wishing everyone a Happy Deepavali.
Let the light of knowledge remove the darkness of ignorance.
Let the warmth of lamp bring more energy to your homes.
Let the beauty of the oil lamp fill the eyes of the beholder.
Let everlasting joy and happiness become a part of your life from this Deepavali.
Let the supreme light which governs everything enlighten the light of every individual soul.
Stats for October 2020
Unique visitors for MOHANMA.COM in October 2020 is 1156.
Number of visits between October 1 to October 31 is 2380.
October 15 & 16th 2020 clocked the highest number of visits in a day for October 2020 – 114.
Average visits received per day for October 2020 is 76.
Thank you all for visiting the website.