DEV Community

Manav Misra
Manav Misra

Posted on

How To Use DISTINCT With a Join?

-1

This is practice with the MySQL Employees DB. The diagram for it is here.

I want to know the top 10 salaries.salary, by employees.gender.

I have tried:

SELECT DISTINCT employees.emp_no, employees.first_name, employees.last_name, employees.gender, salaries.salary
FROM employees 
JOIN salaries ON employees.emp_no = salaries.emp_no 
ORDER BY salaries.salary DESC 
LIMIT

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay