HubSpot model

Closed won deals amount by owner

Retrieves the total amount of closed won deals for each owner in HubSpot and orders them in descending order.

Grain
See the notes
Built from
  1. 2
    Raw tables
  2. 1
    Core
  3. 1
    Analytics
Reads from HubSpot
dealsowners
Ships as
Weld and dbt SQL, open source on GitHub
core.hubspot.closed_won_deals_amount_by_owner
1-- core.hubspot.closed_won_deals_amount_by_owner
2-- Closed won deals amount by owner. Retrieves the total amount of closed won deals
3-- for each owner in HubSpot and orders them in descending order.
4--
5-- From the weld.app template library. Not reconciled against HubSpot;
6-- check the output against the source before relying on it.
7
8select
9concat(owners.firstName, ' ', owners.lastName) as deal_owner,
10sum(properties_amount) as amount
11from
12{{raw.hubspot.deals}} as deals
13left join {{raw.hubspot.owners}} as owners on cast(owners.id as int) = deals.properties_hubspot_owner_id
14where
15properties_dealstage = 'closedwon'
16group by
17deal_owner
18order by
19amount desc

This model and the 1 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

This SQL model allows you to easily track the amount of closed won deals by owner, giving you valuable insights into the performance of your sales team. By joining the HubSpot deals and owners tables, this SQL model creates a list of all closed won deals and the corresponding owner's name. The results are then grouped by owner and sorted by the total amount of closed won deals, allowing you to quickly identify your top-performing salespeople. This SQL template is an excellent way to measure the success of your sales team and identify areas for improvement.

Raw tables it reads

  • raw.hubspot.deals
  • raw.hubspot.owners

Put HubSpot in front
of your agents.

Connect HubSpot, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.