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:

SOLUTION:

SELECT DISTINCT CITY FROM STATION WHERE MOD(ID,2)=0; 

EXPLANATION:

  • SELECT DISTINCT CITY:
    This selects only unique city names, so if the same city appears more than once, it will only be listed once in the output.

  • FROM STATION:
    Specifies the table you're querying from.

  • WHERE MOD(ID, 2) = 0:
    Filters the rows to only those with an even ID.

Popular posts from this blog

When a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword - Hacker Rank Solution.

Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solution is provided for you in the editor; you must format and print the input to complete the solution.