Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Republic of the Philippines

Department of Education
REGION I
SCHOOLS DIVISION OF CANDON CITY
CANDON NATIONAL HIGH SCHOOL

NAME: Rhino G. Adame


GRADE & SECTION:
Grade 11 ICT- Masipag SCORE:

ORACLE DATABASE
PERFORMANCE TASK 4
You work as a database programmer at Oracle Corporation. The HR department needs your assistance in creating
some queries. Using the EMPLOYEES table, create the SQL statements to retrieve the data needed by the HR
department. Each query will be graded using the rubric below.
Points Description
5 Query is correct and complete. Query produces the correct results.
4 Query is mostly correct but has few missing components. Query executes without any syntax errors but
output is incomplete.
3 Query is somewhat correct but incomplete. Query may not execute due to a syntax error but it can be
easily corrected.
2 Query is incorrect. Query does not execute due to many syntax errors.
1 Query is incomplete. Query only contains the SELECT and FROM clauses.
0 No answer.

1. Create a report that displays the following:


<employee first name > <employee last name> was hired on <hire date>.
Display the hire date in the format similar to this date: JANUARY 1, 2005. Name the column “HIREDATE”.
SELECT FIRST_NAME||' '|| LAST_NAME || ' was hired on ' || TO_CHAR(HIRE_DATE, 'MONTH MM, YYYY') || '.'
"HIRE_DATE"
FROM HR.employees;

Sample Report:
HIREDATE

Steven King was hired on June 17, 2003.

2. Create a report that produces the following for each employee:


<employee first name > <employee last name> wanted to earn <5 times salary.>.
Label the column Dream Salaries. Use the concatenation operator to join string literals and column expressions.
Use the TO_CHAR function to convert the salary.
SELECT FIRST_NAME||' '|| LAST_NAME || ' wanted to earn ' || TO_CHAR(SALARY * 5, 'fm$999,999.00') || '.'
"Dream Salaries"
FROM HR.employees;

Sample Report:
Dream Salaries

Steven King wanted to earn 120,000.00.

3. Display the last name, first name, hire date, and day of the week on which the employee started. Label the column
DAY.
SELECT LAST_NAME, FIRST_NAME, HIRE_DATE, TO_CHAR(hire_date, 'DAY') as "DAY"
FROM HR.employees;
Sample Report:
LAST_NA FIRST_NAM HIRE_DAT
ME E E DAY

Steven 17-JUN-03 TUESDAY


King
WEDNESD
Kochhar Neena 21-SEP-05
AY

4. Create a query that displays the first name, last name and commission amount of all employees whose first name
starts with ‘L’. If an employee does not earn commission, show “No Commission.” Label the column COMM.

SELECT FIRST_NAME, LAST_NAME,


NVL(TO_CHAR(COMMISSION_PCT), 'No Commission') COMM
FROM HR.employees
WHERE FIRST_NAME LIKE'L%';

Sample Report:
FIRST_NAM LAST_NA
E ME COMM

Laura Bissot No Commission


Louise Doran .3

5. Using CASE syntax, write a query that displays the grade of all employees based on the value of the JOB_ID
column, using the following data:
Job Grade
AD_PRES A
ST_MAN B
IT_PROG C
None of the above 0
SELECT JOB_ID, decode (JOB_ID,
'AD_PRES', 'A',
'ST_MAN', 'B',
'IT_PROG', 'C',
'0')GRADE
FROM HR.employees;

Sample Report:
GRAD
JOB_ID E

AC_ACCOU
0
NT
AD_ASST 0
AD_PRES A

6. Rewrite the statement in the preceding exercise by using the CASE syntax.
SELECT JOB_ID, CASE JOB_ID
WHEN 'AD_PRES' THEN 'A'
WHEN 'ST_MAN' THEN 'B'
WHEN 'IT_PROG' THEN 'C'
ELSE '0' END GRADE
FROM HR.employees;
Sample Report:
GRAD
JOB_ID E
AC_ACCOU
0
NT
AC_MGR 0
AD_ASST 0
AD_PRES A

You might also like