postgresql case when then end 以及字符串处理的用法

条件

case s.×××                                                     

when 'A'
     then (case when S.×× is null then '' else '' end)
when 'B'
     then( case when S.×× is null then '' else '' end)
when 'C'
     then( case when S.×× is null then '' else '' end) 
                                                                                                   

else s.order_class end

字符串连接以及截取某段字符串

 

          table1.userid|| COALESCE((
            SUBSTR(table1.username, position(  '(' IN table1.username) ,

              position(')' IN table1.username) -  position( '(' IN table1.username) +1)

 

 

其中  position(  '(' IN table1.username) ‘(’在字段中的位置,返回int型;

       position(')' IN table1.username) -  position( '(' IN table1.username) +1)获取()中的内容

       substr(字符串,起始位置start,截取长度 index)

 

原文地址:https://www.cnblogs.com/luoyaoquan/p/2128818.html