I’d like to build a query that returns the top 1 million customers based off of two criteria that ranks 10 million customers.
Criterion 1 being a grade assigned to each customer from 1 to 5, 1 being the best
Criterion 2 being a grade assigned to each customer from A to E, A being the best
Criterion 1 outweighs Criterion 2, in that before you move to B (Criterion 2), you must first go from 1 to 5 (Criterion 1) within the A band (Criterion 2) i.e. A customer that scores a 5 (criterion 1) and an A (criterion 2), is a better customer than a customer that scores a 1 (criterion 1) and a B (criterion 2).
I’d like the query to return the top 1 million customers, stopping within the bands that return the 1 million-th customer e.g. if customer 1 million is in the 4C band, don’t return any customers beyond 4C. It’s ok if it's just over 1 million, to accommodate every customer in 4C band. This is my attempt at it but this doesn’t account for sequence:
SELECT *
FROM CUSTOMER_POPULATION
WHERE Criterion1 IN (5,4,3,2,1)
AND Criterion2 ('A','B','C','D','E')
LIMIT 1000000
TIA.