请参阅https://www.hackerrank.com/challenges/weather-observation-station-11?h_r=next-challenge&h_v=zen
上的问卷关于sql查询:
查询STATION的CITY名称列表,这些名称不是以元音开头,也不是以元音结尾。您的结果不能包含重复项。
到目前为止我已经
了SELECT DISTINCT CITY FROM STATION
WHERE CITY NOT RLIKE'^[aeiouAEIOU].*$'
AND city NOT LIKE '%a'
AND city NOT like '%e'
AND city NOT like '%i'
AND city NOT like '%o'
AND city NOT like '%u'
它告诉我这是错的,但我不能在输出中看到任何错误的答案请告知.... 感谢
答案 0 :(得分:0)
Helo,它在我的测试中起作用。 尝试撰写正则表达式。
没有开始而且没有以低俗结束:
SELECT DISTINCT CITY
FROM STATION
WHERE CITY NOT RLIKE '^[aeiouAEIOU].*'
AND CITY NOT RLIKE '.*[aeiouAEIOU]$';
没有开始或不以wovel结束:
SELECT DISTINCT CITY
FROM STATION
WHERE CITY NOT RLIKE '^[aeiouAEIOU].*'
OR CITY NOT RLIKE '.*[aeiouAEIOU]$';
未开始XOR(或独家)不以wovel结尾:
SELECT DISTINCT CITY
FROM STATION
WHERE CITY NOT RLIKE '^[aeiouAEIOU].*'
XOR CITY NOT RLIKE '.*[aeiouAEIOU]$';
希望能提供帮助。
答案 1 :(得分:0)
这对于使用MySQL的我来说是有效的:
select distinct CITY from STATION where CITY NOT RLIKE '^[aeiouAEIOU]' OR CITY NOT RLIKE '[AEIOUaeiou]$' GROUP BY CITY;