如何使用MongoDB中的聚合使用一个查询

时间:2016-12-04 07:19:35

标签: mongodb aggregation-framework

所以我的作业中有些问题我很难理解:

找出平均最大最低 h er TEAM_ID
找出平均最大最低 h er team_id

两者都非常相似,但第二个问题也要求今年。我不确定如何设置我的查询来使用聚合来解决这些问题。如果有人能够向我展示一个问题的解决方案,那么当我从例子中学习而不是解决它时,这个问题会有很大的帮助。

我使用的数据具有以下结构;第一行是标题:

player_id,year,stint,team_id,league_id,w,l,g,gs,cg,sho,sv,ipouts,h,er,hr,bb,so,baopp,era,ibb,wp,hbp,bk,bfp,gf,r,sh,sf,g_idp
bechtge01,1871,1,PH1,,1,2,3,3,2,0,0,78.0,43,23,0,11,1,,7.96,,,,0,,,42,,,
brainas01,1871,1,WS3,,12,15,30,30,30,0,0,792.0,361,132,4,37,13,,4.5,,,,0,,,292,,,
fergubo01,1871,1,NY2,,0,0,1,0,0,0,0,3.0,8,3,0,0,0,,27.0,,,,0,,,9,,,
fishech01,1871,1,RC1,,4,16,24,24,22,1,0,639.0,295,103,3,31,15,,4.35,,,,0,,,257,,,
fleetfr01,1871,1,NY2,,0,1,1,1,1,0,0,27.0,20,10,0,3,0,,10.0,,,,0,,,21,,,
flowedi01,1871,1,TRO,,0,0,1,0,0,0,0,3.0,1,0,0,0,0,,0.0,,,,0,,,0,,,
mackde01,1871,1,RC1,,0,1,3,1,1,0,0,39.0,20,5,0,3,1,,3.46,,,,0,,,30,,,
mathebo01,1871,1,FW1,,6,11,19,19,19,1,0,507.0,261,97,5,21,17,,5.17,,,,2,,,243,,,
mcbridi01,1871,1,PH1,,18,5,25,25,25,0,0,666.0,285,113,3,40,15,,4.58,,,,0,,,223,,,
mcmuljo01,1871,1,TRO,,12,15,29,29,28,0,0,747.0,430,153,4,75,12,,5.53,,,,0,,,362,,,

可以找到完整的文件here

感谢任何阅读和帮助的人!

0 个答案:

没有答案