How to select columns with an even ID number in SQL?

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

You can try this query:

SELECT DISTINCT CITY FROM STATION WHERE (ID % 2) = 0 

For DB2:- SELECT DISTINCT CITY FROM STATION

WHERE MOD(ID, 2) = 0;

For Oracle:- SELECT DISTINCT CITY FROM STATION

WHERE MOD(ID, 2) = 0;

For MySQL:- SELECT DISTINCT CITY FROM STATION WHERE MOD(ID, 2) = 0; -- Or -- SELECT DISTINCT CITY FROM STATION

WHERE ID%2=0;

For MSSQL:- SELECT DISTINCT CITY FROM STATION

WHERE ID%2=0;

Tags:

Sql

Oracle