I have tried the following query to get the Total Sales order created on month wise.
I want this sort of all Sales Documents in single query. For Sales Order, Delivery, AR Invoice.
I am getting the following error
"1). [Microsoft][SQL Native Client][SQL Server]Column 'OPOR.DocDate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 2). [Microsoft][SQL Native Client][SQL Server]No column was specified for column 1 of 'S'. 3). [Microsoft][SQL Native Client][SQL Server]The column prefix 't0' does not match with a table name or alias name used in the query. 4). [Microsoft][SQL Native Client][SQL Server]Cannot find either column "P" or the user-defined function or aggregate "P.Count", or the name is ambiguous. 5). [Microsoft][SQL Native Client][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared."
 as [Jan],
 as [Feb],
 as [Mar],
 as [Apr],
 as [May],
 as [Jun],
 as [Jul],
 as [Aug],
 as [Sep],
 as [Oct],
 as [Nov],
 as [Dec]
(SELECT Count(t0.docentry), month(t0.docdate) as 'Month'
FROM OPOR T0
WHERE T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1]) S
Pivot (Count(t0.docentry) FOR [Month] IN (,,,,,,,,,,,)) P
How to Fix this ?