couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Iriele <siriele...@gmail.com>
Subject Re: CouchDB: Group results by unique values
Date Fri, 26 Jul 2013 20:33:32 GMT
Is fruit a string or an array here?.. Why do you care about the fruit
length?
On Jul 26, 2013 4:29 PM, "Hank Knight" <hknight555@gmail.com> wrote:

> I have 1000 of rows but the containing data about fruit.  There are
> only 10 unique values for the field "fruit".
>
> I would like to count the total number of occurrences for each unique
> "fruit" value.
>
> This returns 1000 results:
>
> function(doc) {
>   if (doc.fruit) emit(doc.fruit,doc.fruit.length);
> }
>
> How can I limit the results so each unique value for fruit is only
> returned once?
> In MySQL I would use something like:
> SELECT `fruit`, COUNT(`fruit`) GROUP BY `fruit`
>
> ---
> Thanks!
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message