title: oracle: decode and subquery select result
body: <p>I have a oracle query and part of it is calculating some value using DECODE.  For example:</p>
  
  <pre><code>SELECT ..., 
        (SELECT DECODE((SELECT 23 FROM DUAL), 
                        0, null,
                       (SELECT 23 FROM DUAL))  
           FROM DUAL) 
    FROM ...
  </code></pre>
  
  <p>Here the value "23" gets calculated at runtime, and it's quite complicated joins - multiple tables, uses <code>PARTITION BY</code> etc.  So I want to  avoid executing the same subquery if the value is not "0". Is there any way to write something like this </p>
  
  <pre><code>SELECT ..., 
         (SELECT DECODE ((SELECT 23 FROM DUAL) as test, 
                          0, null,
                         test)  
           FROM DUAL) 
    FROM ...
  </code></pre>