I wanted to use MOD
function in SQL Server 2008R2
and followed this link but still got the message:
'MOD' is not a recognized built-in function name.
DECLARE @m INT SET @m = MOD(321,11) SELECT @m
Error:
Msg 195, Level 15, State 10, Line 2
'MOD' is not a recognized built-in function name.
Why I can't use this function from the link above?
SQL MOD() function is used to get the remainder from a division. The SQL DISTINCT command along with the SQL MOD() function is used to retrieve only unique records depending on the specified column or expression. Syntax: MOD( dividend, divider ) PostgreSQL and Oracle.
The Oracle MOD() is used to return the remainder of a dividend divided by a divisor. This function also works on fractional values and returns the exact remainder. The function returns dividend when the value of divisor is 0.
A mathematical function that returns the absolute (positive) value of the specified numeric expression. ( ABS changes negative values to positive values. ABS has no effect on zero or positive values.)
DIV() Function in MySQL This function in MySQL is used to return a quotient (integer) value when integer division is done. For example, when 7 is divided by 3, then 2 will be returned.
The MOD
keyword only exists in the DAX
language (tabular dimensional queries), not TSQL
Use %
instead.
Ref: Modulo
In TSQL, the modulo is done with a percent sign.
SELECT 38 % 5 would give you the modulo 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With