select TAX as TAXID,  sum(SUBTOTAL * ITSPERCENTAGE / 100) as TOTALTAX
from SALESINVOICELINE 
join INVITEM on INVITEM.ITSID = SALESINVOICELINE.INVITEM
join INVITEMTAXCATEGORY on INVITEMTAXCATEGORY.ITSID = INVITEM.TAXCATEGORY
join INVITEMTAXCATEGORYLINE on INVITEMTAXCATEGORYLINE.ITSOWNER = INVITEMTAXCATEGORY.ITSID
where SALESINVOICELINE.REVERSEDID is null and SALESINVOICELINE.ITSOWNER = :ITSOWNER
group by TAX;
