Re: Find a duplicate value via SQL
Posted in 1998
On Tue, 15 Sep 1998 Tim_Clifton@candle.com wrote:
> This is undoubtedly a pedestrian question to some of you, but as I am
> new to SQL...... Does anyone know of a quick way to find records that
> contain duplicate values for a particular field via SQL? Or is this done
> is SPL?
It isn't make it particularly easy, nor particularly hard...
SELECT *
FROM SomeTable
WHERE ParticularField IN (SELECT ParticularField
FROM SomeTable
GROUP BY ParticularField
HAVING COUNT(*) > 1
)
Of course, if you needed to look for duplicates pairs of columns, life
would be a lot tougher...
Yours,
Jonathan Leffler (jleffler@informix.com) #include <witticism.h>
Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN
Informix IDN for D4GL & Linux -- http://www.informix.com/idn