title: Dynamically SELECT a column based on value of row at first of month
body: <p>The following query:</p>
  
  <pre><code>  SELECT Confirmed, Interim, Declared, Date    
      FROM Interest_Hist                         
     WHERE Date BETWEEN '2019-08-01' AND '2019-12-04'          
  ORDER BY Date ASC
  </code></pre>
  
  <p>Returns the following sample data:</p>
  
  <pre><code>Confirmed   Interim   Declared   Date
  Y           0.314     0.0788     2019-08-01
              0.317     0          2019-08-02
  ...
              0.245     0          2019-08-31
              0.222     0.219      2019-09-01
              0.198     0          2019-09-02
  ...
  Y           0.50      0.454      2019-12-01
              0.51      0          2019-12-02
              0.52      0          2019-12-03
              0.53      0          2019-12-04
  </code></pre>
  
  <p>Where on the first of the month, <code>Confirmed</code> = Y, I need to return the <code>Declared</code> column for that month. </p>
  
  <p><em>Note, <code>Confirmed = Y</code> will only exist on the first of the month.  That column is blank in all other cases</em></p>
  
  <p>Otherwise, I need to return each <code>Interim</code> column for the month.</p>
  
  <p>Thus far, I have been able to return the <code>SUM</code> of either column, but not the individual values.</p>
  
  <pre><code>SELECT                                                                   
     CASE WHEN SUM(CASE WHEN IRc_Confirmed = 'Y' THEN 1 ELSE 0 END) = 0   
       THEN Interim                                     
       ELSE Declared                                     
    END AS Rate                                                    
   FROM Fund_Interest                                                
  WHERE Date BETWEEN '2019-08-01' AND '2019-12-04'           
  GROUP BY                                                                   
    DATEADD(month, DATEDIFF(month, 0, Date), 0), Interim, Declared                 
  ORDER BY                                                                   
    DATEADD(month, DATEDIFF(month, 0, Date), 0) 
  </code></pre>
  
  <p><strong>The expected output given the data at the top is as follows</strong></p>
  
  <pre><code>0.0788
  0
  ...
  0
  0.222
  0.198
  ...
  0.454
  0
  0
  0
  </code></pre>