DEV Community

loading...

Answer: How To Use DISTINCT With a Join?

Manav Misra
I'm a JS Subject Matter Expert (SME) that has spent the past few years spearheading curricula and teaching initiatives at colleges and bootcamps, in person and virtually.
・1 min read
SELECT employees.emp_no, employees.first_name, employees.last_name, employees.gender, MAX(salaries.salary) AS salary FROM employees JOIN salaries ON employees.emp_no = salaries.emp_no GROUP BY employees.emp_no ORDER BY salary DESC LIMIT 10
+--------+------------+-----------+--------+--------+
| emp_no | first_name | last_name | gender | salary |
+--------+------------+-----------+--------+--------+
|  43624 | Tokuyasu   | Pesch     | M      | 158220 |
|

Discussion (0)