Weather Observation Station 3
Last updated
Last updated
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
Sol:
SELECT DISTINCT CITY FROM STATION WHERE MOD(ID, 2) = 0;
Explanation:
SELECT DISTINCT CITY : This part of the query indicates that we want to retrieve unique values from the CITY column of the STATION table. The DISTINCT keyword ensures that only distinct (unique) values are returned.
FROM STATION: This specifies the table from which we want to retrieve the data, which is the STATION table.
WHERE MOD(ID, 2) = 0: This is a condition added to the query using the WHERE clause.
The MOD function calculates the remainder of the ID divided by 2. If the remainder is 0, it means the ID is an even number. So, this condition filters the rows in the STATION table so that only rows with even IDs are included in the result.