I have a table named commercialcopy
with 4 columns. I want to remove the duplicated row on the table.
My script is below
DELETE FROM commercialcopy
where (BUSINESSREGISTRATIONNUMBER, BUSINESSNAME, CustomerIDCORP, BUSINESSOFFICEADDRESSLINE1) NOT IN (
SELECT MIN(BUSINESSREGISTRATIONNUMBER), MIN(BUSINESSNAME),MIN(CustomerIDCORP),MIN(BUSINESSOFFICEADDRESSLINE1)
FROM commercialcopy
GROUP BY BUSINESSREGISTRATIONNUMBER, BUSINESSNAME, CustomerIDCORP, BUSINESSOFFICEADDRESSLINE1
);
ERROR:
I am getting the below redline error on the first column_name argument "where (BUSINESSREGISTRATIONNUMBER,"
An expression of non-boolean type specified in a context where a condition is expected
1条答案
按热度按时间6ss1mwsb1#
The issue with your script is that the WHERE clause expects a boolean expression, but you are comparing multiple columns to a subquery result which is not a valid boolean expression.
You can modify your script to use EXISTS instead of NOT IN, like this:
This will delete all rows from commercialcopy except the one with the smallest ROWID for each set of duplicated values in the four columns.