I have table:
I want to get the latest status for today, provided that if there are no vacations or business trips on the current date, the "Job" status should be displayed. I use this query, but it's incorrect (some times it shows two values)
SELECT Name,Status,Start,End
FROM employee as emp
Where Start = (Select max(Start) from employee as emp2 where emp.Name = emp2.Name )
Order by Name
Current result
Name Status Start End
People-1 Job 2/3/2020 0001-01-01 00:00:00.000
People-1 business trip 4/20/2022 4/22/2022
Expected result:
Name Status Start End
People-1 Job 2/3/2020 0001-01-01 00:00:00.000
