View the Exhibit and examine the data in the EMPLOYEES table.
You want to generate a report showing the total compensation paid to each employee to date.
You issue the following query:
What is the outcome?
A.
It generates an error because the alias is not valid.
B.
It executes successfully and gives the correct output.
C.
It executes successfully but does not give the correct output.
D.
It generates an error because the usage of the ROUND function in the expression is not valid.
E.
It generates an error because the concatenation operator can be used to combine only two items.
Explanation:
ROUND(column|expression, n) Rounds the column, expression, or value to n decimal places or, if n is omitted,
no decimal places (If n is negative, numbers to the left of decimal point are rounded.)
SQL> select ename || ‘joined on’ || hiredate || ‘.the total compensation paid is’ ||
2 to_char(round(round(sysdate – hiredate)/265) * sal + comm) “compen util date” from EMPLOYEES;
compen util date
——————————————————————————–
SMITHjoined on17-DEC-00.the total compensation paid is
ALLENjoined on20-FEB-99.the total compensation paid is41900
WARDjoined on22-FEB-95.the total compensation paid is39250
JONESjoined on02-APR-98.the total compensation paid is
MARTINjoined on28-SEP-99.the total compensation paid is32650
BLAKEjoined on01-MAY-97.the total compensation paid is
A: because ther is no comma between ename and ‘joind on’.
Expl :
SELECT LAST_NAME,
‘joined on’,
hire_date,
‘, the total comp paid is’,
salary ,
TO_CHAR(ROUND(ROUND(sysdate-hire_date)/365)*salary+ COMMISSION_PCT) “compensation until date”
FROM employees;
Examples Result
ROUND(748.58, -1) 750.00
ROUND(748.58, -2) 700.00
ROUND(748.58, -3) Results in an arithmetic overflow, because 748.58 defaults to decimal(5,2), which cannot return 1000.00.
To round up to 4 digits, change the data type of the input. For example:
SELECT ROUND(CAST (748.58 AS decimal (6,2)),-3); 1000.00
ROUND(column|expression, n) Rounds the column, expression, or value to n decimal places or, if n is omitted,
no decimal places (If n is negative, numbers to the left of decimal point are rounded.)
On the real exam, if it has ||, the answer is C.
If it is missing ||, the answer is
E.
It generates an error because the concatenation operator can be used to combine only two items.