Skip to content

add 'group by' in aggregating #99

Closed

Description

@huangyingjie

Hello,
How can I use the words 'group by'? To achieve the effect like "select avg(weight), age from person group by age". Or is there any way by method find?

Activity

  1. dresende commented on Apr 8, 2013

    @dresende
    Owner

    Using the git version (not npm), try this: (adjust to your needs)

    Person.aggregate([ 'age' ]).avg('weight').groupBy('age').get(function (err, stats) {
        // stats is an Array, each item should have 'age' and 'avg_weight'
    });
  2. added a commit that references this issue on Apr 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions