First, decode function
Meaning explanation:
1, Decode (condition, value 1, return value 1, value 2, return value 2,... Value N, return value N, default value)
The function has the following meanings:
IF condition = value 1 Then
RETURN (translation value 1)
elsif condition = value 2 Then
RETURN (translation value 2)
......
elsif condition = value n Then
RETURN (translated value N)
ELSE
RETURN (default value)
END IF
The result of this function is that when the value of the field or Field operation is equal to the value 1 o'clock, the function returns the value 2, otherwise the value 3
Of course, a value of 1, a value of 2, a value of 3 can also be an expression, this function makes some SQL statements a lot simpler
2, Decode (field or Field operation, value 1, value 2, value 3)
The result of this function is that when the value of the field or Field operation is equal to the value 1 o'clock, the function returns the value 2, otherwise the value 3
Of course, a value of 1, a value of 2, a value of 3 can also be an expression, this function makes some SQL statements a lot simpler
Second, add_months
Add_months has two parameters, the first parameter is the date, the second argument is the number (in months) that the date is added and minus
3 months later, select Add_months (sysdate,3) from dual;
3 months ago, select Add_months (sysdate,-3) from dual;
Third, case and then usage
Https://www.cnblogs.com/Richardzhu/p/3571670.html
Oracle function decode