Oracle
Select * fromGcfr_t_vch_delete EWHEREE.rowid<(SELECT Max(X.rowid) fromGcfr_t_vch_delete XWHEREX.vchno=E.vchno andE.type=X.type andE.curragency=x.curragency);--orSelect * fromGcfr_t_vch_delete EWHEREE.rowid>(SELECT min(X.rowid) fromGcfr_t_vch_delete XWHEREX.vchno=E.vchno andE.type=X.type andE.curragency=X.curragency);
The type of voucher, the number, the unit is the basis for judging the repetition. Delete Duplicates is to delete the superfluous and leave only one. The meaning of the above SQL is to find out the duplicate records, with a maximum value of the standard, the less than his are deleted. Or, by the smallest criterion, delete the larger than his. This is exactly what is needed.
Oracle uses ROWID to ensure the uniqueness of the data, but it is also possible to use a table field, but it is best to be the primary key in order to ensure the uniqueness of the fields.
Mysql
Select * fromGcfr_t_vch_delete EWHEREE.guid<(SELECT Max(X.guid) fromGcfr_t_vch_delete XWHEREX.vchno=E.vchno andE.type=X.type andE.curragency=x.curragency);--orSelect * fromGcfr_t_vch_delete EWHEREE.guid>(SELECT min(X.guid) fromGcfr_t_vch_delete XWHEREX.vchno=E.vchno andE.type=X.type andE.curragency=X.curragency);
MySQL has no rowid here, in the case of GUIDs, the GUID is the primary key of the table.
Delete duplicate records in a database table