(Exercise on retrieving records from the table) EMPLOYEES (Employee_Id, First_Name,
Last_Name, Email, Phone_Number, Hire_Date, Job_Id, Salary, Commission_Pct,
Manager_Id, Department_Id)
( a) Find out the employee id, names, salaries of all the employees
( b) List out the employees who works under manager 100
( c) Find the names of the employees who have a salary greater than or equal to 4800
( d) List out the employees whose last name is ‘AUSTIN’
( e) Find the names of the employees who works in departments 60,70 and 80
( f ) Display the unique Manager_Id
create table Employees (Emp_id NUMBER(6),First_name CHAR(25),Last_name
CHAR(20),Phone_No NUMBER(12),Hire_date DATE,Job_Id NUMBER(5),Emp_Salary
NUMBER(7),Comission_Pct NUMBER(5),manager_id NUMBER(5),Department_id
NUMBER(5));
Insert five records into the table employees:
SQL> insert into employees values(47401,'Rama','Rao',8965324170,'28-
Jan2003',301,60000,601,100,60);
1 row created.
SQL> insert into employees values(47402,'Ranga','Reddy',7020321450,'23-
Jun2004',302,56464,602,101,70);
1 row created.
SQL> insert into employees values(47403,'Raja','Shekhar',9848002255,'12-
aug2004',303,58451,603,103,80);
1 row created.
SQL> insert into employees values(47404,'Ravi',' AUSTIN ',9701811356,'30-
sep2006',304,36520,604,100,90);
1 row created.
SQL> insert into employees values(47405,'Ranga','Raju',9032553262,'17-
May2014',305,2568,605,105,60);
1 row created.
Display the table Employees :
select * from employees;
a) Find out the employee id, names, salaries of all the employees
Query:
sql>select Emp_id,First_Name,Last_Name,Emp_Salary from employees;
b) List out the employees who works under manager 100
Query:
sql>select * from employees where manager_id=100;
c) Find the names of the employees who have a salary greater than or equal to 4800
Query:
sql>select * from employees where EMP_SALARY>=4800;
d) List out the employees whose last name is ‘AUSTIN’
Query:
sql>select * from employees where Last_Name='AUSTIN ';
e) Find the names of the employees who works in departments 60,70 and 80
Query: sql>select * from employees where DEPARTMENT_ID IN(60,70,80);
f) Display the unique Manager_Id from employees table
Query:
sql>select DISTINCT(MANAGER_ID) from employees;