Order by boolean column produce duplicate rows when paging in sql server -


i work on table :

order boolean column produce duplicate rows when paging in sql server

when paging using isadmin column, result contain duplicated rows. query :

select [userid],[isadmin],[date] [groups].[groupmembers] ([groupid] = 5) order [isadmin] desc offset 0 rows fetch next 6 rows  

and second query :

select [userid],[isadmin],[date] [groups].[groupmembers] ([groupid] =5)     order [isadmin] desc offset 6 rows fetch next 6 rows 

the result 2 queries :

order boolean column produce duplicate rows when paging in sql server

but if user date column, result without duplicate.

my question why using boolean produce duplicate rows ?

the problem order non-deterministic. there lot of rows admin = 0, aren't guaranteed same rows selected each time.

if change query

select [userid],[isadmin],[date] [groups].[groupmembers] ([groupid] = 5) order [isadmin] desc, [userid] 

then won't same row appearing twice (assuming [userid] unique).

actually, still won't guarantee row won't appear twice. if rows inserted between calls, , new rows have appeared on current page, of rows shown on current page re-shown on next page have been bumped down order.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -