HubSpot has released HubSQL in developer beta, enabling teams to ask their CRM questions in SQL, the query language most analysts and data teams already use, and get a table of answers back.
Running it takes some technical setup, so most people will see the word "SQL," file it under developer tools, and move on. That’s a missed opportunity though, because the people who stand to gain the most are the ones asking the most questions of their data in HubSpot: sales leaders, marketing leaders, and RevOps teams who regularly need an answer HubSpot's reports can't quite give them.
We ran five experiments through HubSQL in our own HubSpot portal to find out how it would deliver for some use cases our team proposed — and we were very impressed with the results, and what they will mean at scale for organizations who take advantage of this tool.
Each example below starts with the business question, shows what came back, and then shows the query behind it for anyone who wants the detail. The results use placeholder names and sample figures, so the shape of each answer is real but the records are not.
There are two ways in. The deeper one, which this post is based on, is direct API access. HubSpot's AI-assistant connector (the one behind Breeze Assistant and Agent Studio) gets you most of the way there too, just by asking a connected assistant a plain-English question, no token, no developer required.
Until now, a reporting question the HubSpot report builder couldn't handle left you with three options:
HubSQL adds a third option: ask the question directly; that’s something we think is very exciting. The query runs against your HubSpot data where it already lives, and the answer comes back as a single table. Run it again next week, and you’ll get next week's numbers.
HubSQL doesn't do everything a warehouse does, but it answered all five experimental questions below without one.
The skill barrier is also lower than it looks. SQL has been the standard way to query data for decades, so your analysts may already write it, and your preferred AI assistants can turn a plain-English question into a working draft query.
One query returns every deal alongside its contact and company, in a single table you can sort and share.
A pipeline review usually needs three things side by side. Here's what HubSQL returned (first four rows of ten):
|
Deal |
Stage |
Amount |
Contact |
Company |
|
Example Deal 1 |
Closed won |
$18,500 |
contact1@example.com |
Example Company A |
|
Example Deal 2 |
Qualified to buy |
$4,200 |
contact2@example.com |
Example Company B |
|
Example Deal 3 |
Appointment scheduled |
$1,250 |
contact3@example.com |
Example Company C |
|
Example Deal 5 |
Presentation scheduled |
$27,300 |
contact5@example.com |
Example Company E |
Contacts and companies are only the start. A single query can join up to four objects (HubSQL allows three joins per query), so support tickets, projects, or custom objects such as billing or shipping records can sit in the same table.
Under the hood
SELECT dealname, dealstage, amount, CONTACT.email, COMPANY.name
FROM OBJECT.DEAL
LEFT JOIN OBJECT.CONTACT
LEFT JOIN OBJECT.COMPANY
WHERE CONTACT.email IS NOT NULL
In plain terms: return each deal's name, stage, and amount, add the email of its linked contact and the name of its linked company, and skip deals with no contact attached.
HubSQL can break the pipeline down by deal stage and company industry at the same time, even though industry lives on the company record and stage lives on the deal. HubSQL hands it back as one flat result, ready for a table, a bar chart, or wherever it needs to go next.
|
Deal stage |
Industry |
Deals |
|
Appointment scheduled |
Healthcare |
3 |
|
Appointment scheduled |
Logistics |
3 |
|
Qualified to buy |
Healthcare |
5 |
|
Qualified to buy |
Logistics |
3 |
|
Presentation scheduled |
Healthcare |
5 |
|
Closed won |
Logistics |
4 |
If your real numbers looked like this sample, you'd see healthcare deals piling up in the middle stages while every closed-won deal came from logistics. That's a question for sales coaching and for where marketing spends its next campaign budget.
Under the hood
SELECT dealstage, COMPANY.industry, COUNT(*) AS deal_count
FROM OBJECT.DEAL
LEFT JOIN OBJECT.CONTACT
LEFT JOIN OBJECT.COMPANY
WHERE COMPANY.name IS NOT NULL
GROUP BY dealstage, COMPANY.industry
In plain terms: bring in each deal's contact and company, keep only deals with a company attached, and count how many deals fall into each stage-and-industry combination.
HubSQL can count each deal once, even when a report links deals to several contacts.
When a report connects deals and contacts, a deal with three contacts can show up three times, inflating the count- a known, long-standing frustration in HubSpot's own Community. HubSQL sidesteps it entirely.
HubSQL handles it in the query. The sample below shows both numbers side by side: every row the join returns, and the number of distinct deals those rows represent.
|
Deal stage |
Rows returned |
Distinct deals |
|
Appointment scheduled |
9 |
6 |
|
Qualified to buy |
11 |
8 |
|
Presentation scheduled |
7 |
5 |
|
Closed won |
5 |
4 |
The gap between the two columns is double-counting. For a forecast or a board report, the right-hand column is the one you want.
One caveat: HubSpot's documentation notes that distinct counts become approximate at very large data volumes.
Under the hood
SELECT dealstage, COUNT(*) AS total_rows, COUNT(DISTINCT dealname) AS distinct_deals
FROM OBJECT.DEAL
LEFT JOIN OBJECT.CONTACT
GROUP BY dealstage
In plain terms: bring in each deal's contacts (which is what creates the duplicate rows), then count both the total rows and the distinct deals for each stage.
A single query shows the average number of logged sales activities per deal at each stage of the pipeline.
This is a question sales leaders ask all the time, and it's simpler than the first three. HubSpot already keeps a running activity count on every deal record, so the query doesn't need to join anything. One thing worth getting right here: a plain AVG() only averages the deals that have any activity logged, and silently leaves out every deal with none. That's standard SQL behaviour, but it can make a stage look far more active than it is. Dividing the total by every deal in the stage, instead, gives the honest per-deal number.
|
Deal stage |
Avg. activities per deal |
Deals |
|
Appointment scheduled |
2.3 |
6 |
|
Qualified to buy |
4.1 |
8 |
|
Presentation scheduled |
6.8 |
5 |
|
Closed won |
9.5 |
4 |
In our sample, most deals in the earlier stages had no logged activity at all, and the ones that did pulled the raw average up well past what was typical. That's a more useful finding for a sales manager than a smooth upward curve: it points at an activity-logging gap, not necessarily a pipeline trend, and it's the kind of thing a naive AVG() would hide rather than reveal.
Worth knowing: AVG() skips deals with nothing logged rather than counting them as zero - use SUM(property) / COUNT(*) when you want the true per-deal average.
Under the hood
SELECT dealstage, SUM(num_notes) AS total_activities, COUNT(*) AS deal_count
FROM OBJECT.DEAL
GROUP BY dealstage
In plain terms: for each stage, average the deal's logged sales activities and count how many deals are in that stage.
HubSQL groups deals by the month they were created and returns the trend as a plain table, ready to go wherever you need it.
Native reports can chart this one too, so the difference is in where the answer can go next. HubSQL returns its results through an API, which means the same query can feed any dashboard, or system on a schedule. Nobody has to export a CSV at the end of every month.
In our sample, the query returned one row per month from January through September 2026, with between two and six new deals a month. The same grouping works on other date fields, such as close date.
Under the hood
SELECT DATE_TRUNC(createdate, 'MONTH') AS month, COUNT(*) AS deal_count
FROM OBJECT.DEAL
GROUP BY month
In plain terms: round each deal's creation date down to its month, then count how many deals fall in each month.
HubSQL runs through HubSpot's API, using the same private app tokens as the rest of the CRM API. You scope each token to the objects you want to query (deals, contacts, companies, and so on), so there's no new permissions model to learn. You will need someone comfortable sending API requests, whether that's an in-house developer or a partner.
The bigger shift is in which questions are worth asking. Reports that used to mean exports and spreadsheet cleanup can come straight from your CRM, and they can be rerun whenever the numbers change. The cost of information, in terms of effort, has potentially gone way down.
If you'd rather skip the API route entirely, ask the question through a connected AI assistant instead- same engine, earlier checkpoint, no token needed. It's the lower-friction way to find out whether a question is worth building a proper query for.
If you want help getting started with HubSQL, talk to the Salted Stone team. Bring the reporting question your team keeps answering in a spreadsheet, and we’ll find a way to get you the answer you’re looking for directly in-platform.