I have a table with one of the columns is of type varchar(city). and want to find the longest and shortest of values stored in that column.
select a.city, a.city
In Oracle, we can do like this
select city, length(city)
from (select city from STATION order by length(city) DESC, city ASC)
where rownum = 1
union
select city, length(city)
from (select city from STATION order by length(city), city ASC)
where rownum = 1;
The idea is to get the longest and shortest city then union them into one result.