Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19CEB6B6D for ; Thu, 9 Jun 2011 16:27:10 +0000 (UTC) Received: (qmail 25451 invoked by uid 500); 9 Jun 2011 16:27:08 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 25423 invoked by uid 500); 9 Jun 2011 16:27:08 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 25415 invoked by uid 99); 9 Jun 2011 16:27:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2011 16:27:08 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received-SPF: unknown ~alla (nike.apache.org: encountered unrecognized mechanism during SPF processing of domain of david@cloudant.com) Received: from [216.86.168.183] (HELO mxout-08.mxes.net) (216.86.168.183) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2011 16:27:00 +0000 Received: from [192.168.1.100] (unknown [67.180.255.146]) by smtp.mxes.net (Postfix) with ESMTPA id 867E3509F3 for ; Thu, 9 Jun 2011 12:26:39 -0400 (EDT) Message-ID: <4DF0F44C.7010507@cloudant.com> Date: Thu, 09 Jun 2011 09:26:52 -0700 From: David Hardtke User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: how to sum values of a view in a date range? References: <4DF0E44E.8020601@altraqua.com> <4DF0EF7B.6020604@altraqua.com> In-Reply-To: <4DF0EF7B.6020604@altraqua.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Fabio, This should work. You can use the _sum builtin as reduce: "reduce":"_sum" You then need to query your view with the proper group level and a startkey and endkey: GET db/_design/power/_view/watt?group_level=2&startkey=[2011,3]&endkey=[2011,4]&inclusive_end=false That gives you the sum for the month of March. On 06/09/11 09:06, Fabio Di Bernardini wrote: > Il 09/06/2011 17:18, Fabio Di Bernardini ha scritto: >> If I have a map function emitting a timestamp as key ad a number as >> document, how to get sum of values selecting a date range? > > More datails here: > http://stackoverflow.com/questions/6294794/how-to-sum-values-of-a-view-in-a-date-range-using-couchdb >