SIGN
SIGN(X)
Section titled “SIGN(X)”- x: This parameter corresponds to the numeric value whose sign you want to calculate. If X is positive, the SIGN function will return 1. If X is negative, the SIGN function will return -1. If X is zero, the SIGN function will return 0.
Example
Section titled “Example”SELECT SIGN(-15);SELECT SIGN(0);SELECT SIGN(45);Output
Section titled “Output”-101Explanation
Section titled “Explanation”In the given example, the SIGN() function returns -1 when the argument is negative (-15), 0 when the argument is zero (0), and 1 when the argument is positive (45). This function is useful for categorizing data into positive, negative, and zero groups.
SIGN( numeric_expression )
Section titled “SIGN( numeric_expression )”- numeric_expression: This is the value for which the SIGN function is to be calculated. It can be an integer, a decimal, a float, or any value that can be passed as a numeric expression.
Example
Section titled “Example”SELECT SIGN(-10) AS SignValueOutput
Section titled “Output”SignValue------------1Explanation
Section titled “Explanation”The SIGN function in SQL Server is used to determine whether the number is positive, negative, or zero. It returns -1 when the number is negative, 0 when the number is zero, and 1 when the number is positive. In this example, the SIGN function returned -1 because -10 is a negative number.
SIGN(n NUMBER) RETURN NUMBER;
Section titled “SIGN(n NUMBER) RETURN NUMBER;”- n number: Input parameter that takes a numeric value, used by the Oracle SIGN function to return the sign of this number. Supports both positive and negative numbers as well as zero.
Example
Section titled “Example”SELECT SIGN(-15) FROM dual;Output
Section titled “Output”-1Explanation
Section titled “Explanation”The SIGN function in Oracle takes a single argument and returns -1, 0, or 1 based on whether the argument is negative, zero, or positive. In the provided example, the function returns -1 because the argument (-15) is negative.