Skip to content

Commit 52c6976

Browse files
committed
hw 5.2
1 parent d00e9e2 commit 52c6976

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Diff for: hw5.2/README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,37 @@ mongoimport -d test -c zips --drop small_zips.json
3232
### Response
3333

3434
````
35-
35+
db.zips.aggregate([
36+
{
37+
$match: { state: {
38+
$in: ['CA', 'NY'] }
39+
}
40+
},
41+
{
42+
$group: {
43+
_id: {
44+
state: '$state',
45+
city: '$city'
46+
},
47+
pop: {
48+
$sum: '$pop'
49+
}
50+
}
51+
},
52+
{
53+
$match: { pop: { $gt: 25000 }}
54+
},
55+
{
56+
$group: {
57+
_id: null,
58+
average: {
59+
$avg: '$pop'
60+
}
61+
}
62+
}
63+
])
3664
````
3765

38-
*
66+
* 44805 (44804.782609)
3967

4068

0 commit comments

Comments
 (0)