New 2
New 2
1
Question:
⦁ (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
Employees table:
Query:
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));
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Query:
sql>select * from employees;
1
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;
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;
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);
Query:
sql>select DISTINCT(MANAGER_ID) from employees;
Query:
create table Client_Master(Client_no varchar(6),Client_Name char(25),Client_Address
varchar(25),Client_City varchar(20),Client_State varchar(20),Balance_Due number(20));
Query:
sql>insert INTO CLIENT_MASTER Values('C123','Ramesh','L B Nagar', 'Hyderabad', 'Telangana',
7000);
sql>insert INTO CLIENT_MASTER Values('C124', 'Suresh', 'Dilsuknagar', 'Hyderabad',
'Telangana',6000);
sql>insert INTO CLIENT_MASTER Values('C125','Vignesh','Saroor nagar', 'Hyderabad',
'Telangana',3500);
sql>insert INTO CLIENT_MASTER Values('C126','Rajiv','A S Rao Nagar','Hyderabad',
'Telangana',4500);
sql>insert INTO CLIENT_MASTER Values('C127','Ranga', 'Vanasthalipuram','Hyderabad',
'Telangana',5478);
2
Query: sql>select * from Client_Master;
Create Teacher table with the following fields(Id,Name, DeptNo, Date of joining, DeptName,
Location, Salary)
Query :
SQL> create table teacher(Id number(2) primary key, name varchar2(20) not null, Deptno number(2)
not null, Deptname varchar2(20) not null, joinDate date not null, location varchar2(20) not null, salary
number(10,2) not null);
Sql> update teacher set salary= salary+(salary * 0.25) where Deptname= ‘mathematics';
3
Sql>commit;