To clarify the question further…
I have the following Table ORDERS_TAB with some example information:
|Order| Launch_Date |
| 1 | 27-Sep-11 |
| 2 | 29-Sep-11 |
| 3 | 30-Sep-11 |
| 4 | 03-Oct-11 |
| 5 | 28-Oct-11 |
| 8 | 10-Oct-11 |
| 7 | 29-Sep-11 |
I want to select all orders that have a LAUNCH_DATE value within the next three available days including the current day. So, as today is 29-Sep-11 the three available dates from the table would be 29-Sep-11, 30-Sep-11 and 03-Oct-11. Thus the query would return the result:
|Order| Launch_Date |
| 2 | 29-Sep-11 |
| 3 | 30-Sep-11 |
| 4 | 03-Oct-11 |
| 7 | 29-Sep-11 |
So I assume I would need to check what the current date is in the system, search for this date or the next available one and then find the next two available dates after that.. the problem is I have no idea how to do this!
All I am looking for is a simple SELECT statement with some conditions but any help is much appreciated,
Thank-you. 🙂
EDIT As there is confusion about how DENSE_RANK() works, here is the OP’s example…
This means that the returned Orders will be
2,3,4,7. Exactly as described by the OP.