select CustomerID,InvoiceNumber,
max(case when TaxCode = 2 then TotalTaxLocalAmount end) as State,
max(case when TaxCode = 3 then TotalTaxLocalAmount end) as Fed,
max(case when TaxCode = 4 then TotalTaxLocalAmount end) as County
from dbo.Z_TaxProject
group by CustomerID,InvoiceNumber
|