I have a query that currently SELECTs data that I need to delete. The problem is that I need to delete based on TimeSheetID, AssignmentCode *and* ActivityID. I can't delete based on just one. The main criteria is that I need to delete any entries that have a SUM(Length) = 0. Here's the query that produces exactly what I need to delete, but I have no idea how to actually nest this query into a delete statement itself.
Code:
SELECT TimeSheetID, AssignmentCode, ActivityID, SUM(Length) AS Total
FROM Timesheet_TimeLogs
GROUP BY TimeSheetID, AssignmentCode, ActivityID
HAVING SUM(Length) = 0
ORDER BY Total