Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3376

Comment on: "manual/tutorial/aggregation-zip-code-data-set.txt"

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Blocker - P1 Blocker - P1
    • v1.3.8
    • None
    • manual

    Description

      Hello.

      About the example "Return Average City Population by State" I spent a lot of time figuring out why the query was so complex.

      I had to analyze the dataset to see that cities can have the same name in the same state. Maybe it is obvious for americans but not really for foreign people like me

      I think it should me mentioned somewhere that we need to group on state AND cities because 2 cities can have the same name, in the same state.
      Else, the simple following request would be enough:

      db.collection.aggregate([{$group: { _id: "$state", average: {$avg: "$pop" }}}])

      Michel

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 29 weeks, 5 days ago