Mongodb aggregate if you operate multiple times

question: there is a set of data similar to the following
{"sn": "18160481", "status": 1, "updateTime": 1542691932103}
{"sn": "18160482", "status": 2, "updateTime": 1542691932113}
{"sn": "18160483", "status": 2, "updateTime": 1542691932123}
{"sn": "18160484", "status": 3,

how to get the latest updateTime, and count the number of status of 2 through aggregate

Dec.11,2021

I don't know if I understand what I mean to you. The latest updateTime if it refers to the latest for each group grouped according to status , it is written like this:

db.table.aggregate([
    {$group: {_id: "$status", updateTime: {$max: "$updateTime"}, count: {$sum: 1}}}
]);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3802c-2c0f2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3802c-2c0f2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?