Running totals page 2 |
|||||
Expansion of supporting window functions in SQLServer 2012 gives us opportunity to solve task on running totals in extremely simple manner. As for our task, we expose the following new features: Thus we can obtain running totals sorting data by date and calculating sum of values in a range from current row and up (unlimitedly) above, and we can do it with aid of a single function! The exercise on previous page about running totals for the point 2 can now be solved as follows.
To obtain running totals for each point separately, we remove from above query only the condition for the point 2:
The above queries have to work under PostgreSQL and Oracle. As for MySQL, window functions was supported in MySQL 8.0. Suggested exercises: 106
|