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.)
IT DOESN’T EXECUTE BECAUSE THE TO_CHAR FUNCTION DOES NOT HAVE A SECOND ARGUMENT.
the following query is getting executed successfully. Kindly clarify on why the ans is b.
SELECT ename||’ joined on ‘|| hiredate||’, the total compensation paid is ‘||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
“COMPENSATION UNTIL DATE”
FROM employees;
the following query is getting executed successfully. Kindly clarify on why the ans is b.
SELECT ename||’ joined on ‘|| hiredate||’, the total compensation paid is ‘||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
“COMPENSATION UNTIL DATE”
FROM employees;
Leaving aside the missing “||”, there are still problems. “COMM” column might be NULL, so any operations with this column will result as NULL. The ROUND has no decimal places. So, I don’t think it will give the correct output.
Cheers!
If you divide days (SYSDATE – hiredate) by 365 you get years. One should receive salary monthly. So this is wrong again.