title: Order total sales by month
body: <p>I am printing out the total sales for each state so long as they have over $6000 in sales for that month. The results need to be ordered by month(descending order). I noticed that I got 2 results for Texas for the same month. So what that tells me is it is just looking for individual sales over $6,000 even though I have a sum(so.total) which I thought would give the total sales for state ordered by the month. Not sure how to break down the sales by each individual month if the order_date field has day-month-year in it.(Using Oracle 10g)</p>
  
  <p>Input:</p>
  
  <pre><code> SELECT c.state "State",to_char(so.order_date, 'Month')"Month", sum(so.total)"Sales"
   FROM a_customer c
   JOIN a_sales_order so ON c.customer_id=so.customer_id
   GROUP BY c.state, so.order_date
   HAVING sum(so.total)&gt;6000
   ORDER BY to_char(so.order_date, 'MM') desc
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>State Month        Sales
  ----- --------- --------
  TX    September   $8,400 
  CA    July        $8,377 
  TX    March       $7,700 
  TX    March       $8,540 
  CA    February   $46,370 
  MN    February    $6,400 
  CA    February   $24,650 
  </code></pre>