Oracle sql 11g - Can an nvl2 function include a select statement?
<p>Not even sure <code>nvl2</code> is what I should be using, but it seems to make sense to me.  If I could get the select to work.  The data below is not the actual, but as close as I can get with imagined objects:</p>

<p>I tried to post this with a full case of two tables and one view, but I kept getting 'an error occurred while posting', so I thought I would try without any test data....  There are two tables - <code>t1</code> and <code>t2</code> -- that hold columns of 'name', 'style', 'color', and 'doors'.</p>

<p>.. they each have several rows of data where everything is equal and several rows that do not match.  If 'name' and 'doors' are both equal, I need the color in the view to be whatever the color is in t1.  If 'name' and 'doors' do not match, I need the color in the view to read 'orange' </p>

<p>I tried creating in the view select statement an <code>nvl2</code> function with a select statement determining the first value</p>

<pre><code>nvl2(color, (select color from t1 where t1.style = t2.style and t1.doors = t2.doors), orange)
</code></pre>

<p>Can an <code>nvl2</code> function contain a select?  Have I gone about it wrongly, and if so, what should I use in the stead of an nvl2 function?</p>