select SUM(total) from MyTax mt1 inner join ( select Code,ID,TaxYear,Data,max(date) as FinalDate from MyTax group by Code,ID,TaxYear,Data) mt2 on mt1.Code = mt2.Code and mt1.ID = mt2.ID and mt1.Data = mt2.Data and mt1.TaxYear = mt2.TaxYear and mt1.date = mt2.date
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)