title: Oracle SQL Invalid Number Error with Strings
body: <p>I have a query like this... </p>
  
  <pre><code>SELECT 1,2,3 
  FROM (SELECT CASE WHEN something THEN TO_CHAR(1)... END,2,3 
        FROM tables WHERE condtions) 
        WHERE 1 NOT LIKE 'String'
  </code></pre>
  
  <p>All columns are varchar2, I get a Invalid Number error with this query, pointing to the inner case statement. The inner query runs fine seperately.. the entire query runs fine if I remove the outer WHERE condtion.</p>
  
  <p>I understand this has to do something with the SQL Optimizer, but what am I doing wrong here and how can I get around this? Using To_CHAR for the String or outer select statement aren't working...</p>
  
  <hr>
  
  <p>Updating for Better understanding,</p>
  
  <pre><code>SELECT COL1, COL2, COL3 FROM (
  SELECT CASE WHEN LOGIC THEN TO_CHAR(1) ELSE TO_CHAR(0) END AS COL1, 
  COUNT(SOME_COL) AS  COL2 , COUNT(SOME_COL2) AS COL3 FROM TABLES WHERE CONDTIONS
  ) WHERE COL1 NOT LIKE ‘0’
  </code></pre>
  
  <p>I was told the Oracle SQL Optimizer is interfering and causing the above stated error and that the query has to be written in a different way. </p>