反向数字标志在哪里sql

时间:2017-04-29 14:50:57

标签: select where sign

Picture click here

亲爱的 我想要选择sql Query添加 - 签名到invoiceType ='s'的数字 我该怎么办?

1 个答案:

答案 0 :(得分:0)

使用案例条件检查invoiceType ='s'然后集中 - 签署否则使用普通invoiceamount。

SELECT CASE WHEN invoiceType ='s' THEN '-'||invoiceamount ELSE invoiceamount END FROM Invoice;

SELECT CASE WHEN invoiceType ='s' THEN (invoiceamount * -1) ELSE invoiceamount END FROM Invoice;