title: I can't get data in previous months in MySQL
body: <p>I have this MySQL Query to display the current month and the 2 previous months according to my selection. For example, I choose in my date picker the date range 2011-10-01 to 2011-10-31 (October), it will display the October and the previous two months.  I have this SQL query but it only displays data on the current month which is October but not the previous month.</p>
  
  <pre><code>SELECT jp.JO_partner_ID,ss.first_name as SS, ssa.first_name as SSA 
  ,count(CASE WHEN jp.receivedDate between DATE_SUB('2011-10-01', INTERVAL 2 MONTH) 
  and DATE_SUB('2011-10-31', INTERVAL 2 MONTH) THEN jp.job_order_number ELSE null END) As aug 
  ,count(CASE WHEN jp.receivedDate between DATE_SUB('2011-10-01', INTERVAL 1 MONTH) 
  and DATE_SUB('2011-10-31', INTERVAL 1 MONTH) THEN jp.job_order_number ELSE null END) As sep 
  ,count(CASE WHEN jp.receivedDate between '2011-10-01' 
  and '2011-10-31' THEN jp.job_order_number ELSE null END) As oct 
  ,count(case WHEN (jp.receivedDate between '2011-10-01'and '2011-10-31' and      jo.job_order_type LIKE 'IT') then jp.job_order_number else null end) as IT 
  ,count(case WHEN (jp.receivedDate between  '2011-10-01' and '2011-10-31' and jo.job_order_type LIKE 'Non-IT') then jp.job_order_number else null end) as NonIT 
  ,count(jp.job_order_number) As Total FROM jo_partner jp 
  left join specialist_partner sp on jp.JO_partner_ID = sp.specialistPartnerID 
  left join staffing_specialist_asst ssa on jp.SSA_ID = ssa.SSA_ID 
  left join staffing_specialist ss on jp.SS_ID = ss.SS_ID 
  left join job_order jo on jp.job_order_number = jo.job_order_number 
  left join candidate_jo cjo on jp.JO_partner_ID= cjo.jo_partner_ID 
  left join candidate can on cjo.candidate_jo_ID= can.candidate_ID 
  WHERE jp.receivedDate BETWEEN '2011-10-01' AND '2011-10-31'
  GROUP BY ss.SS_ID; 
  </code></pre>
  
  <p>here is the screenshot of my result:
  <a href="http://www.fileden.com/files/2011/7/27/3174077//3.JPG" rel="nofollow">http://www.fileden.com/files/2011/7/27/3174077//3.JPG</a></p>
  
  <p>Can anyone help to correct my SQL or simplify???? thanks...</p>