Hi,

I'd like to add a running total to my result set. For example:

Table: Invoices

Reference           Due
Invoice1               50.00
Invoice2               30.00
Invoice3               20.00

I'm guessing SQL would be something like:
Select
  Reference,
Due,
Sum_Total(Due) as Balance
>From Invoices

Desired Result:
Reference           Due                        Balance
Invoice1               50.00                     50.00
Invoice2               30.00                     80.00
Invoice3               20.00                     100.00

I know I can do this quite easily from within a selectable stored procedure, 
but the problem there is the running total won't be correct if a different sort 
order is specified, which happens often in my real world application.

Is it possible to do this using just a simple SQL statement?

Thanks
Maya

  • [fire... Maya Opperman m...@omniaccounts.co.za [firebird-support]
    • ... Svein Erling Tysvær setys...@gmail.com [firebird-support]
    • ... Norbert Saint Georges n...@tetrasys.eu [firebird-support]
      • ... Maya Opperman m...@omniaccounts.co.za [firebird-support]
      • ... Alan J Davies alan.dav...@aldis-systems.co.uk [firebird-support]
        • ... Steve Wiser st...@specializedbusinesssoftware.com [firebird-support]
        • ... 'Arno Brinkman' fbsupp...@abvisie.nl [firebird-support]
          • ... 'Arno Brinkman' fbsupp...@abvisie.nl [firebird-support]
        • ... Louis van Alphen lo...@nucleo.co.za [firebird-support]
    • ... 'Mark Rotteveel' m...@lawinegevaar.nl [firebird-support]
    • ... Maya Opperman m...@omniaccounts.co.za [firebird-support]

Reply via email to