Check out example codes for "sql finding longest and shortest names in a fleld". It will help you in understanding the concepts better.

Code Example 1

# IN the example below, "CITY" is the filed, "STATION" is the Table
(SELECT CITY, LENGTH(CITY)
FROM STATION
ORDER BY LENGTH(CITY) ASC, CITY ASC LIMIT 1)
UNION
(SELECT CITY, LENGTH(CITY)
FROM STATION
ORDER BY 
LENGTH(CITY) DESC, CITY DESC LIMIT 1)

Learn ReactJs, React Native from akashmittal.com