oracle 查詢爲空返回指定值,及滿足條件返回指定值

查詢結果存在爲空給與一個默認值 

 nvl(h.date_type, '時間類型') as dateType

根據條件判斷返回對應值

第一種:

 case
         when h.date_time= 0 then
          '7天'
         when h.date_time= 1 then
          '半個月'
         when h.date_time = 2 then
          '一個月'
       end as dateTime

 第二種:

decode(h.yqsj,'0','7天','1','半個月','一個月)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章