sql finding longest and shortest names in a fleld

Solutions on MaxInterview for sql finding longest and shortest names in a fleld by the best coders in the world

showing results for - "sql finding longest and shortest names in a fleld"
Braelyn
21 Apr 2016
1# IN the example below, "CITY" is the filed, "STATION" is the Table
2(SELECT CITY, LENGTH(CITY)
3FROM STATION
4ORDER BY LENGTH(CITY) ASC, CITY ASC LIMIT 1)
5UNION
6(SELECT CITY, LENGTH(CITY)
7FROM STATION
8ORDER BY 
9LENGTH(CITY) DESC, CITY DESC LIMIT 1)