decode(字段,表示式1,表示式2,表示式。。。)
當,欄位的值為 表示式1時返回表示式2,以此類推。
例子1:
select decode(opertype,1,'a',2,'b',3,'c','hh') from zm_corp_record
opertype等於1時 返回a。。
不等於1、2、3時 ,返回hh
例子2:
select ename,comm, decode(comm,null, 0) aa from emp;
comm為空時,返回0,否則返回空;
例子3:
表table_subject,有subject_name列。要求按照:語、數、外的順序進行排序。 select * from table_subject order by decode(subject_name, '語文', 1, '數學', 2, , '外語',3)
oracle中的decode函式
decode函式的用法解釋 1 decode 條件,a,b,c 相當於 if 條件 a then b else c 2 decode 條件,a,b,c d,e,f,g 相當於 if 條件 a then b else if 條件 c then d,else if 條件 e then f else g ...
oracle中的decode函式
decode函式是oracle pl sql是功能強大的函式之一,目前還只有oracle公司的sql提供了此函式,其他資料庫廠商的sql實現還沒有此功能。decode有什麼用途 呢?先構造乙個例子,假設我們想給智星職員加工資,其標準是 工資在8000元以下的將加20 工資在8000元以上的加15 通...
oracle中decode 的作用
decode函式相當於一條件語句 if 它將輸入數值與函式中的引數列表相比較,根據輸入值返回乙個對應值。函式的引數列表是由若干數值及其對應結果值組成的若干序偶形式。當然,如果未能與任何乙個實參序偶匹配成功,則函式也有預設的返回值。區別於sql的其它函式,decode函式還能識別和操作空值.其具體的語...