I have a SQLite DB where the statement:
SELECT messdatum, count(*) as anzahl
from lipo
GROUP BY Messdatum
ORDER BY anzahl desc;
results in some lines, which indicates that I have some duplicates with the same Messdatum
.
How can I delete the duplicates only form my sqlite db? (it should delete anzahl-1 records where the messdatum is the same?) Has anyone an advice?
PS: I found this link How to remove duplicate from Microsoft but have problems with sqlite dialect. I got some errors due to the sqlite syntax.
So f.e. I could do:
INSERT into holdkey SELECT messdatum, count(*) as anzahl from lipo group by messdatum having count(*) > 1;
INSERT into holddups SELECT DISTINCT lipo.* from lipo, holdkey where lipo.Messdatum = holdkey.messdatum ;
DELETE lipo from lipo, holdkey where lipo.messdatum = holdkey.messdatum;
here is an error at the delete command. How can I do that? I tried to update the holdkey.anzahl to an additional col in lipo with
UPDATE lipo,holdkey set lipo.duplettenzahl = holdkey.anzahl WHERE lipo.messdatum = holdkey.messdatum ;
but this is also not possible. If I would have the anzahl as dublettenzahl in lipo I could delete all records from lipo where dublettenzahl > 0. Please help! Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…