Skip to main content
10 events
when toggle format what by license comment
Feb 15, 2011 at 14:41 history made wiki Post Made Community Wiki
Jan 12, 2011 at 21:43 comment added Jon Hopkins @Tim - That would work. No preference - one of the things I like about it is that there's no one right answer and there are different options.
Jan 12, 2011 at 19:22 comment added Tim Goodman I guess I would do this: DELETE FROM Things WHERE ID NOT IN (SELECT MIN(ID) FROM Things GROUP BY Name). Do you have a preferred solution?
Jan 12, 2011 at 18:50 comment added Tim Goodman @Jon Hopkins: OK, I get what you're doing now. You want to find all of the rows with duplicates so you can kill all but one of each, leaving only the de-duped rows. I was initially thinking that you just wanted a query that returns the rows while omitting duplicates, which is why it seemed really simple.
Jan 6, 2011 at 14:10 history edited Jon Hopkins CC BY-SA 2.5
added 37 characters in body
Dec 21, 2010 at 10:26 comment added Jon Hopkins @Tim - You're right, it's really unclear. I'll edit when I get a few minutes.
Dec 20, 2010 at 20:54 comment added Tim Goodman @Jon: Not sure what you mean by "That gives the count for everything". From your example solution, it looks like what you want is one row for each distinct name. From your comments it seems like maybe you mean something like HAVING count(Name) > 1, but then I guess your sample answer should omit Bodkin Van Horn, Hot Shot, Snimm, and Dave.
Dec 20, 2010 at 16:49 comment added Jon Hopkins @Tim - That gives you the count for everything. I only want those with duplicates. Manually edited the results doesn't count, assume it's scaling to millions of rows. It is an easy problem but in my experience 80% of people claiming to know SQL can't get even as far as your first stab.
Dec 20, 2010 at 16:46 comment added Tim Goodman I guess I don't know what counts as "entirely trivial"... Something like SELECT min(ID), Name FROM Things GROUP BY Name would work, right?
Nov 24, 2010 at 16:23 history answered Jon Hopkins CC BY-SA 2.5