 			p.Ukprn, 
 			p.Uln, 
 			p.PeriodEnd, 
-			PaymentId, 
-			FundingSource, 
-			Amount, 
+			p.PaymentId, 
+			p.FundingSource, 
+			p.Amount, 
 			p.PaymentMetaDataId, 
 			ptt.[Description] AS TransactionTypeDesc,
 			meta.ProviderName AS TrainingProvider,

		INNER JOIN [employer_financial].[PaymentMetaData] meta 
			ON p.PaymentMetaDataId = meta.Id
	WHERE  p.AccountId = @AccountId
		AND DateCreated >= @FromDate 
		AND DateCreated <= @ToDate
		AND p.FundingSource in (1,2,3)
)
, UniqueApprenticePaymentRecords -- This gets all the unique Account, Provider, Learner, PeriodEnd combinations

	tl.EmpRef,
	ld.PayrollYear,
	ld.PayrollMonth,
	tl.LevyDeclared,
	tl.EnglishFraction,
	tl.Amount - (LevyDeclared * EnglishFraction) AS TenPercentTopUp,
	tl.Amount
FROM [employer_financial].TransactionLine tl
