check if row number is odd or even
Database
2
Posts
2
Posters
0
Views
1
Watching
-
Do you want to check for the ID of the PK column or the order of the record? in the first case:
Select *,case (ID % 2) when 1 then 'Odd' Else 'Even' End from items
in the second case (SQL Server 2005 only):Select *,case (row_number() over (order by ID) % 2) when 1 then 'Odd' Else 'Even' End from items
Hesham A. Amin blog