For this, I would use a table of common expressions (CTE). This is similar to creating a temporary table.
;with EmpInfo as
(
SELECT start_date, employee_no, MIN(start_date) OVER () as MinStartDate
FROM [employees]
)
SELECT start_date, employee_no FROM EmpInfo WHERE start_date = MinStartDate
Here is the Microsoft web page about Using Common Table Expressions
source
share