Good morning.
I have a table in Sql Server that contains Id
, Nombre
, Numero
. The names can be repeated but each will have a unique id
, I need to get the names that have the number ( Phone
) greater.
I attach images to make it clearer.
What I need to be greater is the column Phone
and that the three columns are shown.
This is how it works for me, but I do not like the idea of comparing by name.
SELECT C.ShipperId, C.Shippername, C.Phone
FROM (
SELECT MAX(A.Phone) AS Phone, A.shippername
FROM table A
GROUP BY A.shippername) B
JOIN table C
ON B.phone = C.phone
and B.shippername = C.shippername