title: How to get last month sale and this month sale in sql server 2008
body: <p>How to get last month sale and this month sale in sql server 2008
  Here my table structure is:</p>
  
  <pre><code>DailyDispatchID int Unchecked 
  Name    varchar(50) Checked
  Qty int Checked
  Month   varchar(50) Checked
  </code></pre>
  
  <p>i tried this:</p>
  
  <pre><code>SELECT *
  FROM   (SELECT Name,
                 Gas,
                 Qty,
                 Month
          FROM   DailyDispatch) AS s
         PIVOT (Sum(QTY)
               FOR [month] IN(aug,
                              sep)) AS P 
  </code></pre>
  
  <p>i am getting the output,but its taking only from August and September monthly only. it should generate automatically this month and previous sales. how to sort out this., </p>