I have table like this:
ID NAME
1 juan
2 pedro
3 jose
4 lucas
5 antoni
I need show result like this:
1 juan
3 jose
5 antoni
How should I proceed to show every record in a sequence of 2 ? Thank you
I have table like this:
ID NAME
1 juan
2 pedro
3 jose
4 lucas
5 antoni
I need show result like this:
1 juan
3 jose
5 antoni
How should I proceed to show every record in a sequence of 2 ? Thank you
Use Modulo(%)
operator
Select * from yourtable Where ID % 2 = 1
This considers ID
is sequential
SELECT * FROM
(
SELECT ID,NAME,ROW_NUMBER()OVER(ORDER BY ID ASC)as ROW
FROM TABLE
) as A
WHERE ROW % 2 = 0