I have a table with 1 million+ records like this:
My aim is to get records that have status N, excluding those records that do not have the latest (wrt date column) entry as Y. I'm looking for something like this:
Here entries with status=N are id=123,129,128. The latest entry associated with order 129 is 'Y' so we exclude it from our output. In other words, because 129 had status N previously, but on its new run on the next day, the status changed to Y. So I do not need 129 for further processing.
I tried with nested SELECT queries and join but was unable to get the right combination. Kindly suggest a suitable solution.