Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Différence entre Equi-Join et Inner-Join en SQL

Essayez ceci :

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;