tsql - Modulo seems to not be working in SQL Server 2012 -


i have simple select statement uses 1 table. 1 of columns take value of column, divides it, modulo after end decimal. why modulo not working?

select     (numeric_datatype_column / 10000) % 100      table 

all of values coming out decimals. shouldn't modulo give me integer?

shouldn't modulo give me integer?

no. modulo returns remainder of value after division. if value decimal value, modulo return decimal component. not truncated.

as working example:

select (123.1234 / 10) % 5 

2.3123400

if want remove decimals, can convert result int , modulo:

select convert(int, (123.1234 / 10)) % 5 

2


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -