Display the Name , Location , Department , of Employees whose salary > 1500.

For solving the above question we need to create two tables (EMPLOYEE , DEPARTMENT)


create table employee
(
empid number(5) primary key,
empname varchar2(50),
salary number(10,2),
Grade number(1),
deptno number(3) references department(deptno),
location varchar2(50),
desig varchar(20)
);

create table department
(
deptno number(3) primary key,
deptname varchar(50)
);

Then Insert few records in Employee and Department table.

EMPLOYEE

EMPID EMPNAME SALARY GRADE DEPTNO LOCATION DESIG
1 AMIT SEN 10000 1 1 BHOPAL MANAGER
2 RAMESH THAKUR 11000 1 2 BHOPAL CLERK
3 RAKESH 12000 1 1 INDORE CLERK
4 SUMIT SAKET 9000 2 3 BHOPAL CLERK
5 AMIT SEN 11000 2 2 BHOPAL MANAGER
6 AMIT SEN 12000 5 2 INDORE CLERK
7 AMIT SEN 15000 6 1 INDORE MANAGER

DEPARTMENT

DEPTNO DEPTNAME
1 SALES
2 PRODUCTION
3 PURCHASE
4 MARKETING
5 ACCOUNTS
6 HR
7 ADMIN

SQL :
select e.empname, e.salary,d.deptno, d.deptname from department d, employee e where d.deptno = e.deptno and e.salary >1500;


RESULT :

EMPNAME SALARY DEPTNO DEPTNAME
AMIT SEN 10000 1 SALES
RAMESH THAKUR 11000 1 SALES
RAKESH 12000 1 SALES
SUMIT SAKET 9000 2 PRODUCTION
AMIT SEN 11000 2 PRODUCTION
AMIT SEN 12000 5 ACCOUNTS
AMIT SEN 15000 6 HR

No comments:

Post a Comment