Saturday 24 October 2015

Selecting 'vowels'

Given a table STATION that holds data for five fields namely ID, CITY, STATE, NORTHERN LATITUDE and WESTERN LONGITUDE.
+-------------+------------+
| Field       |   Type     |
+-------------+------------+
| ID          | INTEGER    |
| CITY        | VARCHAR(21)|
| STATE       | VARCHAR(2) |
| LAT_N       | NUMERIC    |
| LONG_W      | NUMERIC    |
+-------------+------------+

1) Write a query to print the list of CITY that start with vowels (a, e, i, o, u) in lexicographical order. Do not print duplicates.

>>select distinct city from station where city like'a%' or city like'e%' or city like'i%' or city like'o%' or city like'u%' order by city;

2) Write a query to print the list of CITY that ends with vowels (a, e, i, o, u) in lexicographical order. Do not print duplicates.

>>select distinct city from station where city like '%a' or city like '%e' or city like '%i' or city like '%o' or city like '%u' order by city;

No comments:

Post a Comment