Label data according to percentile
select customer_id,sum,case 
when pct_row&lt;=0.10 then 1
when pct_row&gt;0.10 and pct_row&lt;=0.20 then 2
when pct_row&gt;0.20 and pct_row&lt;=0.60 then 3
when pct_row&gt;0.60 then 4
end as customer_label from (
select customer_id,sum,(@curRow := @curRow+1)/c as pct_row
from temp t 
jOIN (SELECT @curRow := 0) r
JOIN (SELECT @curRow2 := 0) r2 
join (select count(*) c from temp) s
order by sum desc) p;


sqlfiddle :- here

I don't know whether this is efficient method or not but work fine for small data set.