How to retreive Monthly Sales Analysis Order By Amount And Qty.
I have Written this Query in Sql but I am getting Sum(Qty) using Pivot. I want only Qty
and Amount Not Sum.
SELECT *
FROM (SELECT QTY,AMOUNT,PRODUCT_NO,AC_NO,
DATENAME(MONTH, DATE_CREATED) [Month]
FROM invINVOICEDETAILS where DATENAME(MONTH, DATE_CREATED) in ('January','February','March','April','May',
'June','July','August','September','October','November',
'December')
GROUP BY QTY,AMOUNT,PRODUCT_NO,AC_NO,
DATENAME(MONTH, DATE_CREATED)) AS MontlySalesData
PIVOT(sum([QTY])
FOR Month IN ([January],[February],[March],[April],[May],
[June],[July],[August],[September],[October],[November],
[December])) AS MNamePivot
I want to retreive Qty,Product_No,AC_NO and Amount According to the sales in months in the year. In Reports I want to Display All Months i.e January to December and also print Qty and Amount based on Product_no according to sales in Prooper Months.
For Example: I have sold two products in the month of january.Similarly I sold 3 products in the month of Febrauary.
Now I want to display those Qty and Amount For the months of January and Febrauary.
Similarly I want to Display All Months in the report with Null values.
Here I want to display all columns from january to December.
Can u please suggest me right query for this.