前言
HackerRank中Basic Select专题Weather Observation Station 8
查询 STATION 中不以元音开头的城市名称列表。查询结果不能包含重复内容。本文通过subString(A,x,y)、left(A,x)进行编写SQL
一、subString(A,x,y)、left(A,x)
1、subString(A,x,y)
截取A这个字段的第 X个字符位置(负数为倒数)开始取,只截取之后的y个字符
select distinct city from station where substring(city,1,1) not in ('a','e','i','o','u')
2、left(A,x)
截取左边的x个字符
select distinct city from station where left(city,1) not in ('a','e','i','o','u')