Sales By Accounts (by quarters)

Salesforce

 

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

Sales By Accounts (by quarters)

Query Text

  SELECT a."Name" 'Account Name', 
        SUM(case when (o."FiscalQuarter"=1 and o."FiscalYear"=strftime('%Y','now')) then o."Amount" else 0 end) 'Q1 Amount',
        SUM(case when (o."FiscalQuarter"=2 and o."FiscalYear"=strftime('%Y','now')) then o."Amount" else 0 end) 'Q2 Amount',
        SUM(case when (o."FiscalQuarter"=3 and o."FiscalYear"=strftime('%Y','now')) then o."Amount" else 0 end) 'Q3 Amount',
        SUM(case when (o."FiscalQuarter"=4 and o."FiscalYear"=strftime('%Y','now')) then o."Amount" else 0 end) 'Q4 Amount',
        SUM(case when (o."FiscalYear"=strftime('%Y','now')) then o."Amount" else 0 end) 'Q1-Q4 Amount SUM'
  FROM "Opportunity" o, "Account" a
  WHERE o."IsWon"=true AND
        o."IsClosed"=true AND
        o."AccountId"= a."Id"
  GROUP BY o."AccountId"
  ORDER BY SUM(o."Amount") DESC
  

Open Query