SELECCIONAR *
DE tabla1 COMO t1
LEFT JOIN tabla2 COMO t2 ON t1.date_start > t2.date_start
--DML
CREAR TABLA SI NO EXISTE Employee (id int, salario int, departmentId int);
INSERTAR EN Employee (id,salary,departmentId) VALORES (1, 70000, 1),(2, 94000, 1),(3, 85000, 1),(4, 80000, 2),(5, 60000, 2),(6, 62000, 3),(7, 90000, 3),(8, 94000, 3),(9, 94000, 3);
con cte como(
seleccionar *,
rank() sobre(partición por departmentId ordenar por salary desc) como max_salary
de Employee
)
seleccionar *
de cte
donde max_salary = 1