0% found this document useful (0 votes)
36 views2 pages

Lab#4 5

DATABASE

Uploaded by

mscsf23m002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Lab#4 5

DATABASE

Uploaded by

mscsf23m002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DB-Lab 05

Total Marks : 60
Teacher: Dr. Zobia Suhail Time Allowed:60 Mins

----------------------------------------------------------------------------------------------------------------------
Instructions:
● Work on this lab individually. Discussion is not allowed.
● Evaluation of tasks will be conducted in lab.
● Anyone caught being indulged in the act of plagiarism would be awarded an “F”
grade in this lab.
----------------------------------------------------------------------------------------------------------------------
USE THE FOLLOWING TABLE:
EMPLOYEE (EMPNO, ENAME, JOB, SAL, HIREDATE, COMM, MGR, DEPTNO)
Perform following tasks:

1. DISPLAY THE NAMES AND DEPARTMENT NO. OF ALL EMPLOYEES WHO


ARE IN DEPARTMENT NO 20 OR 50 IN ALPHABETICAL ORDER BY NAME

2. DISPLAY THE NAMES AND DEPARTMENT NO. OF ALL CLERK AND ADD 2500
RUPEES IN EACH SALARY THEN DISPLAY ONE FOURTH OF THEIR SALARY
LABEL THE COLUMN WITH QSALARY AND ORDER BY QSALARY

3. DISPLAY THE EMPLOYEE NAME, JOB, AND HIRE DATE OF EMPLOYEES HIRED
BETWEEN FEBRUARY 20,1981, AND JUNE 20, 1981. ORDER THE QUERY IN
ASCENDING ORDER BY HIREDATE.

4. DISPLAY THE NAME, SALARY, AND COMMISSION FOR ALL EMPLOYEES


WHO EARN COMMISSION. SORT DATA IN DESCENDING ORDER OF SALARY
AND COMMISSION.

5. DISPLAY THE NAMES, SALARY AND COMM OF ALL EMPLOYEES WHO EARN
COMMISSION LESS THAN SALARY.

6. WRITE A QUERY TO DISPLAY THE CURRENT DATE. LABEL THE COLUMN DATE.

7. WRITE A QUERY TO DISPLAY THE NO. OF MONTHS AN EMPLOYEE HAS


WORKED FROM HIS HIRING. ROUND OFF THE NO. OF MONTHS.

8. CREATE A QUERY THAT DISPLAYS THE EMPLOYEES’ NAMES, JOB AND


HIREDATE ALSO DISPLAY A COLUMN WITH THE NAME “NEW HIREDATE” IN
WHICH INCREASE 6 MONTHS IN THE HIRE DATE OF SALESMAN , 2 MONTHS IN THE
HIRE DATE OF CLERK, 1 MONTHS IN THE HIRE DATE OF PRESIDENT. ORDER THE
OUTPUT IN DESCENDING BY HIREDATE.
9. Write a SQL query to list the employees in the ascending order on job name and
descending order on employee id. Return complete information about the employees.
10. Write a SQL query to display sorted concatenated string of employee name and job .
11. Display the employee number, name, salary and salary increase by 15% expressed as
whole number. Label the column New Salary.
12. Modify the previous query to add a column that will subtract the old salary from the new
salary. Label the column increase.
13. Write a query to display the current date. Label the column with current date.
14. Display the employees name, hire date, and salary review date which is the first day
after six months of service. Label the column REVIEW.
15. For each employee display the employee name and calculate the number of
MONTHS_WORKED. Order your results by the number of months employed. Round the
number of months up to the closest whole number.
16. Create a query to display name, and salary for all employees. Format the salary to be 15
characters long. Left padded with $. Label the column SALARY.
Sample OUTPUT:
ENAME SALARY

SMITH $$$$$$$$$$$$800
ALLEN $$$$$$$$$$$1600
WARD $$$$$$$$$$$1250

17. Write a query that will display the employee's name with the first letter Capitalized and all
other letters lowercase and the length of their name, for all employees whose names starts
with J, A or M. Give each column an appropriate label.

What is the output of following :

18. SELECT name, salary FROM employee ORDER BY name,


salary DESC

19. SELECT name, salary FROM employee ORDER BY name DESC, salary
DESC
20. Select * from emp order by 1,2

You might also like