I have a system bug which means that I have occasional dupicate entries in
my 'subscribers' table. I'm trying to find a query which performs something
like a 'where user_name is not unique' query.
At the moment we use this cludge:
select count(*), user_name from subscribersgroup by user_name order by count;
(I'm surprised I can't add 'where count > 1' but it seems conditionals on
aggregate fields are not allowed).
This gives me a very long list with the 'not unique' entries at the bottom, eg
count | user_name
------+------------------
1 | bill.hicks [ ..cut 9 zillion results.. ]
1 | margaret.thatcher
4 | linus.torvalds
9 | bill.gates
I then have to do
select oid from subscribers where user_name = 'linus.torvalds';
and delete all but one of the records. Is there a better way to do this?
And yes, we're working on a system fix to avoid the problem in the 1st place!
TIA, al.
--
# Allan Kelly http://www.plotsearch.co.uk# (+44) (0)131 524 8500#
allan.kelly@buildstore.co.uk... ..# /Software Engineer/i . . . . .# ------------------------------
* . . . . .# "If you are a Visual Basic programmer, * . . .# these details are none of your
business." * . . .# Mr Bunny's Guide to Active X, by Carlton Egremont III * . .#
------------------------------ vi: set noet tw=80 sts=4 ts=8 : .