Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Pivot Sum is blank

$
0
0

Hi All,

I am pivoting on a balance amount and then trying to get the total of each row, but the total column is null.

CLient-client code-gl account-division-client type-CA100- CA180-CA200-CA210-Total

Acme Pty Ltd-ACM-Production-Reaching-Trade-5213.06-null-null-null-null

Bunnies Ltd-BUN-Testing-Fankt-Local-null-2427-null-null-null

select *,
		pvt.[CA100 - Work in progress gross] + pvt.[CA180 - Work in progress prov] + pvt.[CA200 - Trade and related receivables gross] + pvt.[CA210 - Accrued revenue - External] AS [Total]
from
(
select distinct
		c.CLIName1 as [Client],
		c.CLICode as [Client Code],
		a.COACode2Name1 as [GL Account Group],
		a.COAName1 as [GL Account],
		l.GNLBalanceBase as [Closing Balance],
		--c.CLIID,
		--o.CLOID,
		--d.DIVID,
		--o.CLODIVID,
		d.DIVName1 as [Division],
		t.CLTName1 as [Client Type]
from xx.yyy c
inner join [vwChartOfAccount] a
on a.[COASourceID] = c.[CLISourceID]
inner join [vwChartOfAccountGroup] g
on g.[AGPID] = a.COAAGPID
inner join [vwGeneralLedger] l
on l.GNLID = c.[CLIID]
inner join [vwclientOwner] o
on o.CLOID = c.CLIID 
inner join [vwDivision] d
on d.DIVID = o.CLODIVID
inner join [vwClientType] t
on t.CLTID = c.[CLICLTID]
where a.COACode2Name1 like 'CA100%' or a.COACode2Name1 like 'CA180%' or a.COACode2Name1 like 'CA200%' or a.COACode2Name1 like 'CA210%'
)srce
PIVOT 
(SUM([Closing Balance]) 
for [GL Account Group] IN(
[CA100 - Work in progress gross],
[CA180 - Work in progress prov],
[CA200 - Trade and related receivables gross],
[CA210 - Accrued revenue - External]
))as pvt
group by pvt.Client,pvt.[Client Code], pvt.[Client Type], pvt.Division, pvt.[GL Account], pvt.[CA100 - Work in progress gross], pvt.[CA180 - Work in progress prov], pvt.[CA200 - Trade and related receivables gross], pvt.[CA210 - Accrued revenue - External]

Thanks for any help.

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>