% (Modulo) (U-SQL)
Summary
Returns the remainder of one number divided by another.
Syntax
Modulo_Operator := dividend '%' divisor.
Remarks
dividend
Is the numeric expression to divide. dividend must be a valid expression of any one of the data types in the integer and monetary data type categories, or the numeric data type.divisor
Is the numeric expression by which to divide the dividend. divisor must be any valid expression of any one of the data types in the integer and monetary data type categories, or the numeric data type.
Return Type
Determined by data types of the two arguments.
Examples
- The examples can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
- The scripts can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.
Simple Example
The following example divides the number 38 by 5. This results in 7 as the integer portion of the result and demonstrates how modulo returns the remainder of 3.
@aValue =
SELECT * FROM
( VALUES
(38)
) AS T(col1);
@result =
SELECT 38 / 5 AS Integer,
38 % 5 AS Remainder,
col1 % 5 AS Remainder2
FROM @aValue;
OUTPUT @result
TO "/Output/ReferenceGuide/Operators/Arithmetic/Modulo1.txt"
USING Outputters.Csv();