Lab 1.1
Lab 1.1
select staff_name,staff_sal,dept_code
from staff_masters
where dept_code in (20,40,30)
2. List the details of the employees with user defined Column headers.
3. Display the code, subjects and total marks for every student. Total Marks will
be calculated as Subject1+Subject2+Subject3. (Refer Student_Marks table)
4. List the details of the staff whose designations are either PROFESSOR or
LECTURER.
select s.staff_name,s.design_code,d.design_name
from staff_masters s join designation_masters d
on s.design_code=d.design_code
and d.design_name in ('Professor','Lecturer');
5. List the code, name, and department number of the employees who have experience
of more than 18 years.
select staff_code,staff_name,dept_code
where trunc((sysdate-hiredate)/365)>18
6. List the name and Designations of the staff who have joined before Jan 2003.
select staff_name,design_code
from staff_masters
where hiredate<'01-Jan-2003';
7. List the name, designation, and income for 10 years of the employees who are
working in departments 10 and 30.
8. List the name and experience (in years) of employees who are working as
LECTURER.
10. List the Name and Salary of the staff who are earning between 12000 and 25000.
Sort them based on their salaries and name.
select staff_name,staff_sal
from staff_masters
where staff_sal between 12000 and 25000;
12. Write a query which will display name, department code and date of birth of all
students who were born between January 1, 1981 and March 31, 1983. Sort it based on
date of birth (ascending).
select student_name,dept_code,student_dob
from student_masters
where student_dob between '01-Jan-81' and '31-Mar-83';
13. Get the Department number, and sum of Salary of all non managers where the sum
is greater than 20000.
select dept_code,sum(staff_sal)
from staff_masters
where staff_code not in (select mgr_code from
from staff_masters
where mgr_code not null)
group by dept_code
having sum(staff_sal)>20000
14. Display the details of books that have not been returned and expected return
date was last Monday.
15. Display the name and department code of students. If student does not belong to
any department, display “No Department”. Label the column as “Department”. (Hint:
Use NVL function)
16. Display the name and salary of the staff. Salary should be represented as X.
Each X represents a 1000 in salary.
Sample Output
JOHN 10000 XXXXXXXXXX
ALLEN 12000 XXXXXXXXXXXX