Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Differenza tra Equi-Join e Inner-Join in SQL

Prova questo:

SELECT a.First_Name, b.Dept_Name, alt.Min_Salary AS Min_Salary
FROM table123 a
INNER JOIN table246 b
    ON a.Dept_ID = b.Dept_ID
INNER JOIN (
            SELECT Dept_ID, MIN(Salary) Min_Salary
            FROM table123
            GROUP BY Dept_ID
           ) alt
    ON b.Dept_ID = alt.Dept_ID
WHERE a.Salary = alt.Min_Salary;