This is the question in 'Hackerrank'
"Query the list of CITY(Column) names from STATION(Table) that do not start with vowels and do not end with vowels. Your result cannot contain duplicates."
Below is my answer, but I am getting an error in Hackerrank. Am I missing something that is very silly?
SELECT DISTINCT [City] FROM [Station] WHERE [City] NOT LIKE '[aeiou]%[aeiou]'
快分手...
[City] NOT LIKE '[aeiou]%' AND [City] NOT LIKE '%[aeiou]'
我会说脱掉开始和结束括号括号
[City] NOT LIKE 'aeiou%' AND [City] NOT LIKE '%aeiou'
This works:
SELECT
distinct (city)
FROM
station
WHERE
city not rlike '^[aeiouAEIOU].* $'
AND city not rlike '^.* [aeiouAEIOU]$';
Remove space from above query, this will work perfectly
SELECT
distinct (city)
FROM
station
WHERE
city not rlike '^[aeiouAEIOU].*$'
AND city not rlike '^.*[aeiouAEIOU]$';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.