I'm trying to write a sql statement which returns bad rows from my table. I have a table with rows:
Key | Date | Indicator
1 | 10/10/08 | SE
1 | 10/11/09 | CB
1 | 10/12/09 | CE
1 | 10/13/09 | TR
2 | 1/1/09 | SE
3 | 10/10/08 | SE
3 | 10/13/09 | CE
3 | 10/15/09 | SL
So what I want returned would be all rows where a key has an indicator of CE then I want the row that is exactly after it date wise.
EX. my result would then be:
1 | 10/13/09 | TR
3 | 10/15/09 | SL
My problem is I can't figure out how to join the table on itself with the conditions listed above. Please help with any suggestions.