I want to delete rows from a SQL Server 2000/2005 table variable based on the presence of other rows in the same table (delete all 0 count rows if a non-0 count row exists with
Specify the alias name before FROM statement Meaning, you are deleting from the aliased table.
delete o1 from @O as o1 where ACount = 0 and exists ( select Month from @O o2 where o1.Month = o2.Month and o2.ACount > 0)
Result