top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Preferential Ranking: Turning Data into Actionable Priority

Jan 14
4 min read

When you work with a large number of customers, one common challenge quickly emerges:

Who should be handled first?

In real business scenarios, you’re rarely prioritizing based on just one factor. A customer might be very active but not loyal. Another might be loyal but inactive. Someone else might have a high balance but very low engagement.

You might want to prioritize customers who are:

  • More active

  • Recently engaged

  • Long-term and loyal

  • High priority or high urgency

The problem is simple but important:If you sort by only one column, you miss the full picture.

That’s exactly where Preferential Ranking becomes powerful.


What Is Preferential Ranking?

Preferential Ranking is a method of ranking records using multiple rules applied in a strict order until all ties are resolved.

Think of it as a decision ladder:

  • Start with the most important rule

  • If there’s a tie, move to the next rule

  • Continue step by step until one record clearly wins

Instead of forcing everything into a single score, preferential ranking respects business priorities in the order they matter.


Why Preferential Ranking Matters

Preferential ranking helps you:

  • Make fair and defensible decisions

  • Apply consistent and repeatable logic

  • Clearly explain why someone ranks higher

  • Prioritize customers based on real business value

  • Avoid bias, gut feeling, and guesswork

Rather than asking “Who has the highest value?”, you’re answering:

“Who deserves attention first — and why?”

That shift makes all the difference.


Reference Dataset (Designed for Learning)

To make the concept easy to understand, I created a reference dataset for January and February, intentionally designing many customers to share the same values.

This forces the ranking logic to work exactly as intended.

In January, there are 16 customers who all share the maximum priority score of 98.

At this point, a simple sort fails — everyone looks identical.

So we introduce ordered business rules.



The Preferential Ranking Rules

Customers are ranked within each month using the following order:

  1. priority_score → higher is better

  2. activity_count → higher is better

  3. recent_interactions → higher is better

  4. relationship_years → higher is better

  5. age → higher is better

  6. outstanding_balance → lower is better

In plain language:

If two customers tie on rule 1, move to rule 2.If they still tie, move to rule 3.Continue until one customer wins.

This ordered logic is the heart of preferential ranking.


Step-by-Step: How the Ranking Actually Works


Step 1: Priority Score

All 16 customers have:

  • priority_score = 98

No one is eliminated here.


Step 2: Activity Count

Customers now split naturally:

  • Activity = 18 → Customers 1–10

  • Activity = 17 → Customers 11–12

  • Activity = 16 → Customers 13–14

  • Activity = 15 → Customers 15–16

Since higher activity wins:

  • Customers 1–10 rank above 11–16

  • Customers 11–12 rank above 13–16, and so on


Step 3: Recent Interactions (Among Activity = 18)

Within Customers 1–10:

  • Recent = 8 → Customers 1–9

  • Recent = 7 → Customer 10

Customer 10 loses here and drops below Customers 1–9 — regardless of balance, age, or loyalty.

This highlights a key principle:

Once a customer loses on a higher-priority rule, lower rules no longer matter.

Step 4: Relationship Years

Customers 1–9 now split again:

  • 12 years → Customers 1–7

  • 10 years → Customers 8–9

Customers 1–7 move ahead.


Step 5: Age

Among Customers 1–7:

  • Age = 75 → Customers 1–5

  • Age = 70 → Customers 6–7

Even though Customers 6 and 7 may have lower balances, they lose here due to age.

Critical lesson:

A strong value in a lower-priority column cannot override a loss in a higher-priority one.

Step 6: Outstanding Balance (Final Tie-Breaker)

Only Customers 1–5 remain tied.

Balances decide the final order:

Customer

Balance

Rank

1

200

1

2

210

2

3

220

3

4

230

4

5

240

5

Lower balance wins.


What Happens to the Other Customers?

Each customer drops exactly at the rule where they first differ:

  • Customers 6–7 lose on age

  • Customers 8–9 lose on relationship years

  • Customer 10 loses on recent interactions

  • Customers 11–12 lose on activity count

  • Customers 13–16 fall further as engagement and loyalty decrease

Nothing is random. Every rank is explainable.


The SQL Query That Does All the Work

WITH Ranked AS (
    SELECT
        customer_id,
        month_start,
        priority_score,
        activity_count,
        recent_interactions,
        relationship_years,
        age,
        outstanding_balance,
        ROW_NUMBER() OVER (
            PARTITION BY month_start
            ORDER BY
                priority_score DESC,
                activity_count DESC,
                recent_interactions DESC,
                relationship_years DESC,
                age DESC,
                outstanding_balance ASC
        ) AS preference_rank
    FROM master_data
)
SELECT *
FROM Ranked
WHERE preference_rank = 1
ORDER BY month_start, preference_rank;

This query:

  • Resets ranking every month

  • Applies each rule in the correct business order

  • Assigns a unique rank to every customer

  • Returns the top-priority customer per month

From the output:

we can see customer 1 has the rank 1 in the month of January and  customer 31 has the rank 1 in the month of February.

Why Preferential Ranking Works So Well

Preferential Ranking is:

  • Fair → same rules for everyone

  • Transparent → every decision is explainable

  • Scalable → works for thousands or millions of records

  • Business-aligned → respects real priorities

  • Easy to automate → SQL does the heavy lifting

Common use cases include:

  • Customer prioritization

  • Lead scoring

  • Risk modeling

  • Collections strategy

  • Engagement and retention analytics

Final Takeaway

Preferential Ranking is a structured decision framework, not just a sorting technique.

Each customer climbs the ladder based on:

  1. Priority

  2. Activity

  3. Recent engagement

  4. Loyalty

  5. Age

  6. Balance

The first point where two customers differ decides who ranks higher.

With a well-designed dataset and a clear set of rules, preferential ranking becomes easy to understand — and even easier to implement using SQL.



 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page