> b2b=> select * from biztypes;
> bizid | biztype
> -------+-----------
> B11 | logistics
> B11 | logistics
> B11 | logistics
> B11 | logistics
> B11 | logistics
> (5 rows)
>
> b2b=>delete from biztypes where exists (select * from biztypes b2 where
> biztypes.bizid=b2.bizid)
>
> DELETE 5
> b2bscm=> select * from test1;
> bizid | biztype
> -------+---------
> (0 rows)
>
> all the records been deleted.
> the result should be :
>
> bizid | biztype
> -------+-----------
> B11 | logistics
>
Sorry, I forgot this code works only if you have any field which is
primary key or any other unique identifier - for example oid.
It will look then:
delete from biztypes where exists (select * from biztypes b2 where
biztypes.bizid=b2.bizid and biztypes.oid<>b2.oid)
If you don't have any unique identifier for rows in your table, the only
way to delete this record is creating a copy of this table:
create table some_copy as
selectbizid,biztype
from biztypes group by bizid,biztype;
drop table biztypes;
alter table some_copy rename to biztypes;
Regards,
Tomasz Myrta