Emails by owner
1select
2 concat(owners.firstName, ' ', owners.lastName) as owner
3 , count(*) as emails
4from
5 {{raw.hubspot.engagements}} as engagements
6 left join {{raw.hubspot.owners}} as owners on cast(owners.id as integer) = engagements.ownerId
7where
8 type = 'EMAIL'
9group by
10 owner
+------------------+--------+
| owner | emails |
+------------------+--------+
| John Smith | 25 |
| Jane Doe | 18 |
| Michael Johnson | 12 |
| Sarah Williams | 8 |
| Robert Brown | 5 |
+------------------+--------+
This SQL model allows you to easily retrieve the number of emails sent by each owner in your HubSpot account. By joining the engagements and owners tables, this SQL template creates a comprehensive report that includes the first and last name of each owner, as well as the total number of emails they have sent. This information can be used to gain insights into the performance of your sales team, identify top performers, and optimize your email marketing strategy. With the Emails by Owner SQL template, you can quickly and easily analyze your email engagement data and make data-driven decisions to improve your business.