Sei sulla pagina 1di 5

CS111-Fundamentals of

Course Code Programming and Database


Theory and Apps
Database Management System
Description
1
College / Department:
LabExer No. 006
Online Education
Laboratory Exercise Page 1 of 1

Direction:
 Use the Employees table (copy and paste the code in SQL command line)
 Write the PL/SQL based on the requirement in each number.
 Note: Sample output is just a guide, it does not necessarily that the value to your output should be equal
to the sample output.

1. Write a query that display the employees lastname concatenated with firstname and put a ‘, (comma)’ in
between. Rename the column as Complete Name. Note all values in Complete Name column should be
in lowercase plus display the length of employees lastname for all employees whose lastname starts with
letter M sort the lastname in its default order.
Sample output:
Complete Name LENGTH(LASTNAME)
mourgos, anna 7

2. Write a query that display the Firstname concatenated to employees original salary plus concatenate
again a new column salary that multiplies the original salary into three. Rename the column as Dream
Salaries.Note sort the salary in descending order.
Sample output:
Dream Salaries
King earns 24000 monthly but wants 72000
3. Write a query that display the lastname and salary of all employees whose department_id = 60 or job_id
like ‘_T%’. Format the salary to be 15 character long, left padded with ‘$’ as special character. Label the
column Salary.
Sample output:
Lastname salary
King $$$$$$$$$240000

4. Write a query that display the employees lastname concatenated to salary. Format the salary column to 6
character long left padded with ‘*’ as special character for all employees whose manager_id is null or
salary between 4000 and 6000 Rename the column as employees and their Salaries.
Sample output:
Employees and their Salaries
King******

5. Write a query that display the firstname in capitalized format rename the column as pangalan whose
job_id is equal to ‘SA_REP’.

6. Write a query that display the firstname and length of firstname rename the column length of firstname
as Number of Character of all employees whose salary is between 4400 and 8300.

7. Write a query that display the firstname concatenated to salary with additional column salary that
provides a computation of salary * 2. Rename the column as Increase of all employees whose lastname
ends with N.
Sample output:
Increase
Jennifer salary is 4400 if multiply by two then he/she got a new salary of 8800
8. Write a query that displays the salary leftpadded with 15 character long and ‘$’ as special character and
another column salary right padded with 10 character long with ‘@’ as special character used of all
employees in 201, 176 and 144.

9. Write a query using SUBSTR function that returns the job_id = ‘REP’.
Sample output:
Job_id
SA_REP

10. Write a query that display the lastname plus new column lastname that shows the character position of
‘A’ from the column lastname of all employees whose salary >=11000.

11. Write a query that display the rounded value of the following number using the DUAL table.
563.396,2
563.396,1
563.396,-2
563.396,-1

12. Compute for the remainder of 100 to 10 and 9 to 2 using the dual table.

13. Write a query that display the truncated value of the following number.
563.396,2
563.396,1
563.396,-2
563.396,-1

14. Write a query that will trim the letter ‘A’ from lastname of all employees whose department_id between
60 and 90

.
15. What is DUAL Table?
DUAL is a table owned by the user SYS and can be accessed by all users.

Potrebbero piacerti anche