使用最短和最长的城市名称查询STATION中的两个城市, [英] Query the two cities in STATION with the shortest and longest CITY names,
本文介绍了使用最短和最长的城市名称查询STATION中的两个城市,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查询:查询STATION中两个城市的最短和最长CITY名称,以及它们各自的长度(即名称中的字符数).如果最小或最大的城市不止一个,请按字母顺序选择最先出现的城市.
Query: Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
样本输入:
让我们说CITY只有四个条目:DEF, ABC, PQRS and WXY
Let's say that CITY only has four entries: DEF, ABC, PQRS and WXY
样本输出:
ABC 3
PQRS 4
推荐答案
尝试一下:)
mysql代码....简单的一个
mysql code.... simple one
select CITY,LENGTH(CITY) from STATION order by Length(CITY) asc, CITY limit 1;
select CITY,LENGTH(CITY) from STATION order by Length(CITY) desc, CITY limit 1;
这篇关于使用最短和最长的城市名称查询STATION中的两个城市,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文