I'm having trouble replicating the mod function in SQL sever.
In excel, mod (-3, 7) = 4. But in SQL, -3 % 7 = -3
Am I using % wrong, or does SQL do mod differently?
This will give a result between 0 and n - 1 for both positive and negative values of x:
((x % n) + n) % n
2.1m questions
2.1m answers
60 comments
57.0k users