Weld logo

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.

Source
HubSpot
Level
Beginner
Reads
raw.hubspot.engagements, raw.hubspot.owners
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 output

+ ------------------+-----------------+
| 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.

Browse every HubSpot SQL template, or all templates.