The following query returns employees years of service-Output excel. The employees are ordered according to their years of service in decreasing order.
select empl_id, last_name, first_name, date(coalesce(adj_hire_date,date_started)) as date_started,
(now()-coalesce(adj_hire_date,date_started)) /365.25 len_of_service_in_yrs
from employee
where empltype_code = 'EMPL'
order by len_of_service_in_yrs desc;;
output to c:\lengthOfServiceData.xls format excel;;