How to - complex (for me) aggregation pipeline

It gives the unique combination of the 2.

You can then group all the status counts of one customer with another group such as:

{
		"$group" : {
			"_id" : "$_id.customer_x",
			"counts" : {
				"$push" : {
					"status" : "$_id.status",
					"count" : "$count"
				}
			}
		}
	}
1 Like