This query sums the total amount from opportunities grouped by type. A total is displayed at the bottom
SELECT
"type",
SUM("amount") AS "amount",
COUNT(*) AS "opps"
FROM
public.salesforce_opportunity
WHERE
DATE_TRUNC('quarter', "closedate") = DATE_TRUNC('quarter', CURRENT_DATE)
AND stagename = 'Closed Won'
GROUP BY
1
UNION ALL
SELECT
'Total' AS "type",
SUM("amount") AS "amount",
COUNT(*) AS "opps"
FROM
public.salesforce_opportunity
WHERE
DATE_TRUNC('quarter', "closedate") = DATE_TRUNC('quarter', CURRENT_DATE)
AND stagename = 'Closed Won'
ORDER BY
amount
Column | Description |
---|---|
type |
Opportunity type |
amount |
Sum of the opportunity amount |
opps |
Opportunity count |