Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Unterschied zwischen Equi-Join und Inner-Join in SQL

Versuchen Sie Folgendes:

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;