how to show only even or odd rows in sql server 2008?

前端 未结 16 1510
甜味超标
甜味超标 2020-12-05 13:53

i have a table MEN in sql server 2008 that contain 150 rows.

how i can show only the even or only the odd rows ?

thank\'s in advance

16条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 14:50

    To select an odd id from a table:

    select * from Table_Name where id%2=1;
    

    To select an even id from a table:

    select * from Table_Name where id%2=0;
    

提交回复
热议问题