views:

25

answers:

1

I have a process that needs to select rows from a Table (queued items) each row has a quantity column and I need to select rows where the quantities add to a specific multiple. The mulitple is the order of between around 4, 8, 10 (but could in theory be any multiple. (odd or even)

Any suggestions on how to select rows where the sum of a field is of a specified multiple?

+1  A: 

My first thought would be to use some kind of MOD function which I believe in SQL server is the % sign. So the criteria would be something like this

WHERE MyField % 4 = 0 OR MyField % 8 = 0

It might not be that fast so another way might be to make a temp table containing say 100 values of the X times table (where X is the multiple you are looking for) and join on that

Kevin Ross
Thanks, I am using this within C#, I think the solution is more application that database related, am just trying to find other / more proficient ways to implement things. Will ask this as a C# question.. Thanks forthe top tho!
Mark Redman