1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to MongoDB in Python

Exercise

Recently single?

A prize might be awarded to a single laureate or to several. For each prize category, report the most recent year that a single laureate -- rather than several -- received a prize in that category. As part of this task, you will ensure an index that speeds up finding prizes by category and then sorting results by decreasing year

Instructions

100 XP
  • Specify an index model that indexes first on category (ascending) and second on year (descending).
  • Save a string report for printing the last single-laureate year for each distinct category, one category per line. To do this, for each distinct prize category, find the latest-year prize (requiring a descending sort by year) of that category (so, find matches for that category) with a laureate share of "1".