Weld logo
hubspot logo
Hubspot

Closed won deals by owner

Retrieves the number of closed won deals by owner from HubSpot and orders them in descending order based on the number of deals.
1select
2    concat(owners.firstName, ' ', owners.lastName) as deal_owner
3  , count(*) as number_of_deals
4from
5    {{raw.hubspot.deals}} as deals
6    left join {{raw.hubspot.owners}} as owners on cast(owners.id as int) = deals.properties_hubspot_owner_id
7where
8    properties_dealstage = 'closedwon'
9group by
10    deal_owner
11order by
12    number_of_deals desc
Example of output from model:
+------------------+----------------+
| deal_owner       | number_of_deals|
+------------------+----------------+
| John Smith       | 25             |
| Jane Doe         | 18             |
| Michael Johnson  | 12             |
| Sarah Williams   | 9              |
| David Lee        | 7              |
+------------------+----------------+

This SQL model allows you to easily track the number of closed won deals by each owner in your organization. By running this SQL, you can quickly gain insights into which sales reps are performing the best and which ones may need additional support. The SQL code uses a left join to combine data from the HubSpot deals and owners tables, and then filters the results to only show deals that have been marked as "closedwon". The output of the SQL is a table that displays the name of each deal owner and the number of closed won deals they have. This information can be used to identify top performers, set sales goals, and optimize your sales process.

Ready to start modeling your own hubspot data?

Get started building your data warehouse with hubspot and connect all your apps and databases.

hubspot logo
Weld logo
Sign up for free
© 2024 Weld. All rights reserved.