Skip to content
Advertisement

running sum or cumulative frequency using subquery

Below is the output of cumulative frequency according to datewise, which I want to change into the subquery. The output is also correct but I want to do it by using a subquery.

OUTPUT

Advertisement

Answer

You would use window functions:

Not only is this simpler to write, but it should be significantly faster — and no CTE or subquery is appropriate for this version.

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