Subject | Re: [firebird-support] Function - what is it called |
---|---|
Author | Helen Borrie |
Post date | 2015-01-26T19:17:55Z |
At 11:25 p.m. 23/01/2015, Michael.Vilhelmsen@... [firebird-support] wrote:
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
__________________________________________________________________
>I am looking for a function which are able to add values from a table as records are fetched.It is often referred to as a "running total".
>
>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?
>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
__________________________________________________________________