Saturday, July 13, 2013

MS SQL select rows divisible by 3 or something else

Recently i ran into issue.. i had two servers doing some background processing on the same DB.. i had to somehow divide the data (work) between them .. thus thought upon dividing the row id by some integer




Here is the MS SQL syntax :

select user_id from members_tbl where (user_id % 3) = 0



Hope it helps.

Note : Above query might even work for MySql or other RDBMS.