Skip to main content
Log inGet a demo

How to Calculate a (MQL) Marketing Qualified Lead in SQL

Learn how you can calculate a marketing qualified lead in SQL.

Luke Kline.

Luke Kline

August 12, 2022

7 minutes

How to Calculate a (MQL) Marketing Qualified Lead in SQL.

There are more customer acquisition channels than ever before, and cycling through your leads can be challenging as you try to figure out which one’s to prioritize and which to nurture. To help you choose which leads to prioritize is precisely why it’s essential to qualify and define your leads.

What is an MQL?

A MQL is a lead created and owned by your marketing team that aligns with your ideal customer profile (ICP). At its core, an MQL is a qualified lead that has interacted with your brand in some capacity and has shown signs of becoming a paying customer. The goal of an MQL is to give your marketing team a tangible way to capture intent and qualify leads for your sales team using relevant behavioral data. In its simplest terms, an MQL represents the point in time that a lead is qualified to talk to your sales team.

This could be:

  • Adding an item to the cart
  • Viewing a product
  • Requesting a demo
  • Viewing your pricing page
  • Downloading a whitepaper
  • Subscribing to your newsletter
  • Interacting with more than five emails
  • Coming through a paid channel
  • Or coming from a referral

How to Define an MQL?

There are many different ways to define an MQL based on your business model and product offerings. Still, it would help if you based your MQL definition on key behavioral data you define. Specifically, you need to look at your previous customers’ historical, demographic, and behavioral data and their actions that led to them becoming paying customers. You need to analyze your demographic, historical, and behavioral data to do this.

  • Demographic data represents everything about your customer (e.g. job title, location, revenue, industry, employee count, etc.)

  • Historical data represents the key actions that your customers took to become a customer.

  • Behavioral data can be as simple as someone signing up for your newsletter, viewing a specific page on your website, downloading a resource, or even signing up for a free product trial.

These are just a few examples, but the criteria you define will differ from company to company.

To define your MQL definition, your marketing, sales, and product teams will need to align on the key attributes that create high-quality leads, and this means answering questions like:

  • What type of content (e.g., emails, websites, apps, whitepapers, etc.) does a lead need to engage with to become an MQL?
  • How many actions does a lead need to take to become an MQL?
  • What are the defining characteristics required to move a lead to an MQL?
  • What pain points/challenges need to be identified to convert a lead to an MQL?

Once you’ve ironed out your MQL definition, the final step is establishing a point scoring system to define an MQL. The easiest way to do this is simply to create a point scoring system for specific actions your leads take.

Perhaps you identified that users who signup for a free trial of your product are twice as likely to purchase an enterprise contract from your sales team, or maybe leads who open more than five marketing emails are more likely to book a demo with your sales team.

After you’ve defined the actions that make up your MQL definition, you can assign points to each specific event. For example, signups might be worth 25 points, while page views might only be worth five points. Only after a lead has accumulated enough points will it be converted to an MQL. Defining an MQL definition is actually very similar to lead scoring, so if you’re struggling to grasp these concepts, this post should help.

If a scoring system is too complicated, you could tag MQLs by specifying a set number of actions. You could easily define product signups or pricing page views as MQLs. Ultimately you need to revisit your MQL definition regularly to ensure it aligns with your business goals. You could even create levels for your MQLs to classify them further based on intent.

Why Do MQLs Matter?

Without a proper MQL definition, your sales team is just surfacing through an endless pile of leads that all look the same. MQLs create a clear handoff between your marketing and sales teams. Once you tag a lead as an MQL, your sales team can prioritize it and work to start nurturing that lead into a deal cycle. The ultimate goal of every MQL is to convert into a sales-qualified lead (SQL) eventually. In most cases, an SQL represents the first meeting booked, but much like MQLs, this definition can be more granular.

MQLs allow you to do more accurate forecasting and increase your revenue. For example, if you know that 25% of all MQLs convert to SQLs and only 33% of SQLs convert to paying customers, this can be extremely important when forming your go-to-market strategy.

What Are the Impacts MQLs?

A proper MQL definition enables your sales teams to personalize every aspect of the customer journey. Once you’ve classified a lead as an MQL you can automatically route that lead to the appropriate sales team.

From here, your SDR team can automatically enroll your MQLs in nurture sequences to qualify them further and lock down the first meeting to shift that lead from an MQL to an SQL. If your sales team cannot qualify for an MQL, it might make sense to hand that lead back over to marketing for re-engagement.

The largest benefit of MQLs is that they allow you to automate sales and marketing processes. With a proper MQL definition, you can rest assured that your leads are being nurtured through your sales pipeline.

Calculating MQLs Using SQL

All your customer data and key behavioral events already live in the warehouse, so the logical step is simply to define your MQL using SQLs.

First, you define all the events that a lead could do (ex: download a whitepaper, attend an event, etc) that signal intent. To do that, you’ll likely need to join your sales data (likely in your CRM like Salesforce or HubSpot) with your website/product analytics data (ex: Google Analytics, Segment, Amplitude, or Mixpanel events). Your data warehouse is the best place to join all that data together.

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 (
    min(created_date) as created_at 
    lead_source in (‘relevant lead sources’) = < relevant lead sources > 
    and email not like '' 
    and email not like '' 
  group by 

mqe_events as (
    * distinct event_id, 
    event_type in (‘List of events we care about’) = < List of events we care about >

priority_events_of_leads as (
    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.

  countCOUNT(*) as lead_score 
group by 

How to Implement MQLs

Since sales are the main team that benefits from MQLs, you’ll inevitably need a way to sync the data model that you’ve defined using to a new field called “MQL” in your CRM (e.g., Hubspot or Salesforce). In the past, moving data out of your warehouse required your data team to build entirely new pipelines and manage API integrations for every tool in your technology stack.

This is no longer the case, thanks to Reverse ETL platforms like Hightouch. Hightouch runs on top of your data warehouse and lets your leverage your existing data models or simple SQL to sync data to 100+ destinations. All you have to do is define your data and map it to the appropriate fields in your end destination. You can configure when, where, and how you want your syncs to run. Create a free Hightouch workspace today and start syncing your MQL model directly to your favorite business tools 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


Reverse ETL Category Leader


Marketplace Partner of the Year


Cool Vendor in Marketing Data & Analytics


Ecosystem Partner of the Year


Best Estimated ROI


One to Watch for Activation & Measurement


CDP Category Leader


Easiest Setup & Fastest Implementation

Activate your data in less than 5 minutes