• LinksUp (4/20/2015)


    The key is the Row_Number function. Row_Number does just that. It numbers the returned rows in sequential order. But what makes it a very useful function is the partition and order clauses. The partition creates a "window" of rows that are ordered on box_no. When a new partition starts, ie, the box_no changes, the row numbering starts over. Then within each partition, it orders the rows by date in descending order. Since you only wanted the earliest date for each box_no, looking at rowNum = 1 gives us just that!

    If you have any other questions about this, don't hesitate to ask.

    Thanks, that explanation helps more than you would believe.