Skip to content
Advertisement

get top values in select

I have next ordered table:

I need to select top values, sum of witch is 15+ (in my case 7+5+4 > 15) and merge items which lefts in to other: result should be:

Advertisement

Answer

You can use a subquery with a cumulative sum:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement