How to select and order by grouping n rows with sum of them between a and b?
I have the list number like:
1,2,3,4,5,6,7,8,9,10,11,12...100
SELECT LEVEL FROM DUAL CONNECT BY LEVEL <= 100
I need to order a group of each 5rows have 80 <= sum <= 100
1,12,22,23,31, 2,3,15,24,47, 5,11,17,26,37, ...
Inside:
sum(1,12,22,23,31) = 89 match the condition
sum(2,3,15,24,45) = 91 match the condition
sum(5,11,17,26,37) = 96 match the condition
...
Anyone can help me?