i have now solve my own problem
this is my code for future use
select id, desc, cost from
(select *, SUM(cost) over (order by cost desc)totalcost from TableX) t WHERE totalcost <=(select sum(cost) from tableX)*0.25
how the code work?
its simple by adding new column where adding the cost to totalcost
sample:
id desc cost totalcost
1 xx 10 10
2 xx 11 21
15 xx 11 32
3 xx 12 44
4 xx 13 57
5 xx 14 71
6 xx 14 85
14 xx 14 99
7 xx 15 114
8 xx 16 130
9 xx 18 148
10 xx 19 167
11 xx 20 187
12 xx 21 208
13 xx 23 231
then selecting only the match to my condition
sorry for poor explanation.