### SQL basics- complete reference guide - part5 - Mathematical Functions

Part5: Mathematical Functions in SQL- Complete Reference

FunctionDescriptionSYNTAXExample
ABSABS ( { int | long | decimal | double } )
ACOSACOS(double)
ASINASIN(double)
ATANATAN(double)
COSCOS(double)
COTCOT(double)
SINSIN(double)
TANTAN(double)
ATAN2ATAN2(double, double)
BITANDThe bitwise AND operation.BITAND(long, long)
BITORThe bitwise OR operation.BITOR(long, long)
BITXORThe bitwise XOR operation.BITXOR(long, long)
MODThe modulo operation.MOD(long, long)
CEILINGCEILING(double)
DEGREESDEGREES(double)
EXPEXP(double)
FLOORFLOOR(double)
LOGLOG(double)
LOG10LOG10(double)
SQRTSQRT(double)
PIPI()
POWERPOWER(double, double)
RANDCalling the function without parameter returns the next a pseudo random number.RAND( [ int ] )
RANDOM_UUIDReturns a new UUID with 122 pseudo random bits.RANDOM_UUID()
ROUNDRounds to a number of digits.ROUND(double, digitsInt)
ROUNDMAGICThis function rounds numbers in a good way, but it is slow.ROUNDMAGIC(double)
SECURE_RANDGenerates a number of cryptographically secure random numbers.SECURE_RAND(int)
SIGNReturns -1 if the value is smaller 0, 0 if zero, and otherwise 1.SIGN ( { int | long | decimal | double } )
ENCRYPTEncrypts data using a key.ENCRYPT(algorithmString, keyBytes, dataBytes)
DECRYPTDecrypts data using a key.DECRYPT(algorithmString, keyBytes, dataBytes)
HASHCalculate the hash value using an algorithm, and repeat this process for a number of iterations.HASH(algorithmString, dataBytes, iterationInt)
TRUNCATETruncates to a number of digits (to the next value closer to 0).TRUNCATE(double, digitsInt)
COMPRESSCompresses the data using the specified compression algorithm.COMPRESS(dataBytes [, algorithmString])
EXPANDExpands data that was compressed using the COMPRESS function.EXPAND(bytes)
ZEROReturns the value 0.ZERO()