HackerRank中Basic Select专题Weather Observation Station 6;查询 STATION 中以元音(a、e、i、o、u)结尾的城市名称列表。查询结果不能包含重


前言

HackerRank中Basic Select专题Weather Observation Station 7

在这里插入图片描述
查询 STATION 中以元音(a、e、i、o、u)结尾的城市名称列表。查询结果不能包含重复内容。


一、right、substing、like

1、right(A,x)
截取右边的x个字符

select distinct city from station where right(city,1) in ('a','e','i','o','u')

2、substring(A,x,y)
截取A这个字段的第 X个字符位置(负数为倒数)开始取,只截取之后的y个字符

select distinct city from station where substring(city,-1,1) in ('a','e','i','o','u')

3、like

select distinct CITY from station where CITY like '%a' or city like '%e' or city like '%o' or city like '%i' or city like '%u'

猜你喜欢

转载自blog.csdn.net/hsuehgw/article/details/131958675
今日推荐