title: SQL View - Nesting SELECT?
body: <p>I am trying to create a view from the following table.  I'm looking for the output to be the CUSTOMER, the most recent or MAX(CALENDARDT) for that CUSTOMER and a SUM(QTY) field, for all records that have the same CCYYMM field as the MAX(CALENDARDT) record.</p>
  
  <p>Expected result would be </p>
  
  <pre><code>1500627 03/25/2013 5 
  </code></pre>
  
  <p>5 being the sum of the qty field for the last two records both with 201303 in the CCYYMM field</p>
  
  <pre><code>Customer  |CCYYMM   |CalendarDt|DocNumb|Qty
  1500627 |201202 |02/01/2012|Z201202|0
  1500627 |201203 |03/02/2012|2542484|7
  1500627 |201205 |05/04/2012|2979222|3
  1500627 |201206 |06/20/2012|3262548|2
  1500627 |201207 |07/31/2012|3500794|1
  1500627 |201208 |08/30/2012|6946730|1
  1500627 |201209 |09/13/2012|3774092|1
  1500627 |201210 |10/31/2012|4063932|3
  1500627 |201211 |11/16/2012|Z201211|0
  1500627 |201301 |01/04/2013|Z201301|0
  1500627 |201301 |01/30/2013|Z201301|0
  1500627 |201303 |03/01/2013|4876779|1
  1500627 |201303 |03/25/2013|5044331|4
  </code></pre>