In MS and Oracle dialects this would be accomplished with a ROLLUP or CUBE statement.
On Tue, 2015-01-27 at 08:17 +1300, Helen Borrie hele...@iinet.net.au [firebird-support] wrote: > > At 11:25 p.m. 23/01/2015, michael.vilhelm...@microcom.dk > [firebird-support] wrote: > > >I am looking for a function which are able to add values from a table > as records are fetched. > > > >Something like this: > > > >ValueCalculated value > > > >11 > > > >23 > > > >36 > > > >410 > > > >515 > > > >The calculated value is just the sum of all previous values of VALUE. > > > >Whats the name of such function in english and Firebird? > > It is often referred to as a "running total". > > >Does such a function even exist in Firebird 2.5? > > I have not heard of a function that could generate such result from > multiple rows, since a function returns a finite, single-row set from > finite input and would have no way to retain the current accumulated > value from one call to the next. > > As Thomas indicated, the window functions in Fb3 will enable you to do > such operations in direct SQL. In 2.5 and lower, it is very easy to > generate a set containing a running total, by way of a selectable > stored procedure. > > Helen Borrie, Support Consultant, IBPhoenix (Pacific) > Author of "The Firebird Book" and "The Firebird Book Second Edition" > http://www.firebird-books.net > __________________________________________________________ > > > > >