Subject | Re: Need delete dupes SQL st8ment |
---|---|
Author | Adam |
Post date | 2005-02-23T23:14Z |
I am sure there is a more efficient way to do it, but I have never
had to do it with more than 1000 records so I have never needed to
optimise it further.
delete
from tableA
where code in
(
select code
from tableA a, tableA b
where a.code > b.code
and a.descr = b.descr
)
You may want to check the subselect first.
Adam
--- In firebird-support@yahoogroups.com, "Clay Shannon"
<cshannon@d...> wrote:
had to do it with more than 1000 records so I have never needed to
optimise it further.
delete
from tableA
where code in
(
select code
from tableA a, tableA b
where a.code > b.code
and a.descr = b.descr
)
You may want to check the subselect first.
Adam
--- In firebird-support@yahoogroups.com, "Clay Shannon"
<cshannon@d...> wrote:
> Who knows how to delete duplicate values in a column via SQL. Someof the
> goofy data I ported over from an MS Access "database"same
>
> Has duplicate values in a Code/Description table (different codes,
> descriptions). I want to leave just one record for each distinct
> description. IOW, instead of
>
>
>
> CODE DESCRIPTION
>
> 01 TUBERCULOUS PLEURISY IN PRIMARY
> PROGRESSIVE TUBERC
>
> 02 TUBERCULOUS PLEURISY IN PRIMARY
> PROGRESSIVE TUBERC
>
> 10 TUBERCULOUS PLEURISY IN PRIMARY
> PROGRESSIVE TUBERC
>
> 11 TUBERCULOUS PLEURISY IN PRIMARY
> PROGRESSIVE TUBERC
>
>
>
> I want to end up with just:
>
> CODE DESCRIPTION
>
> 12 TUBERCULOUS PLEURISY IN PRIMARY
> PROGRESSIVE TUBERC
>
>
>
> Or so..
>
>
>
>
>
> Clay Shannon,
>
> Dimension 4 Software
>
>
>
>
>
> [Non-text portions of this message have been removed]