Find the name of the employees, whose names are same but salary are different
sql
Solution
This assumes that you want the names of both of the people listed:
SELECT e1.e_name
FROM employee e1, employee e2
WHERE e1.e_name = e2.e_name
AND e1.salary <> e2.salary;
If you only want each name listed once, you would use a SELECT DISTINCT instead of the SELECT.
Problem
I have an 'employee' table with ``` create table employee ( e_number int, e_name varchar(20), salary money, hire_date date ) ``` Now I want to display only the name of the employees who have the same name but different salary. I tried `select e_name,count(*) from employee group by e_name having count(*)>1;` but cannot combine it with "the same salary" section. Any help?