Technological Institute of the Philippines
938 Aurora Blvd. Cubao, Quezon City
College of Information Technology Education
ITE 006 – Database Systems 1 (Oracle 1)
Preliminary Period
Single-Row Functions
Name: Surname, Firstname Mi. Date:
Program / Section: Instructor: Ms. Roxanne A. Pagaduan
Assessment Task: Quiz No. 3 (Hands-on)
The following questions support the attainment of CILOs:
1. Write SQL statements based on given problems and retrieve data in the database.
2. Compare the use of operators and functions.
Score Equivalent:
No error/Correct Query = 5points
1-3 errors = 3points
4-5 errors = 1point
More than 5 errors/Not running = No point
1. Create a new email, which will contain the first 3 letters of the first name and last name and
employee id. Sort the data in ascending order. Do not use Concat Operator ||. See sample output
below for additional character strings and formatting.
Sample Output:
SELECT CONCAT(
CONCAT(
CONCAT(
CONCAT(LOWER(SUBSTR(first_name,1,3)) , UPPER(SUBSTR(last_name,1,3))) ,
'_') , SUBSTR(employee_id,1,3)), '@yahoo.com') AS "New Email"
FROM employees
ORDER BY "New Email";
2. Starting with the string “Oracle Internet Academy”, pad the string to create
****Oracle****Internet****Academy****
SELECT REPLACE(RPAD(LPAD('Oracle Internet Academy', 27, '*'),31,'*'),' ', '****') AS
"OIA"
FROM DUAL;
3. How many months between your birthday this year and January 1 next year?
SELECT MONTHS_BETWEEN
(TO_DATE('01-01-2020','MM-DD-YYYY'),
TO_DATE('03-16-2019','MM-DD-YYYY') ) "Months"
FROM DUAL;
4. What’s the position of “I” in “Oracle Internet Academy”? Label as Position. Use the string “Oracle
Internet Academy” to produce the following output below. Label this column as The Net. Write your
SQL Statement
.
SELECT INSTR('Oracle Internet Academy' , 'I') "Position"
, CONCAT(' ' , SUBSTR('Oracle Internet Academy',13,3)) "The"
FROM DUAL;