df4VW
V2EX  ›  数据库

问个 mongo 查询的问题

  •  
  •   df4VW · Jun 7, 2015 · 1163 views
    This topic created in 4036 days ago, the information mentioned may be changed or developed.

    Mongo 中怎么高效的做这样的查询

    取User表中,同样姓氏(其他属性也可以,比如城市)中,年龄最大的那个人的集合。

    比如有10个姓王,20个姓李,30个姓赵的,结果就应该是一个3人数组,分别为王李赵姓的年龄最大的

    2 replies    2015-06-07 06:32:42 +08:00
    Septembers
        1
    Septembers  
       Jun 7, 2015 via Android
    请认真阅读文档
    20150517
        2
    20150517  
       Jun 7, 2015 via Android
    $group 里用$max
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4519 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 6b34f497 · 57ms · UTC 10:01 · PVG 18:01 · LAX 03:01 · JFK 06:01
    ♥ Do have faith in what you're doing.