Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含两列整数的表。我想从中选择数据(以某种标准方式)并按规则添加一个新列:
例子:
16 | 15 | 1 20 | 28 |-1 11 | 11 | 0 28 | 14 | 1 ...
Sounds like you want the SIGN Function
SIGN
SELECT Col1, Col2, SIGN(Col1 - Col2) AS Col3 FROM T
SELECT X,Y, CASE WHEN X > Y THEN 1 WHEN X < Y THEN -1 ELSE 0 END AS "Z" FROM table_name