Managers from Same City in SQL

Question:

Managers from Same City

Managements wants to display city and manager details if more than one manager from same city. 
Write a query to display city , manager name and their phone number. Sort the result based on city and manager name. 

Managers from Same City

Code:

Main.sql

select distinct m1.city, m1.name, m1.phone
from manager m1 join manager m2
       on m2.city=m1.city
       where m1.name!=m2.name
order by 1,2;

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *