How Many Different Departments Are There in The Employee' Table. A)
How Many Different Departments Are There in The Employee' Table. A)
ASSESSMENT 2
RISHIKA GOYAL
18BIT0270
EXERCISE 4:
A)
COUNT(DISTINCTD_NO)
-------------------
1 55000 55000
2 70000 70000
5 25000 40000
4 25000 43000
3 80000 80000
A)
12*(SUM(SALARY)/COUNT(SALARY))
------------------------------
517200
A)
SQL> SELECT COUNT(EMPSSNNO) FROM EMPLOYEE WHERE (EXTRACT(YEAR
FROM SYSDATE)-EXTRAC
COUNT(EMPSSNNO)
-------------
A)
SQL> SELECT D_NO,AVG(SALARY) FROM EMPLOYEE GROUP BY D_NO;
D_NO AVG(SALARY)
---------- -----------
1 55000
2 70000
5 33250
4 31000
3 80000
ON EMPLOYEE.D_NO=DEPARTMENTS.D_NO GROUP BY
D_NAME HAVING(COUNT(EMPSSNNO)>30);
no rows selected
AVG(SALARY)
-----------
43100
COUNT(EMPSSNNO)
---------------
COUNT(EMPSSNNO)
---------------
4
EXERCISE 5
1. Find the employee who is getting highest salary in the dept research
MAX(SALARY)
-----------
40000
2. Find the employees who earn the same salary as the minimum salary for each Dept
3. Find the employee whose salary is greater than average salary of dept 2.
SQL> select firstname,midname,lastname from employee where salary > (select avg(
salary) from employee where deptnumber=2);
FIRSTNAME MI LASTNAME
--------------- -- ---------------
Doug E Gilbert
4. List out all the dept names with their individual employees strength
DEPTNAME COUNT(*)
--------------- ----------
Research 4
Headquarter 1
Manufacture 1
Finance 3
Administration 1
DEPTNAME COUNT(*)
--------------- ----------
Research 4
6. List out all the depts and average salary drawn by their employees
DEPTNAME AVG(E.SALARY)
------------ -- -------------
Research 33250
Headquarter 80000
Manufacture 55000
Finance 31000
Administration 70000
SQL> select max(salary) from employee where salary in (select avg(salary) from e
mployee group by deptnumber);
MAX(SALARY)
-----------
80000
View created.
no rows selected
9. Create a logical table to store employee details who is getting salary more than 10000.
View created.
11 rows selected.
10. Create a table to store the employees details based on the dept no
View created.
11 rows selected.