MySQL SIGN 函数

  • 定义和用法

    SIGN - 返回数字的符号。
  • 语法

    SIGN(X)
    返回X的符号(负数-1为或零或正为1)。
  • 示例

    mysql>SELECT SIGN(-4.65);
    +---------------------------------------------------------+
    |                      SIGN(-4.65)                        |
    +---------------------------------------------------------+
    |                          -1                             |
    +---------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql>SELECT SIGN(0);
    +---------------------------------------------------------+
    |                         SIGN(0)                         |
    +---------------------------------------------------------+
    |                            0                            |
    +---------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql>SELECT SIGN(4.65);
    +---------------------------------------------------------+
    |                         SIGN(4.65)                      |
    +---------------------------------------------------------+
    |                             1                           |
    +---------------------------------------------------------+
    1 row in set (0.00 sec)
    
    尝试一下