[DOCS-3376] Comment on: "manual/tutorial/aggregation-zip-code-data-set.txt" Created: 09/May/14  Updated: 08/Dec/16  Resolved: 25/Jul/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.8

Type: Improvement Priority: Blocker - P1
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/tutorial/aggregation-zip-code-data-set/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.86 Safari/537.36
Referrer: http://docs.mongodb.org/manual/core/aggregation-pipeline/
Screen Resolution: 1440 x 900
repo: docs
source: tutorial/aggregation-zip-code-data-set


Participants:
Days since reply: 9 years, 29 weeks, 5 days ago

 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



 Comments   
Comment by Kay Kim (Inactive) [ 25/Jul/14 ]

Add note that a city can have more than one zip code.

Comment by Githook User [ 25/Jul/14 ]

Author:

{u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-3376 clarify city can have multiple zip codes and hence in example collection, multiple documents
Branch: master
https://github.com/mongodb/docs/commit/01b5a18e06fe9a10cebb70eaeb04f1ab4aaf6f08

Generated at Thu Feb 08 07:45:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.