I have this select statement:
SELECT d.idcprefix,
d.orgdept,
d.idcseq,
d.subcont,
d.actualcomp,
COUNT (*) AS "No Duplicates"
FROM DCS_IDC, DCS_IDC z
WHERE D.IDCPREFIX = z.idcprefix
AND z.orgdept = d.orgdept
AND z.idcseq = d.idcseq
and D.SUBCONT is not null
HAVING COUNT (*) > 1
GROUP BY d.idcprefix,
d.orgdept,
d.idcseq,
d.subcont,
d.actualcomp
ORDER BY d.idcprefix,
d.orgdept,
d.idcseq,
d.subcont,
d.actualcomp
and I want to delete the rows that are brought back from this statement, any ideas?
A Delete FROM gives me a ORA-01732: data manipulation operation not legal on this view
error because, I believe, I am comparing two tables albeit the same table.
I also tried a delete from tablename where rows exist, but that deleted far more rows than I wanted.
The "duplicates" are based on Subcont. There were records inserted into the database / application using the subcont field, which was meant to be blank, so now I have records which are the same except for one has, for example, A in subcont and it's blank in the other:
idcprefix, subcont, orgdept and idcseq
1 A ABC 1
1 ABC 1
2 A BCD 1
2 BCD 1
The query shows all the records that have a subcont that are dupliates of the ones that don't and I need to remove the ones with the subcont value.
Help would be much appreciated!