M101P: MongoDB for Developers - Chapter 5: Aggregation Framework
来源:互联网 发布:sql语句删除查询结果 编辑:程序博客网 时间:2024/05/16 11:07
Homework 5.1
db.posts.aggregate([{$unwind:"$comments"},{$group:{_id:"$comments.author",comments:{$sum:1}}},{$sort:{comments:-1}},{$limit:1}]){ "_id" : "Elizabet Kleine", "comments" : 503 }
Homework 5.2
db.zips.aggregate([{$group:{_id:{state:"$state",city:"$city"},pop:{$sum:"$pop"}}},{$match:{pop:{$gt:25000}}},{$group:{_id:"$_id.state",pop:{$avg:"$pop"}}}])db.zips.aggregate([{$match:{$or:[{state:"CA"},{state:"NY"}]}},{$group:{_id:{state:"$state",city:"$city"},pop:{$sum:"$pop"}}},{$match:{pop:{$gt:25000}}},{$group:{_id:null,pop:{$avg:"$pop"}}}]){ "_id" : null, "pop" : 44804.782608695656 }
Homework 5.3
db.grades.aggregate([{$unwind:"$scores"},{$match:{"scores.type":{$ne:"quiz"}}},{$group:{_id:{class:"$class_id",student:"$student_id"},score:{$avg:"$scores.score"}}},{$group:{_id:"$_id.class",score:{$avg:"$score"}}},{$sort:{score:-1}},{$limit:1}]){ "_id" : 1, "score" : 64.50642324269175 }
Homework 5.4
db.zips.aggregate([{$match:{city:/^\d/}},{$group:{_id:null,pop:{$sum:"$pop"}}}]){ "_id" : null, "pop" : 298015 }
-eof-
0 0
- M101P: MongoDB for Developers - Chapter 5: Aggregation Framework
- M101P: MongoDB for Developers - Chapter 1: Introduction
- M101P: MongoDB for Developers - Chapter 2: CRUD
- M101P: MongoDB for Developers - Chapter 4: Performance
- M101P: MongoDB for Developers - Chapter 3: Schema Design
- M101P: MongoDB for Developers - Final Exam
- Mongodb Aggregation Framework
- Chapter 2:Guidelines for Python Developers
- Framework manager Creating aggregation rules for measures
- 50.Tips.and.Tricks.for.MongoDB.Developers
- IOS 5 for Developers
- M102: MongoDB for DBAs - Chapter 5: Replication Part 2
- M102: MongoDB for DBAs - Chapter 1: Introduction
- M102: MongoDB for DBAs - Chapter 4: Replication
- 50.Tips.and.Tricks.for.MongoDB.Developers --- Optimization Tips
- mongodb aggregation 聚合
- MongoDB Aggregation Pipeline
- MongoDB聚合操作Aggregation
- 告诉你一个dubbo token使用秘技
- STM32进不了主函数
- C++定义类和对象的两种方式--对比Java
- 第一个动态网页
- RxJava 详解-给android开发者
- M101P: MongoDB for Developers - Chapter 5: Aggregation Framework
- Spring 学习笔记(三)
- js使用in和hasOwnProperty获取对象属性的区别
- 最值与极值的理解
- 1/0信封——数据链路层,ARP及RARP
- jexus安装手记
- 文章标题
- RxJava阅读推荐
- JSP+Servlet+JavaBean