Sunday, June 29, 2014

Homework: Homework 5.4 , Removing Rural Residents , calculate the number of people who live in a zip code in the US where the city starts with a digit

 db.zips.aggregate([{$project:{city:{$substr:["$city",0,1]},pop:"$pop",_id:0}},{$match:{city:{$regex:'[0-9]'}}},{$group:{_id:null,pop:{$sum:"$pop"}}}])

No comments:

Post a Comment