QuestionQ169

VerifiedUsing Single-Row Functions to Customize Output

Examine the description of the EMPLOYEES table:

Question Image

For every employee in department 90, you want to display:

  1. Their last name.
  2. The number of complete weeks for which they have been employed.

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

Which statement accomplishes this?

Explanation

Oracle TRUNC on a numeric value with no precision argument removes the fractional part, so TRUNC((SYSDATE - hire_date) / 7) returns only completed weeks. Sorting the tenure alias with DESC places the largest number of weeks, and therefore the longest-serving employee, first.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!