Hi guys below is my query that filter my data correctly but i fail to pivot it correctly. This is for report that i want to run in my crm 2015 version
SELECT
AH.customername,
AH. accountdate,
AH. revenue,
EA.AccountNumber,
DATENAME(month, AH.accountdate) As AccountMonth,
DATEADD(year,-1,(dateadd(month, datediff(month, -1, getdate()) - 1, -1) + 1)) AS StarDate
FROM
Filteredaccounthistory AH
INNER JOIN Account EA ON EA.Customer = AH.customer
WHERE AH.accountdate>= DATEADD(year,-1,(dateadd(month, datediff(month, -1, getdate()) - 1, -1) + 1))
AND AH.accountdate<= dateadd(month, datediff(month, -1, getdate()) - 1, 1)
AND DATEDIFF(month,DATEADD(year,-1,(dateadd(month, datediff(month, -1, getdate()) - 1, -1) + 1)), dateadd(month, datediff(month, -1, getdate()) -1, 1)) =12
ORDER BY AH.customername ASC
currently im getting:
and I want to archive this:
I will appreciate your help
*This post is locked for comments