“Grup Agregat MongoDB” Kode Jawaban

grup MongoDB dengan memiliki

#It's the equivalent of the following SQL instruction:
# SELECT COUNT(*) FROM Table
# GROUP BY your_field
# HAVING COUNT(*) > N
query = db.collection.aggregate([

    { 
      "$group": { "_id": "$your_field", #GROUP BY your_field
    			"count": {"$sum":1} }   #COUNT(*)
    },
    
    { "$match": { "count": { "$gt": N } } } #HAVING COUNT(*) > N
])
Annoyed Antelope

Grup Agregat MongoDB

#equivalent of the following SQL instruction:
# SELECT COUNT(*) FROM Table
# GROUP BY your_field
query = db.collection.aggregate([
    { 
        "$group": {
            "_id": "$your_field", #GROUP BY your_field
            "total": {"$sum":1}   #COUNT(*)
        }
    }
])
Annoyed Antelope

Jawaban yang mirip dengan “Grup Agregat MongoDB”

Pertanyaan yang mirip dengan “Grup Agregat MongoDB”

Lebih banyak jawaban terkait untuk “Grup Agregat MongoDB” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya