By Javier Callico on
7/27/2007
Today I was asked to look into an interesting task that was keeping busy one of my colleagues for a while. It's such a common task that I'm wondering how come I was never presented with something similar before.Let's use an example to better illustrate the task on hand. Imagine you have a notification system that runs daily and creates a list of different events for what individual users need to be notified. This table represents the notification list resulted from the daily run:UserId EventId------------------- 1 1 1 2 1 3 2 2 3 2 3 4 3 5 4 2 Now a new requirement comes up: All events will be assigned a priority and the users can only received 2 notifications a day for the events with the highest priority.This table represents our Events and their Priority (the bigger the number the highest is the priority):EventId Priority-------------------- 1 8 2 9 3 10 4 ...