HubSpot SQL templates
12 ready-to-run SQL models for HubSpot data in your own warehouse. Each one runs as-is against your synced tables, in Weld SQL or dbt.
New companies by month
Retrieves a list of new companies created each month from the HubSpot integration and groups them by month. The results are ordered by month.
Beginner
Closed won deals by owner
Retrieves the number of closed won deals by owner from HubSpot and orders them in descending order based on the number of deals.
Beginner
Closed lost deals by owner
Retrieves the number of closed lost deals by owner from HubSpot and orders them by the highest number of deals. It uses a left join to match the owner ID from the deals table to the owners table and concatenates the first and last name of the owner for readability.
Beginner
Closed won deals amount by owner
Retrieves the total amount of closed won deals for each owner in HubSpot and orders them in descending order.
Beginner
Emails by owner
Retrieves the number of emails sent by each owner in HubSpot by joining the engagements and owners tables and grouping the results by owner.
Beginner
New deals by month
Retrieves the number of new deals created each month from HubSpot and organizes them by month.
Beginner
Calls by owner
Retrieves the number of calls made by each owner in HubSpot and displays it alongside their first and last name. It uses a left join to connect the engagements and owners tables and filters the results to only include calls. The output is grouped by owner.
Beginner
Meetings by owner
Retrieves the number of meetings organized by each owner in HubSpot and displays it alongside their first and last name. It uses a left join to connect the engagements and owners tables and filters the results to only include meetings. The output is grouped by owner.
Beginner
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.
Beginner
Deals by deal stage
Retrieves the number of deals in each stage of the sales pipeline from HubSpot and groups them by their respective stage labels.
Beginner
Conversion from contacts to deals by owner
Converts contacts to deals by owner in HubSpot, displaying the owner's name, the number of contacts they have, the number of deals they have, and the conversion rate between the two. It uses left joins to connect the necessary tables and groups the results by owner.
intermediate
New contacts by month
Retrieves the number of new contacts added to HubSpot each month and groups them by month. It uses the date_trunc function to extract the month from the createdAt field and orders the results by month.
Beginner
Or browse templates for every connector.