I want to find the sum of Primary Type in every Year in descending order

Hi sir, i have problem with mongo command, can u help me? i want to find the sum of Primary Type in every Year in descending order but i dont know how to do it

The field Primary Type is a string. How do you want to sum a string value? May be you mean that you want to count the number of documents per Year and Primary Type.

To count you need to $group and use $count. Examples are provided in the links I shared.

You then use $sort to order the result.

This use-case is quite simple and the links provided should help you figure out how to use it. If not, I suggest that you take the course M121 from MongoDB University. That would help get a good basic understanding of aggregation.