Closed won deals amount by owner
1select
2 concat(owners.firstName, ' ', owners.lastName) as deal_owner
3 , sum(properties_amount) as amount
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 amount desc
+------------------+----------+
| deal_owner | amount |
+------------------+----------+
| John Smith | 50,000 |
+------------------+----------+
| Jane Doe | 30,000 |
+------------------+----------+
| Bob Johnson | 20,000 |
+------------------+----------+
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.