Reference
FUNCTIONS
Name | Usage |
---|---|
DISTINCT | Query unique results |
REGEXP | Regular Expressions https://dev.mysql.com/doc/refman/5.7/en/regexp.html |
RIGHT() | Extract a substring from a string (starting from right) |
REGEXP
Symbol | Usage |
---|---|
^ | Match the beginning of a string. i.e. ^[aeiou] |
$ | Match the end of a string. i.e. [aeiou]$ |
[a-dX], [^a-dX] | Matches any character that is (or is not, if ^ is used) either a, b, c, d or X. |
[Challenge Name: Weather Observation Station 3]
Query a list of CITY names from STATION with even ID numbers only. You may print the results in any order, but must exclude duplicates from your answer.
Solution
|
|
Challenge Name: Weather Observation Station 4
Let $N$ be the number of CITY entries in STATION, and let $N’$ be the number of distinct CITY names in STATION; query the value of $N - N’$ from STATION. In other words, find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.
Solution
|
|
[Challenge Name: Weather Observation Station 5]
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.
Solution
|
|
[Challenge Name: Weather Observation Station 6]
Query the list of CITY names starting with vowels (i.e., a
, e
, i
, o
, or u
) from STATION. Your result cannot contain duplicates.
Solution
MYSQL: REGEXP
used for regular expression
|
|
[Challenge Name: Weather Observation Station 7]
Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.
Solution
|
|
[Challenge Name: Weather Observation Station 8]
Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.
Solution
|
|
Challenge Name: Weather Observation Station 9
Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.
Solution
|
|
Challenge Name: Weather Observation Station 11
Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
Solution
either do not start with vowels or do not end with vowels == not start with vowels and end with vowels.
|
|
Challenge Name: Weather Observation Station 12
Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.
Solution
|
|
Challenge Name: Higher Than 75 Marks
Query the Name of any student in STUDENTS who scored higher than $75$ Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.
Solution
|
|