1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 49


Examine the description of the EMPLOYEES table:

For each employee in department 90 you want to display:

1. their last name

2. the number of complete weeks they have been employed

The output must be sorted by the number of weeks, starting with the longest serving employee first.

Which statement will accomplish this?

A.

B.

C.

D.

Show Answer
Correct Answer:

To accomplish the task described - displaying the last name of each employee in department 90 and the number of complete weeks they have been employed, sorted by the longest serving employee first - we must use the TRUNC function. This is because we need to calculate the number of complete weeks, and TRUNC will ensure that any partial week is not included in the count. Additionally, the result must be ordered in descending order, so the longest serving employees appear first (ORDER BY tenure DESC). Given these requirements, the correct SQL query is option B: SELECT last_name, TRUNC((SYSDATE - hire_date) / 7) AS tenure FROM employees WHERE department_id = 90 ORDER BY tenure DESC;.

Discussion

17 comments
Sign in to comment
gabolka
Sep 4, 2022

its asking for complete weeks so its B

holdfaststrongly
Sep 21, 2022

B. Rounding up gives then employees extra days for their "complete" weeks. B would make more sense.

BARNABA23
Jan 27, 2023

Task ask for number of COMPLETE weeks - so TRUNC , not ROUND function should be used Answer is B

DadiJoe
Sep 29, 2023

how to filter department = 90 when theres no Department or Dept_ID in the table... All options must be wrong.

Arth1989
Jan 9, 2024

Are you kidding me? Why paying for incorrect answers? Obviously the answer is B!

jfc1
Jan 12, 2023

B is the correct because the sorting is DESC

cadcadley
Jan 13, 2023

B is correct they said de longuest with means the hightest number of weeks

Orxan_H
Apr 19, 2023

B correct

lucemqy
Nov 13, 2023

B would be more accurate since it does not give extra days by rounding

hmatinnn
Dec 29, 2023

Answer B. Complete weeks with trunc

Lee_jong_suk
Feb 28, 2024

B is the correct answer

Nexes
Aug 4, 2023

Answer is B, complete weeks.

MariGare
Aug 8, 2023

I would say A. If we have 5 working days in a week, then Round will give us the correct result. And as we were asked to show employees, who serves longer, first, then we should order by desc. So, I do not understand why correct answer is C ...

HassanMkhlalati
Sep 12, 2023

Answer is B, complete weeks.

ArslanAltaf
Apr 14, 2024

A & B, Both are correct. More precise is B. The requirement “output must be sorted by the number of weeks, starting with the longest” means the sorting order MUST be DESC on Tenure (High -- Low) Since in C & D, the order by tenure will adopt ASC by default, it will be from low -High so lowest tenure will be on top of output and highest tenure at bottom.

MIGHTYSTUNNERS
May 1, 2024

b is correct

ArslanAltaf
Jun 9, 2024

The answer should be changed to A or B because both are correct. By no means C is correct, it violates the last requirement LONGEST SERVING ON TOP.