nested sql help [message #2995] |
Wed, 28 August 2002 12:46 |
WALID
Messages: 31 Registered: August 2002
|
Member |
|
|
Can you help me find data in one table - each row is a historical record of an units with serial numbers as primary key - there is a column that has a flag = Y/N and time seqno =0/1/2/3/4/5/... There should only be one record in the sequence of events with flag=Y. I want to find all units that might have two or more lastflag='Y' and not to include the row with only one lastflag='Y'
I tried this query and I don't think I am getting the right info. Please help.
SELECT serno from TMP_WORK_ARCH t1
where exists (select SERNO from TMP_WORK_ARCH t2
where t2.SERNO = t1.SERNO
and t2.lastflag <> t1.lastflag
and t2.tmseqno > t1.TMSEQNO);
Thanks,
|
|
|
|