Sobes.tech
Middle

SELECT * DIN tabelul1 CA t1 LEFT JOIN tabelul2 CA t2 ON t1.date_start > t2.date_start --DML CREAZĂ TABELUL DACĂ NU EXISTĂ Employee (id int, salary int, departmentId int); INSERĂ ÎN Employee (id,salary,departmentId) VALORI (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); cu cte ca( select *, rank() over(partition by departmentId order by salary desc) ca max_salary din Employee ) select * from cte unde max_salary = 1