Home > database >  How to display the specified value content specified in oracle
How to display the specified value content specified in oracle

Time:10-01

Such as a table, when the inventory is zero wanted to show no inventory, how to do??

CodePudding user response:

 
SQL>
SQL> Create table test (id int, kc int);
The Table created
SQL> Insert into test values (1, 0);
1 row inserted
SQL> Insert into test values (2100);
1 row inserted
SQL> - use the decode
SQL> Select id, decode (kc, 0, 'there is no inventory, kc) kc from test;
ID KC
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1 no inventory
2 100
SQL> Drop table test purge;
Table dropped

SQL>

CodePudding user response:

CASE inventory

THEN the WHEN 0 'no inventory'

The ELSE inventory END

CodePudding user response:

Ignore the 2 #, can't

CodePudding user response:

The oracle:
The select case kc the when 0 then 'no'
1 then the when 'a'
End the kc
From the table.
  • Related