ease20022002
Technical User
Hi,
I have a table that has several fields, but for the action I want to perform there are only 2 fields of concern, Field1 and Field2. Field1 is string and contains material designation id's (MCP) and Field2 contains the quantity of the material (Quantity1). What I want to do is delete all Field1 ids that have a Field2 quantity = 0. What I have done so far is design a query from the original table to GROUP BY Field1 and Sum Field2 to find all the Field1 ids that have a total quantity of 0. Now I need to know how I can delete those records all in one query. I hope someone can help me out and the following is what I have done so far.
SELECT MB51YTD_Table.MCP, Sum(MB51YTD_Table.Quantity1) AS SumOfQuantity1
FROM MB51YTD_Table
GROUP BY MB51YTD_Table.MCP
HAVING (((Sum(MB51YTD_Table.Quantity1))=0));
Now to delete, I thought all I had to do was put DELETE at the beginning of the statement, but I don't think it works.
Any help is appreciated.
I have a table that has several fields, but for the action I want to perform there are only 2 fields of concern, Field1 and Field2. Field1 is string and contains material designation id's (MCP) and Field2 contains the quantity of the material (Quantity1). What I want to do is delete all Field1 ids that have a Field2 quantity = 0. What I have done so far is design a query from the original table to GROUP BY Field1 and Sum Field2 to find all the Field1 ids that have a total quantity of 0. Now I need to know how I can delete those records all in one query. I hope someone can help me out and the following is what I have done so far.
SELECT MB51YTD_Table.MCP, Sum(MB51YTD_Table.Quantity1) AS SumOfQuantity1
FROM MB51YTD_Table
GROUP BY MB51YTD_Table.MCP
HAVING (((Sum(MB51YTD_Table.Quantity1))=0));
Now to delete, I thought all I had to do was put DELETE at the beginning of the statement, but I don't think it works.
Any help is appreciated.