oracle中sign函数详解

在Oracle/PLSQL中, sign 函数返回一个数字的正负标志.

语法如下:sign( number )

number 要测试标志的数字.

If number < 0, then sign returns -1.
If number = 0, then sign returns 0.
If number > 0, then sign returns 1.

应用于:

  • Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

例如:

sign(-23)

would return -1

sign(-0.001)

would return -1

sign(0)

would return 0

sign(0.001)

would return 1

sign(23)

would return 1

sig(23.601)

would return 1

 

 

示例:
一、select sign( 100 ),sign(- 100 ),sign( 0 ) from dual;

  SIGN(100) SIGN(-100) SIGN(0)
  -----------------------------------------------------------
  1 -1 0

二、a=10,b=20 
  则sign(a-b)返回-1

你可能感兴趣的:(数据库操作)