Sales to Date versus Last Month

Salesforce

 

Salesforce is the most popular cloud CRM with a focus on sales and support. Skyvia requires Salesforce Enterprise edition or higher.

Total of sales to date for this month (for example, June 2015) versus last month (for example, May 2015)

Query Text

SELECT strftime('%d', o."CloseDate") 'Day',
       SUM(case when (strftime('%Y-%m', o."CloseDate") = '2015-05') then ifnull(o."Amount",0) else 0 end) 'Amount (Prev Month)',
       SUM(case when (strftime('%Y-%m', o."CloseDate") = '2015-06') then ifnull(o."Amount",0) else 0 end) 'Amount (Current Month)'
 FROM "Opportunity" o
 WHERE o."IsClosed"=true AND
       o."IsWon"=true AND
       o."CloseDate">='2015-05-01' and o."CloseDate"<='2015-06-30'
 GROUP BY strftime('%d', o."CloseDate")
  

Open Query