title: Convert to CHAR value in a CASE statement that returns different data types
body: <p>I have a working query as follows:</p>
  
  <pre><code>    SELECT DISTINCT col1, col2, 
      CASE 
      WHEN COUNT(DISTINCT col3_typeID) OVER (PARTITION BY col1) = 1
      THEN col3_typeID   &lt;-- this is what interests me
  
      WHEN COUNT(DISTINCT col3_typeID) OVER (PARTITION BY col1) &gt; 1
      THEN COUNT(DISTINCT col3_typeID) OVER (PARTITION BY col1)
      END 
      COUNT(col4) OVER (PARTITION BY col1)
      FROM table
    -- joins
    -- other conditions
  </code></pre>
  
  <p>I count something, and if <code>COUNT() = 1</code>, then I return an <code>ID</code> instead of a number of those IDs. Ideally, I'd like to return the CHAR value of that <code>ID</code>. If I attempt to replace the marked line above with a column of type <code>CHAR</code>, I get</p>
  
  <pre><code>ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 
  </code></pre>
  
  <p>I've also tried <code>DECODE()</code> as :</p>
  
  <pre><code> THEN DECODE(col3_typeID, 1 , 'type1'
                           2,  'type2' )
  </code></pre>
  
  <p>But I get the same error, naturally, as this is a basic datatype restriction.</p>
  
  <p>Is there a solution to this? </p>