suppose i have a table like this
Date Name Entry
21-08-2012 A In
21-08-2012 A Out
21-08-2012 A In
21-08-2012 A In
21-08-2012 A Out
In this i need to check if first time out will be occurred in the entry column then an error must be generated otherwise it must go to the next record. We have to check everytime the sequence of "in" and "out" entry if "in" will occur twice in the continuous order then it should delete the first occurence of the "in" entry showing in continuous order...... Anyone can help me
I want output like this
Date Name Entry
21-08-2012 A In
21-08-2012 A Out
21-08-2012 A In
21-08-2012 A Out
Loading
Sukesh MarlaPosted Aug 21, 2012, 7:48 AM
Create identity column for your Table call it ID forinstance
Qurey
delete from TblTemplate
WHERE ID <>
(
SELECT MAX(ID)
FROM TblTemplate t2
where TblTemplate.TemplateId=t2.TemplateId
and TblTemplate.c1=t2.c1
GROUP BY t2.TemplateId, t2.c1
)
Check this is correct answer if it helped