title: SQL: Return Expressions from SQL CASE statement
body: <p>Thanks in Advance, i use an oracle 10g. In SQL case statement we pass the value and check the case according to value and return string. But instead of returning String, i want to return an expression. Is this is possible using oracle SQL query CASE statement for returning an expression? I do the following and oracle generate an error <code>ORA-00905:Missing Keyword</code></p>
  
  <pre><code>SELECT ECL_CONTROL,
    CASE 
      WHEN ECL_CONTROL = 'N' THEN ('##0') = ('##0')
      WHEN ECL_CONTROL = 'Y' THEN (NVL(IL.ECL, 'X') = NVL(IM.ECL, 'X'))
    END
  FROM ITEM_CONTROL WHERE ITEM_NO =  '2N2907A' 
  </code></pre>
  
  <p>But The following run successfully : </p>
  
  <pre><code>SELECT ECL_CONTROL,
    CASE 
      WHEN ECL_CONTROL = 'N' THEN 'test'
      WHEN ECL_CONTROL = 'Y' THEN 'demo'
    END
  FROM ITEM_CONTROL WHERE ITEM_NO =  '2N2907A'
  </code></pre>
  
  <p>I want to use this query as the inner query and return and expression for outer query. My query is following : </p>
  
  <pre><code>SELECT  LSM.ACTIVE_FLAG, LSM.ITEM_NO, IL.ECL, LSM.SERIAL_NO, IL.WAREHOUSE, IL.BIN, LSM.TOOL_STATUS_CODE,
  LLG.NEXT_CAL_DATE, IM.PRODUCT_GROUP
  FROM LS_SERIAL_MASTER LSM, LS_LIFE_LOG LLG, ITEM_LOCATION IL, ITEM_MASTER IM
  WHERE   IL.PLANT = IM.PLANT AND IL.ITEM_NO = IM.ITEM_NO 
  AND IM.PLANT = LSM.PLANT AND IM.ITEM_NO = LSM.ITEM_NO AND NVL(IM.PRODUCT_GROUP, 'X') =    NVL('PUMP', 'X')
  AND LSM.PLANT = LLG.PLANT AND LSM.ITEM_NO = LLG.ITEM_NO AND LSM.SERIAL_NO = LLG.SERIAL_NO
  AND LSM.LIFE_TRANS_ID = LLG.TRANS_ID AND LLG.SERIAL_NO = IL.SERIAL_NO
  AND (SELECT ECL_CONTROL,
    CASE ECL_CONTROL
      WHEN ECL_CONTROL = 'N' THEN ('##0' = '##0')
      WHEN ECL_CONTROL = 'Y' THEN (NVL(IL.ECL, 'X') = NVL(IM.ECL, 'X'))
    END AS ECL_CONTROL_TXT
    FROM ITEM_CONTROL WHERE ITEM_NO =  '2N2907A')
  AND LLG.MAINT_LMT_ID IN('T', 'U')
  AND LLG.NEXT_CAL_DATE BETWEEN TO_DATE('02/1/2014', 'MM/DD/YYYY') AND TO_DATE('02/11/2014', 'MM/DD/YYYY').
  </code></pre>
  
  <p>My actual task is return an expression from inner query and used in outer query. </p>