Rounds a value to the number of decimal places specified in the second parameter.
Syntax
ROUND ( numeric_expression, length [,integer_no ] )
Where
Length: If +ve, numeric_expression is rounded to then umber of decimal positions
specified by length. If –ve, numeric_expression is rounded on the left side of the
decimal point.
Integer_no: Is the type. Default is 0. If Non-zero is specified,numeric_expression is truncated.
Examples:
If length is negative and larger than the number of digits before the decimal point, then Round() returns Zero;
ROUND(748.58,-4) => 0
If length is negative number, Round() returns rounded numeric_expression,
regardless of data type.
Select ROUND(748.58,-1) => 750.00
Select ROUND(748.58,-2) => 700.00
Select ROUND(748.58,-3) => 1000.00
Select ROUND(748.58,-4) => 0;
Using ROUND() to truncating
Select ROUND(150.75,0,1) => 150.0
A numeric of anything but 0 will mean the number is truncated
SELECT ROUND(100.345678,5,0) =>100.345680
SELECT ROUND(100.345678,5,1) =>100.345670
SELECT ROUND(107.345678,-1,0) => 110.000000
SELECT ROUND(12.5,0) => 13.0
SELECT ROUND(12.4999,0) =>12.0000
SELECT ROUND(12.4999,1) =>12.5000
SELECT ROUND(12.4999,-1) =>10.0000
SELECT ROUND(3.22245, 3) => 3.22200
ABS():
Returns the absolute value of any number passed to it.
Syntax:
ABS (float_number);
Examples:
Returns positive value
Select ABS(-1.25) => 1.24
7.3. Logarithmic and Exponential functions
EXP():
EXP Returns a float, which is the exponential of the float value passed in as a parameter
Syntax
EXP (float_number);
Examples:
SELECT EXP(4) => 54.598150033144236
LOG():
It takes one positive valued parameter, and returns the natural logarithm of this parameter as a float value
Syntax
LOG(Decimal_Number)
Examples:
Find logramethic value
SELECT LOG(5.67) => 1.7351891177396608S
LOG value is reverse to Exponential
SELECT LOG(EXP(2)) => 2
LOG10():
Returns the base 10 logarithm of this parameter as a float value
Syntax
LOG10(float) ;
Examples:
Find the LOG10 value
SELECT LOG10(5.67) => 0.75358305889290655
PI() :
Returns the value of the mathematical constant PI to 16 decimal places
Syntax
PI()
Examples:
Find the PI Value
SELECT PI()=>3.14159265358979315
7.4. Power and Root functions.
POWER(x,y) :
Returns a number(x) raised to the power of a number (y)
Syntax
POWER (float_x, int_n);
Examples
Find Square(10)
SELECT POWER(10,2)=>100
Square():
Returns the square of the given number
Syntax
SQUARE(float_number);
Examples
Find SQuare(2)
SELECT SQUARE(20)=> 400
SQRT(n) is reverse of SQUARE(n)
SELECT SQRT(SQUARE(2))=> 2
Sqrt():
Returns square root of the given number
Syntax
Sqrt(float_number);
Examples
Find the SquareRoot of 100
SELECT SQRT(100) => 10
Find the SQRT of decimal value
Select SQRT(125.43) => 11.199553562530964
7.5. Validating number.
ISNUMERIC():
Returns 1 if true otherwise 0
Syntax
ISNUMBERIC(String)
Examples
Validating negative decimal value
Select ISNUMERIC(-1.25)=> 1
Validating negative String Value
Select ISNUMERIC('SQL Server') => 0
Validating Date value
Select ISNUMERIC('2001-09-30') =>0
Validating Alphanumeric value
SELECT ISNUMERIC('123ABC') => 0
Validating numeric-String value
LECT ISNUMERIC('123')=>1
SIGN():
Returns sing of given number. i.e., -1 for negative +1 for positive and 0 for zero.
Syntax
SIGN(float_number);
Examples
Find sign of negative integer
SELECT SIGN(-23)=> -1
7.6. Generating Random Number
RAN():
Generates a random number between 0 and 1 as float point value.
This blog is very useful for Students , Learned a lot of new technonologies and thanks for sharing
ReplyDelete.Net Online Training
Nice blog. Explained well. I have suggested to my friends to go through this blog. Very nice explanation. Thank you for sharing this useful information. keep sharing.If you want to learn Dotnet course in online, please visit below site.
ReplyDeletedotnet Online Training, dotnet course, dotnet online training in kurnool, dotnet online training in hyderabad, dotnet online training in bangalore, online courses, online learning, online education, trending courses, best career courses
ReplyDeleteNice blog..! I really loved reading through this article. Thanks for sharing such
a amazing post with us and keep blogging...
ms dotnet training in hyderabad