incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Iriele <siri...@breaktimestudios.com>
Subject Re: CouchDB: Group results by unique values
Date Fri, 26 Jul 2013 20:41:21 GMT
Also you can use arrays as keys as well in group by that.. So [fruit,
weight, etc,] and value can be whatever you want...then use the couchdb
built in reduce function _count
On Jul 26, 2013 4:34 PM, "Stanley Iriele" <siriele2x3@gmail.com> wrote:

> 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