在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Decode函数的语法结构如下: 复制代码 代码如下: decode (expression, search_1, result_1) decode (expression, search_1, result_1, search_2, result_2) decode (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n) decode (expression, search_1, result_1, default) decode函数比较表达式和搜索字,如果匹配,返回结果;如果不匹配,返回default值;如果未定义default值,则返回空值。 复制代码 代码如下: SQL> create table t as select username,default_tablespace,lock_date from dba_users; Table created. SQL> select * from t; USERNAME DEFAULT_TABLESPACE LOCK_DATE 8 rows selected.
USERNAME STATUS 8 rows selected. SQL> select username,decode(lock_date,null,"unlocked") status from t; USERNAME STATUS 8 rows selected. |
请发表评论