I have a peculiar problem at hand. I need to rank in the following manner:
- Each ID gets a new rank.
- rank #1 is assigned to the ID with the lowest date. However, the subsequent dates for that particular ID can be higher but they will get the incremental rank w.r.t other IDs. (E.g. ADF32 series will be considered to be ranked first as it had the lowest date, although it ends with dates 09-Nov, and RT659 starts with 13-Aug it will be ranked subsequently)
- For a particular ID, if the days are consecutive then ranks are same, else they add by 1.
- For a particular ID, ranks are given in date ASC.
How to formulate a query?
You need two steps:
dt_col - rnk
caluclates the same result for consecutives dates -> same rank