Quantcast
Channel: SCN: Message List - Reporting and Printing
Viewing all articles
Browse latest Browse all 2719

Re: Sales by State report

$
0
0

Hi,

 

Try this query:

 

Select [S] as State, [W] as warshouse,[Jan]= sum([1]), [Feb]= sum([2]), [Mar]= sum([3]), [Apr]= sum([4]),  [May]= sum([5]), [June]= sum([6]), [July]= sum([7]), [Aug]= sum([8]), [Sept]= sum([9]), [Oct]= sum([10]), [Nov]= sum([11]), [Dec]= sum([12]), total = sum (isnull([1],0)+ isnull([2],0) + isnull([3],0) + isnull([4],0) +  isnull([5],0) + isnull([6],0) + isnull([7],0) + isnull([8],0) + isnull([9],0)+ isnull([10],0) + isnull([11],0) + isnull([12],0))

from(

SELECT T0.[State1] as S, T2.[WhsCode] as W,month(T1.[DocDate]) as month, sum(T1.[DocTotal]) as T FROM OCRD T0  INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode INNER JOIN INV1 T2 ON T1.DocEntry = T2.DocEntry WHERE year(T1.[DocDate]) = year(getdate()) GROUP BY T0.[State1], T2.[WhsCode],T1.[DocDate] ) s

Pivot
(sum(t) for month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P

group by [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[S],[W]

 

Thanks & Regards,

Nagarajan


Viewing all articles
Browse latest Browse all 2719

Trending Articles



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