Quote Originally Posted by malay_biswal
Check this query.

select orderstage_id,process_date from orderhistory
where orderstage_id in (select orderstage_id from orderhistory
where orderinfo='reprocessed') and orderinfo!='reprocessed'
Your query doesn't take into consideration neither cardinality nor order. You cannot just assume there are two rows per orderstage_id.

How do you know returned row/rows is/are the next to "reprocessed" row?
1- Your query has the potential to return multiple rows
2- Your query has the potential to return rows before/after "reprocessed" row

Better to wait for OP to clarify scenario... then try to help him/her.