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.
- Grain
- See the notes
- Built from
- 2Raw tables
- 1Core
- 1Analytics
- Reads from HubSpot
- engagementsowners
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.hubspot.tasks_completed_by_owner
2-- Tasks completed by owner. Retrieves the number of completed tasks for each owner
3-- in HubSpot, using a left join between the engagements and owners tables. The
4-- result includes the owner's first and last name, as well as the count of
5-- completed tasks.
6--
7-- From the weld.app template library, corrected. Not reconciled against
8-- HubSpot; check the output against the source before relying on it.
9
10select
11concat(owners.firstName, ' ', owners.lastName) as owner
12, count(*) as tasks_completed
13from
14{{raw.hubspot.engagements}} as engagements
15left join {{raw.hubspot.owners}} as owners on cast(owners.id as integer) = engagements.ownerId
16where
17type = 'TASK' and
18json_value(metadata, '$.status') = 'COMPLETED'
19group by ownerThis model and the 1 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
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.
Raw tables it reads
- raw.hubspot.engagements
- raw.hubspot.owners
Put HubSpot in front
of your agents.
Connect HubSpot, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.