Weld logo
hubspot logo
Hubspot

Tasks completed by owner

Retrieves the number of completed tasks for each owner in HubSpot, using a left join between the engagements and owners tables. The result includes the owner's first and last name, as well as the count of completed tasks.
1select
2    concat(owners.firstName, ' ', owners.lastName) as owner
3  , count(*) as tasks_completed
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 = 'TASK'
9    and json_value(metadata, ' .status') = 'COMPLETED'
10group by
11    owner
Example of output from model:
+------------------+-----------------+
|      owner       | tasks_completed |
+------------------+-----------------+
| John Smith       | 10              |
| Jane Doe         | 5               |
| Michael Johnson  | 3               |
| Sarah Williams   | 8               |
+------------------+-----------------+

This SQL model allows you to easily track the number of completed tasks for each owner in your organization. By joining the engagements and owners tables, the SQL code creates a list of owners and the number of tasks they have completed. This information can be used to identify top performers, track progress towards goals, and identify areas where additional support may be needed. The output of this SQL code is a table that displays the owner's name and the number of tasks they have completed. This SQL template is a valuable tool for any business looking to optimize their sales process and improve team performance.

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.