Respuesta :
Answer:
If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
- CDE 3
- LMNO 4
Explanation has given below.
Explanation:
Lets us consider and focused on the problem
Suppose that the City has Latitude_N for northern latitude and Long_W for western longitude.
Where LAT_N is the northern latitude, and LONG_W is the western longitude.
Lets Input
Let us say that the CITY only has four entries: XYZ, CDE, LMNO, and WXY
then the output will be
CITY names are CDE, LMNO, WXY, XYZ with lengths such as 3, 4, 3, and 3. In the given CITY, the most extended City is LMNO. However, three options are available for the shortest length. So we choose the CITY of alphabetically, So CDE choose.
Query for two cities in STATION will be as follow:
{
Select CITY,
char_length(CITY) as len_city
from STATION
where length(CITY)=(select length(CITY)
from STATION
order by length(CITY) LIMIT 1)
Order by CITY LIMIT 1)
(select CITY,
length(CITY) as length_city
from STATION
where length(CITY)=(select length(CITY)
from STATION
order by length(CITY) DESC LIMIT 1)
Order by CITY DESC LIMIT 1)
ORDER BY length(CITY);
Such as
SELECT city, LENGTH(city) FROM station
WHERE LENGTH(city)=(SELECT LONGS(LENGTH(city)) FROM station)
SELECT city, LENGTH(city)
FROM STATION
WHERE LENGTH(city)=(SELECT SHORTEST(LENGTH(city)) FROM STATION)
ORDER BY CITY;