Skip to content
Advertisement

is there a sql query I want to get last job_id with the earliest start date

is there a sql query I want to get last job_id with the earliest start date.

I have a table named employee

expected results

Advertisement

Answer

First, use FIRST_VALUE() window function to get the latest job_id for each employee_id and then use conditional aggregation to get the earliest start_date for this job_id:

See the demo.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement