例如一個table,在庫存為0時想要顯示無庫存,如何實作??
uj5u.com熱心網友回復:
SQL>
SQL> create table test(id int, kc int);
Table created
SQL> insert into test values(1,0);
1 row inserted
SQL> insert into test values(2,100);
1 row inserted
SQL> -- 使用 decode
SQL> select id, decode(kc,0,'無庫存',kc) kc from test;
ID KC
--------------------------------------- ----------------------------------------
1 無庫存
2 100
SQL> drop table test purge;
Table dropped
SQL>
uj5u.com熱心網友回復:
CASE 庫存WHEN 0 THEN '無庫存'
ELSE 庫存 END
uj5u.com熱心網友回復:
忽略 2#吧,不行uj5u.com熱心網友回復:
oracle:select case kc when 0 then ‘無’
when 1 then ‘有’
end kc
from table;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/103506.html
標籤:基礎和管理
上一篇:oracle 匯入
下一篇:SQL優化
