Selecting ODD and Even values from column/row separately

For example I have years in a column listed as 1978, 1987, 1988 and 1879. How to split the odd years and even years separately. I need all the columns to be filtered as well when I run this query

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hey Arun ! To determine if a SQL value is even or odd, you can use the modulo operator (%), which returns the remainder after division of its operands. For example, A % B returns the remainder after A has been divided by B.

    Since the remainder of an even number divided by 2 is always zero, and the remainder of an odd number divided by 2 is always one, modulo can help you achieve what you want here. For example, to select all even values, you can use something like:

    select num from table where ( num % 2 ) = 0

    Like
Like Follow
  • 3 mths agoLast active
  • 1Replies
  • 23Views
  • 2 Following