select distinct emp_no,growth from (select emp_no, LAST_VALUE(salary)over(partition by emp_no order by from_date range between unbounded preceding and UNBOUNDED following)-first_value(salary)over(partition by emp_no order by from_date range between unbounded preceding and UNBOUNDED following) as growth from salaries ) t where (emp_no,'9999-01-01') in (select emp_no,to_date from salaries) order by growth