HubSpot model

Deals by deal stage

Retrieves the number of deals in each stage of the sales pipeline from HubSpot and groups them by their respective stage labels.

Grain
See the notes
Built from
  1. 2
    Raw tables
  2. 1
    Core
  3. 1
    Analytics
Reads from HubSpot
dealspipeline_stage
Ships as
Weld and dbt SQL, open source on GitHub
core.hubspot.deals_by_deal_stage
1-- core.hubspot.deals_by_deal_stage
2-- Deals by deal stage. Retrieves the number of deals in each stage of the sales
3-- pipeline from HubSpot and groups them by their respective stage labels.
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
9pipeline_stage.label as deal_stage
10, count(*) as number_of_deals
11from
12{{raw.hubspot.deals}} as deals
13left join {{raw.hubspot.pipeline_stage}} as pipeline_stage on pipeline_stage.stage_id = properties_dealstage
14group by
15pipeline_stage.label

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 number of deals in each stage of your sales pipeline. By selecting the pipeline_stage.label as deal_stage and counting the number of deals, you can quickly see how many deals are in each stage of your pipeline. This information can be incredibly useful for sales managers who want to identify bottlenecks in their sales process and make data-driven decisions to improve their team's performance. The SQL code is integrated with HubSpot, so you can easily access your data and generate insights that will help you close more deals. With the Deals by Deal Stage SQL template, you can take your sales pipeline management to the next level and drive more revenue for your business.

Raw tables it reads

  • raw.hubspot.deals
  • raw.hubspot.pipeline_stage

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.