r937 ,
i have a data record in V_TABLE table in which values are like this
Code:
ID V_TYPE STATUS
2124 H1 APPR
2124 H1 VISA
23573 H1 VISA
23573 H1 APPR
23869 H1 APPR
23869 H1 VISA
5458 L1 VISA
5458 L1 APPR
16673 L1 VISA
16673 L1 APPR
10074 H1 APPR
10093 L1 VISA
10108 L1 VISA
now i want to delete those emplid(complte rows) who have STATUS = 'APPR' only when they have STATUS = 'APPR' as well for same V_TYPE
for ex. 2124 emplID has both 'APPR' n 'VISA' status for H1 V_TYPE so only 'APPR' row must be deleted.
i have applied this code but it is deleting complete table .
DELETE FROM V_TABLE WHERE EXISTS
(SELECT * FROM V_TABLE A where
ID IN
(SELECT ID FROM V_TABLE B WHERE B.V_STATUS = 'APPR'
AND B.ID = A.EMPLID
AND B.V_TYPE = A.V_TYPE
INTERSECT
SELECT ID FROM V_TABLE C WHERE V_STATUS = 'VISA'
AND C.ID = A.ID
AND C.V_TYPE = A.V_TYPE)
AND A.VISA_STATUS = 'APPR'
and A.ID = V_TABLE.ID)
kindly help..