I am using ntile function in impala to divide group of customers in equal size but it is not dividing in equal size. I am using below code :
`Table 1:
ColA, ColB, CustNo, Spend `
Data in table 1 is prepared at ColA, ColB, CustNo level.
Number of records in tabl1 is : 68555
My Code :
create table Table2 as
Select distinct * from (
Select *,
ntile(10) over (partition by ColA,ColB
order by Spend asc) as rank_10
from Table1
) a
;
When I am actually checking records for each decile I am not getting same records :
8|11931
6|4541
9|15048
7|9012
3|3118
4|3024
1|4635
5|2108
2|2847
10|12288
Please suggest the mistake