Case-tehn in single line SQL

xiaoxiao2021-03-06  19

SQL> SELECT (if j <0 THEN J ELSE 100 End) from (select count (*) j from a); SELECT (if j <0 THEN J ELSE 100 End) from (SELECT Count (*) J from a) * Error is located in Chapter 1: ORA-00907: Missing Right Brand

Time: 00: 00:00.00sql> Select (Case When J <0 THEN J ELSE 100 End) from (select count (*) j from a);

(Casewhenj <0thenjelse100nd) ---------------------------- 100

Time: 00: 00: 00.00sql> Select decode ((J-0), 0, J, 200) from (select count (*) j from a);

Decode ((j-0), 0, J, 200) --------------------- 200

Time: 00: 00:00.00sql> Select decode (SIGN (J-0), 1, J, 0, 'NO RESULT', - 1, 200) from (Select Count (*) J from A);

Decode (SIGN (J-0), 1, J, 0, 'Noresult', - 1,200) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------- 3

Time: 00: 00: 00.00sql>

转载请注明原文地址:https://www.9cbs.com/read-43636.html

New Post(0)