Skip to main content
Log inGet a demo

How to calculate a SQL (Sales Qualified Lead) in SQL

Learn how you can calculate a sales qualified lead score in SQL.

Luke Kline

|

Aug 12, 2022

|

7 minutes

How to Calculate a SQL (Sales Qualified Lead) in SQL.

Intro

Qualifying the leads in your sales funnel and accurately forecasting your sales pipeline is often challenging. Knowing the likelihood of a customer converting is vital in informing your go-to-market strategy. Still, it’s also essential for defining your sales processes, which is precisely why you need a robust way to qualify your leads.

What is a SQL?

Sales qualified leads (SQLs) are leads who are ready to buy. SQLs represent users who have expressed interest and intent to purchase your product or service. In almost every scenario, all SQLs originate from marketing qualified leads (MQLs) or product qualified leads (PQLs) at some point. After all, the end goal of all lead generation is to create as many SQLs as possible as these have the highest potential of becoming potential customers.

How to Define a SQL

For most companies, you only tag SQLs after your outbound sales team has booked the first meeting. Once this happens, your account executives (e.g., your closing team) can look to facilitate further conversations with that contact and enter them into a deal cycle. When ironing out your SQL definition, you’ll want to analyze your pipeline’s existing deals/contacts and see what your current customers have in common. It’s probably worth analyzing your “closed-lost” deals to identify common trends. Usually, this means asking questions like:

  • What does your ideal customer profile (ICP) look like?
  • What are the biggest blockers that keep you from winning deals?
  • What do your current customers have in common?
  • What do your current lost deals have in common?

However, you also want to look at important items like:

  • Budget
  • Demo date
  • Last contact date
  • Phone calls
  • Emails sent
  • Statement of work (SOW)
  • Proof of concept (POC)
  • Job title
  • Revenue
  • Champions
  • Painpoints

While a simple SQL definition for “first meeting booked” might suffice your immediate needs, you can create a more accurate SQL definition using all your customer data.

After you’ve defined the key metrics you want to measure in your SQL definition, the following order of operations is simply to create a lead scoring system and assign points to both positive and negative attributes. For example, you might have a 2x conversion rate if a lead sits through a demo call, so you could assign +25 points to all leads who’ve met these criteria. Conversely, you might have a lower conversion rate if you haven’t identified your lead’s budget so that you could apply negative points in this case.

Why Do SQLs Matter?

SQLs are important because they establish clear guidelines for your sales team. Instead of basing the performance of your sales development team on the number of meetings they book, you can instead focus on the core metrics that they create SQLs and drive conversions.

Meetings booked aren’t always an accurate measurement of intent, so this ensures your sales development team focuses on generating high-quality leads rather than simply booking meetings that won’t translate into revenue. You can apply this same thought process to your sales directors and account executives to ensure their focus is on converting SQLs to tangible pipeline and revenue that you can measure on a quarterly/yearly basis.

What Are the Impacts of SQLs?

With a proper SQL definition, you can monitor your highest performing reps to see exactly what actions they are taking to create SQLs and close deals. Monitoring your highest-performing reps allows you to build standardized processes for your entire team and create more top performers.

SQLs also provide many benefits when it comes to automation. After a lead has taken enough actions to be tagged as an SQL, you can automatically route that user to the appropriate account executive and notify them in real-time to take action. In addition, you can build customized email sequences tailored explicitly to your SQLs’ actions. Your marketing team can also enroll your SQLs in drip campaigns to feed them continuous content and keep them engaged with your brand as they move through your sales funnel.

Calculating SQLs Using SQL

While it is possible to calculate your SQL definition in a tool like Hubspot or Salesforce, you’re usually forced to build and manage several new fields, which quickly becomes complex and time-consuming. And if you want to consider the factors you used to calculate your MQLs and PQLs, this is nearly impossible

In many cases, all the data you need already lives within your data warehouse, so the path of least resistance is simply using standard SQL to build your SQL definition. Here’s an example of how you could do this.

First, you’ll need to ETL your sales data (likely in your CRM like Salesforce or HubSpot) into your warehouse. From there, you can use all the sales data, joined with any other demographic data or 3rd party data you have on that customer to make SQL decisions.

You can also combine non-sales signals like marketing assets downloaded, product actions and more that exist in the warehouse. For example, here’s a subquery we use at Hightouch to pull all “marketing qualified events” that show intent. We first pull all relevant leads and intentionally exclude leads/signups from low-intent domains. Then we join those leads with event data.

with leads as (
  select 
    email, 
    min(created_date) as created_at 
  from 
    leads 
  where 
    lead_source in (‘relevant lead sources’) 
    and email not like '%hightouch.com' 
  group by 
    1
), 
mqe_events as (
  select 
    distinct event_id, 
    anonymous_id, 
    email, 
    event_time, 
    event_type, 
    event_index 
  from 
    events 
  where 
    event_type in (‘List of events we care about’)
), 
priority_events_of_leads as (
  select 
    mqe_events.* 
  from 
    mqe_events 
    join leads using (email)
),

Finally, we can use the COUNT() function to count how many unique events each lead has to give a basic lead score.

select 
  email, 
  count(*) as lead_score 
from 
  priority_events_of_leads 
group by 
  1

That’s it! You now have a basic lead score based on how many high intent actions a lead has done.

If we wanted to get fancier, we could assign “points” to each action/event based on intent (ex: booking a demo is much higher intent than just reading a blog post).

with lead_score_inputs as (
  select 
    id, 
    email, 
    -- creating score for email (simplified)
    case when email similar to '%(gmail|yahoo|outlook|hotmail)%' then -1 else 0 end as email_score, 
    -- creating score for visited pricing page
    case when viewed_pricing = TRUE then 1 else 0 end as pricing_page_score, 
    -- creating score for inviting other members to join
    case when invited_other_users = TRUE then 1 else 0 end as member_invitation_score, 
    -- creating score for daily activity
    case when daily_active = TRUE then 1 else 0 end as activity_score, 
  from 
    fct_users
) 
select 
  (
    email_score + pricing_page_score + member_invitation_score + activity_score
  ) as lead_score, 
  id, 
  first_name, 
  last_name, 
  email 
from 
  lead_score_inputs 
order by 
  1 desc;

How to Implement SQLs

After you’ve calculated your SQL definition in your data warehouse, the next step is simply to sync data to your CRM, which is precisely the problem Hightouch solves with Reverse ETL. Hightouch is a Data Activation platform that runs on top of your data warehouse.

With Hightouch, you can leverage the existing data models built in your warehouse and sync that data to 100+ different destinations without ever using a custom script, API, or CSV. You can even schedule your sync to run automatically every time your data updates in your warehouse. All you have to do is map your data to the appropriate fields in your end destination. To get started, sign up for a free Hightouch workspace today!


More on the blog

  • What is Reverse ETL? The definitive guide .

    What is Reverse ETL? The definitive guide

    Learn how Reverse ETL works, why it's different from traditional ETL, and how you can use it to activate your data.

  • Friends don’t let friends buy a CDP.

    Friends don’t let friends buy a CDP

    How spending the first half of his professional career at Segment drove Tejas Manohar to disrupt the 3.5 billion dollar CDP category.

  • What is a Composable CDP?.

    What is a Composable CDP?

    Learn why Composable CDPs are seeing such rapid adoption, how they work, and why they're replacing traditional CDPs.

Recognized as an industry leader by industry leaders

Iterable logo.

Technology Partner
of the Year