title: Substring from underscore and onwards in Oracle
body: <p>I have a string with under score and some characters. I need to apply substring and get values to the left excluding underscore. So I applied below formula and its working correctly for those strings which have underscore (_). But for strings without (_) it is bringing NULL. Any suggestions how this can be handled in the substring itself. </p>
  
  <p>Ex: ABC_BASL ---> Works correctly; ABC ---> gives null</p>
  
  <p>My formula as below -</p>
  
  <pre><code>select SUBSTR('ABC_BAS',1,INSTR('ABC_BAS','_')-1) from dual;
  ABC
  
  select SUBSTR('ABC',1,INSTR('ABC','_')-1) from dual;
  (NULL)
  </code></pre>