MongoDB DEV · Question 78 · Single choice

Suppose you have a collection named alpha that contains only the following documents: { "_id": 1, "region": "NW1", "leads": 1, "email": "mlangley@co1.com" } { "_id": 2, "region": "NW1", "leads": 1, "email": "jpicoult@co4.com" } { "_id": 3, "region": "NW1", "leads": 2, "email": "zzz@company2.com" } { "_id": 4, "region": "SE1", "leads": 8, "email": "mary@hssu.edu" } { "_id": 5, "region": "SE2", "leads": 4, "email": "janet@col.edu" } { "_id": 6, "region": "SE2", "leads": 2, "email": "bill@uni.edu" } { "_id": 7, "region": "SE2", "leads": 4, "email": "iii@company1.com" } { "_id": 8, "region": "SW1", "leads": 1, "email": "phil@co3.com" } { "_id": 9, "region": "SW1", "leads": 2, "email": "thomas@company.com" } { "_id": 10, "region": "SW2", "leads": 5, "email": "sjohnson@uchi.edu" } How many documents will be returned by the following Aggregation query? db.alpha.aggregate([ { "$group": { "_id": "$region" , "count": { "$sum": 1 }, "leads": { "$max": "$leads" } } } , { "$match": { "leads": { "$gt": 3 } } } ]) Choose the best answer:

Answer options

  1. A.
    0
  2. B.
    1
  3. C.
    2
  4. D.
    3
  5. E.
    4

Answer confidence: High

Correct answer: D

Explanation language: Chinese

$group 按 region 分组并取每组 leads 的最大值:NW1=2、SE1=8、SE2=4、SW1=2、SW2=5。$match 保留 leads>3 的分组后只剩 SE1、SE2、SW2 三组,因此返回 3 个文档。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗