with
    c as (
        select
            a.emp_no,
            b.salary
        from
            employees a
            join salaries b on a.emp_no = b.emp_no
            and a.hire_date = b.from_date
    ),
    d as (
        select
            *
        from
            (
                select
                    emp_no,
                    salary,
                    rank() over (
                        partition by
                            emp_no
                        order by
                            to_date desc
                    ) as ranking
                from
                    salaries
            ) ff
    
        where
            ranking = 1
    )
select
    c.emp_no,
    d.salary - c.salary as growth
from
    c c
    join d d using (emp_no)
where
    c.emp_no in (
        select
            emp_no
        from
            salaries
        where
            to_date = '9999-01-01'
    )
order by growth asc