QuestionQ37

VerifiedUsing Conversion Functions and Conditional Expressions

Examine the description of the EMPLOYEES table:

Question Image

Examine the following requirements:

  1. Display each employee's last name, hire date, and number of years of service.
  2. If an employee has worked 5 or more years but fewer than 10, display “5+ years of service”.
  3. If an employee has worked 10 or more years but fewer than 15, display “10+ years of service”.
  4. If an employee has worked 15 or more years, display “15+ years of service”.
  5. If no condition matches, display “<5 years of service”.
  6. Order the results by the HIRE_DATE column.

Which statement meets all the requirements?

Explanation

TO_YMINTERVAL creates a year-to-month interval that can be added to or subtracted from a DATE to form a date cutoff. A searched CASE expression returns the result for its first true condition, so service thresholds must be ordered from 15 years to 10 years to 5 years. This correctly classifies employees into 15+, 10–under-15, 5–under-10, and under-5 groups, while sorting by hire_date.

Learn more

Community Discussion

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