CASE .. WHEN expression in Oracle SQL

前端 未结 9 869
北荒
北荒 2020-12-04 13:17

I have the table with 1 column and has following data

Status
a1
i
t
a2
a3

I want to display the following result in my select query

9条回答
  •  执笔经年
    2020-12-04 14:01

    Following syntax would work :

    ....
    where x.p_NBR =to_number(substr(y.k_str,11,5))
    and x.q_nbr = 
     (case 
     when instr(substr(y.m_str,11,9),'_') = 6   then  to_number(substr(y.m_str,11,5))
     when instr(substr(y.m_str,11,9),'_') = 0   then  to_number(substr(y.m_str,11,9))
      else 
           1
      end
    )
    

提交回复
热议问题