I have the table (result of a query) with the cities and their respective state ...
...Nowyouonlyhavetodisplaycitieswithequalnamesanddifferentstates:
How do I do the command?
It would be something like this, first you get only those that have more than one recurrence in the table, and then make a query by name, as you did not know the name of your table just replace the [sua_tabela]
tag with the name of the table and test:
SELECT
*
FROM [sua_tabela]
WHERE cidade = (
SELECT
cidade
FROM
(SELECT
COUNT(*) AS qtd,
cidade
from [sua_tabela]
GROUP BY cidade
HAVING qtd > 1) as aux);