Friday, 1 October 2021

Select odd and even rows in the SQL

CREATE TABLE #TEST (ID INT IDENTITY (1,1), ROWID uniqueidentifier)
 
GO
 
INSERT INTO #TEST (ROWID) VALUES (NEWID())
 
GO 10
 
--drop table #TEST
 
select * from #TEST where Id % 2 = 0 --Even

select * from #TEST where Id % 2 != 0 --Odd

No comments:

Post a Comment