Assignment No 3
Assignment No 3
Version 21.3.0.0.0
Enter password:
Connected to:
Version 21.3.0.0.0
Table created.
10 Accounting Mumbai
20 Research Pune
30 Sales Nashik
40 Operations Nagpur
1 row created.
1 row created.
1 row created.
1 row created.
10 Accounting Mumbai
20 Research Pune
30 Sales Nashik
40 Operations Nagpur
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created
SQL> insert into employeee values (1008,'Ravi
sawant','Analyst',1007,'17/nov/95',10000,null,null,'Amaravati');
1 row created.
8 rows selected.
JOB
---------------
Clerk
Salesman
Manager
President
Analyst
1 row updated.
10 Accounting Mumbai
20 Research Pune
30 Sales Nashik
40 Operations Banglore
SQL> update employeee set ename = 'nikhil gosavi' where empno =1003;
1 row updated.
600 20 Nashik
1200 30 Nagpur
30 Pune
10 Mumbai
20 Satar
1500 30 Pune
20 Mumbai
Amaravati
8 rows selected.
1 row deleted.
600 20 Nashik
1200 30 Nagpur
10 Mumbai
20 Satara
20 Mumbai
Amaravati
7 rows selected.
10) Create a table department_temp table from deptarment table, only create the structure not
content.
Table created.
DEPTNO NUMBER(38)
DNAME VARCHAR2(15)
LOCATION VARCHAR2(15)
4 rows created.
10 Accounting Mumbai
20 Research Pune
30 Sales Nashik
40 Operations Banglore
12) Display the list of employee whose salary between 5000 and 20000.
SQL> select * from employeee where salary between 5000 and 20000;
1200 30 Nagpur
20 Satara
Amaravati
600 20 Nashik
30 Pune
10 Mumbai
20 Satara
20 Mumbai
Amaravati
6 rows selected.
14) Display all those employees whose job title is either ‘manager’ or ‘analyst’(write by using OR &
IN operator).
30 Pune
20 Satara
20 Mumbai
EMPNO ENAME JOB MGR JOINED_DA SALARY
Amaravati
15) Display the employee name & department number of all employees in dept 10,20,30 & 40.
EMPNO DEPTNO
---------- ----------
1001 20
1002 30
1003 30
1004 10
1005 20
1007 20
6 rows selected.
16) Display the employee number, name, job & commission of all employees who do not get any
commission.
SQL> select Empno, Ename,job commission from employeee where commission is null;
17) Display the name & salary of all employees whose salary not in the range of 5000 & 10000.
SQL> select Ename,Salary from employeee where Salary not between 5000 and 10000;
ENAME SALARY
-------------------- ----------
Nilesh joshi 2800
18) Find all names & joined date of employees whose names starts with ‘A’.
SQL> select ename ,Joined_dat from employeee where ename like 'A%';
ENAME JOINED_DA
-------------------- ---------
19) Find all names of employees having ‘i’ as a second letter in their names.
ENAME
--------------------
Nilesh joshi
nikhil gosavi
Nitin kurkarni
Niraj sharma
20) Find employee number, name of employees whose commission is not null.
EMPNO ENAME
---------- --------------------
21) Display all employee information in the descending order of employee number.
600 20 Nashik
1200 30 Nagpur
30 Pune
10 Mumbai
20 Satara
20 Mumbai
Amaravati
7 rows selected.
22) Display the minimum, maximum, sum & average salary of each job type
23) Write a query to display the number of employee with the same department.
DEPTNO
----------
24) Select employee number, ename according to the annual salary in ascending order.
COUNT(EMPNO) DEPTNO
------------ ----------
3 20
2 30
1 10
SQL> select empno, ename,12*salary "annual salary" from employeee order by'annualsalary';
7 rows selected.
25) Find the department number, maximum salary where the maximum salary is greater than 5000.
DEPTNO MAX(SALARY)
---------- -----------
20 25000
10 50000
10000
26) Find all distinct column values from employee & department table.
SQL> select deptno from employeee union select deptno from department1;
DEPTNO
----------
20
30
10
40
27) Find all column values with duplicate from employee & department table.
28 Find all column values which are common in both employee & department table.
SQL> select deptno from employeee union select deptno from department1;
DEPTNO
----------
20
30
30
10
20
20
28 Find all column values which are common in both employee & department table.
SQL> select deptno from employeee union all select deptno from department1;
DEPTNO
----------
20
30
30
10
20
20
10
20
30
40
11 rows selected.
29 Find all distinct column values present in employee but not in department table.
SQL> select deptno from employeee minus select deptno from department1;
DEPTNO
----------
30 Display the number of employees in the department 30 who can earn a commission.
SQL> select count (empno) from employeee where deptno = 30 and commission is not null;
COUNT(EMPNO)
------------