Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
22 views

DBMS Lab Assignment - III

The document contains details of 26 SQL queries on employees and department tables. The queries apply conditions like IN, BETWEEN, LIKE, NULL, NOT NULL and use aggregation functions to retrieve and manipulate data from the tables.

Uploaded by

Saloni Vani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

DBMS Lab Assignment - III

The document contains details of 26 SQL queries on employees and department tables. The queries apply conditions like IN, BETWEEN, LIKE, NULL, NOT NULL and use aggregation functions to retrieve and manipulate data from the tables.

Uploaded by

Saloni Vani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Medicaps University

Department of Computer Science & Engineering Database


Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

Lab Assignment - III


Objective: Apply the following compound condition and use
relational operators (IN, BETWEEN, LIKE, NULL, NOT NULL, etc)
in SQL
statements on”Employees” and “Department” tables.

1. Display the last name and salary for any employee whose salary is not in the range of
5,000 to 10,000?

2. Display the last name and department number of all employees in departments 60 or 100
in ascending alphabetical order by last name.

3. To display the last name and salary of employees who earn between 5,000 and
12,000 and are in department 60 or 90. Label the columns Employee and
Monthly_Salary.
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

4. Create a report to display the last name, salary, and commission of all employees
who earn commissions. Sort data in descending order of salary.

5. Display the last name, job id, and salary for all employees whose job is IT-programmer
or finance manager and whose salary is not equal to 2,500, 3,500, or 7,000.

6. Display the last name, salary, and commission for all employees whose commission
amount is 20%.
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

7. Display the employee number, last name, salary, and salary increased by 15.5%
(expressed as a whole number) for each employee. Label the column New Salary

8. Modify above query to add a column that subtracts the old salary from the new
salary. Label the column Increase.
QUERY- select Ename, sal, EmpNo, round(sal+sal*.155-sal) AS increase from EMP;

9. Create a query that produces the following for each employee: employee last name and
salary is 3 times. Label the column Dream .
QUERY- select Ename, (sal*3) AS DreamSalary from EMP;.
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

10. Display the last name and manager id of those employees whose manager id is not 103. .
QUERY- select Ename, mgr from EMP where mgr!=2540;

11. Create a query to display the contents of those employees whose manager id is in the
range of 100 and 103.
QUERY- select * from EMP where mgr BETWEEN 7690 and 7700;

12. Create a query to display the contents of those employees whose commission pct is null.
QUERY- select * from EMP where comm is null;
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

13. Create a query to display the contents of those employees whose manager id is not null
from the department table.
Query - select * from EMP where mgr is not null ;

14. Create a query to see a listing of all rows for which manager _id is not 200.
QUERY- select * from EMP where mgr !=7698 ;

Aggregate functions -
15. Display sum of salary of employees working in the department 60.
QUERY- select sum(sal) from EMP where DeptNo=30 ;

16. How many different job id are stored in the relation


employees. QUERY- select COUNT(distinct(EmpNo)) from EMP;
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

17. How many tuples are stored in the relation employees? Also find the no. of records in
manager_id attribute.
QUERY- select COUNT(*), COUNT(mgr) from EMP;

String matching queries


18. Display the content of the employee from employees table whose first name end with
letter n.
QUERY- select * from EMP where Ename LIKE '%N';

19. Display the content of the employee from employees table whose first name start with
letter A.
QUERY- select * from EMP where ename LIKE 'A%';

20. Display the content of the employee from employees table whose first name start with A
end with letter r.
QUERY- select * from EMP where Ename LIKE 'A%N';
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

21. Display the content of the employee from the employees table whose first name starts
with letter A and it is 5 characters long.
QUERY- select * from EMP where Ename LIKE 'A ';

22. Display the content of the employee from employees table whose first name has substring
‘ar’.
QUERY- select * from EMP where Ename LIKE '%AR%';

23. Display the content of the employee from employees table whose first name end with
letter ‘ara’.
QUERY- select * from EMP where Ename LIKE '%ARD';

24. Display the content of the department from departments table whose department name
has substring ‘tr’ and manager id is either 200 or 1700.
QUERY- select * from EMP where Ename like 'AR%' AND mgr = 7600 OR mgr =
7839;
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

25. Display the content like employee_id,length of the


last_name,manager_id,department_id,and first letter of the first name should be
capital,hire_date from employees.
QUERY- select EmpNo, length(ename), mgr, DeptNo, HireDate from EMP;

26. Display the last name , first name, manager id and email of those employees whose email
contains exactly one character that appears between E and S.
QUERY- select Ename, mgr, DeptNo, HireDate from EMP where job LIKE'%L_S%'
Medicaps University
Department of Computer Science & Engineering Database
Management System (CS3CO39)

Enrollment No. - EN22CS301777 Date of Conduction - 07/02/24


Student Name - Ragini Chandak Date of Submission - 21/02/24

You might also like