DEV Community

Manav Misra
Manav Misra

Posted on

Answer: How To Use DISTINCT With a Join?

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)