Running total?

16 views
Skip to first unread message

Samuel Williams

unread,
Jul 30, 2012, 10:38:16 PM7/30/12
to us...@couchdb.apache.org
Hi,

Given a set of transactions with each transaction having an integer amount
or something similar, is it possible to generate a running total for each
transaction using map-reduce in CouchDB?

Kind regards,
Samuel

Alexander Shorin

unread,
Jul 31, 2012, 2:12:07 AM7/31/12
to us...@couchdb.apache.org
Hi,

Depends on your data, but just emit transaction id from set as key and
his amount as value with map and _sum these values with reduce
function. If you need totals for all set, then emit [set_id, item_id]
key and group results by specific level.

--
,,,^..^,,,

Samuel Williams

unread,
Sep 28, 2012, 9:32:08 AM9/28/12
to us...@couchdb.apache.org
Hi Alex,

Will your suggested approach give me a running balance such as on a bank
statement with a list of transactions?

Kind regards,
Samuel
Reply all
Reply to author
Forward
0 new messages