This is my first post in this forum. Hope you will have patience on me since I am not SQL expert.
I currently have been thinking, how can I delete records in a table that is being returned by a select statement?
SELECT A.intFactoryID, RTRIM(A.strSAPAsset#) strSAPAsset# , RTRIM(A.strConnector) strConnector, A.lngDate, RTRIM(A.strShift) strShift,
LTRIM(RTRIM(A.strAlarmText)) strAlarmText, A.intAlarmCnt
FROM dbo.tblAlarmMaster A
group by [intFactoryID],[strSAPAsset#],[lngDate],[strShift],[strAlarmText], intAlarmCnt
having count([intFactoryID]) > 1) B
on A.[intFactoryID] = B.[intFactoryID]
AND A.[strSAPAsset#] = B.[strSAPAsset#]
AND A.[lngDate] = B.[lngDate]
AND A.[strShift] = B.[strShift]
AND A.[strAlarmText] = B.[strAlarmText]
order by A.[intFactoryID],A.[strSAPAsset#],A.[lngDate],A.[strShift],A.[strAlarmText]
I currently have this select statement, what I want is that I would like to delete the records returned by this select statement on my same table
The keys in my tables are, intFactoryID,strSAPAsset, lngDate,strShift and strAlarmText.
I am not sure how to create the delete statement part. I have just been using only certain simple delete statements until I was face with this task. Hope someone will give pointers. Thank you.