title: teradata SQL tuning pundits - SELECT Failed. 3771: Illegal expression in WHEN clause of CASE expression
body: <p>I am using a statement as below and get this error:</p>
  
  <blockquote>
    <p>SELECT Failed. 3771:  Illegal expression in WHEN clause of CASE
    expression.</p>
  </blockquote>
  
  <p>I had better hopes from Teradata.  SQL Server can do it but Teradata can't.
  How can I work around this?  Any solution?</p>
  
  <pre><code>sel ( CASE
      WHEN  EXISTS   ( sel '1' from VolatileTable Dtb1 where Dtb1.c1=FACT_Table_5MillionRows.C1)
      THEN "FACTTablew5MillionRows"."CustomColumName" 
  ELSE 'ALL OTHER'
  END  ) (NAMED "CustomColumName" )
  
  from
  "Db"."FACTTablew5MillionRows" 
  </code></pre>