Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get one record from duplicate

Status
Not open for further replies.

TheLazyPig

Programmer
Sep 26, 2019
103
PH
Hi!

The record of my table should not have duplicate, if there is a duplicate I want to get one exact data and add their dedamt.

duplcate_xb950y.jpg


the dedamt should be 1,390.00

Note: The other one should be deleted

Thanks in advance!
 
Hi,

You may want to SELECT yourFields, SUM(dedamt) FROM ... GROUP BY ... INTO ...

hth

MarK
 
Hello,

I cannot see a unique primary key in the data, so handling update/delete maybe tricky.
Remember with group you need to have all mentioned fields included in group by or use an aggregate like max() on them.

Basically I would think of a scan endscan , check if last whatever differs and mark for delete (maybe blank some fields) or go back to last rec and store sum
Maybe easier is to combine it by first getting the sums via select .. group then scan endscan with storing sum in first record , on next record check whatever and if same mark for delete.

Regards
tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top