I have a following temp table Customer
Customer Group Price
A Sales 100
B Lease 200
C Lease 300
D Lease 50
E Lease 100
F Sales 750
G Sales 200
H Lease 50
I Sales 130
J Lease 100
K Lease 200
L Sales 500
M Sales 1000
N Sales 10
O Sales 100
I want to find top 25 % customers for each Group.
For eq: Sales has total of 8 customers, so top 25 % would be 2. Hence i need top 2 customers for Sales who have highest Price.
Similarly, for Lease, i have total of 7 customers, top 25 % would be 1.75 which is ~2.
If there is a Customer, which has same Price, Customer which is higher in sorting can be chosen. For eq: Customer B and K have same Price of 200, hence B should be selected.
Here is the desired output:
Customer Group Price
B Lease 200
C Lease 300
F Sales 750
M Sales 1000
Thanks all.