![]() |
Excel Report Template - Monthly Sales 2See Microsoft ® Excel ® Report
Function and SQL
/* Calculate the sales amount */
@F1_1=REPORT(sheet="Report1" type=fix cell=F7,G7)
SELECT Year(o.OrderDate)*100 + MONTH(o.OrderDate)
, Sum(d.UnitPrice * d.Quantity * (1-d.Discount))
FROM Orders o
,OrderDetails d
WHERE o.OrderID = d.OrderID
AND o.OrderDate >= DateAdd('m',-5,'$ReportMonth-01')
AND o.OrderDate < DateAdd('m',1,'$ReportMonth-01')
GROUP BY Year(o.OrderDate)*100 + MONTH(o.OrderDate)
ORDER BY 1 DESC
;
/* Calculate the number of customers and the number of orders */
@F1_2=REPORT(sheet="Report1" type=fix cell=D8,D10)
SELECT COUNT(CustomerID), COUNT(OrderID)
FROM Orders
WHERE YEAR(OrderDate) = YEAR('$ReportMonth-01')
AND MONTH(OrderDate) = MONTH('$ReportMonth-01')
;
/* Calculate the quantity of products */
@F1_3=REPORT(sheet="Report1" type=fix cell=D12)
SELECT SUM(d.Quantity)
FROM Orders o
,OrderDetails d
WHERE o.OrderID = d.OrderID
AND YEAR(o.OrderDate) = YEAR('$ReportMonth-01')
AND MONTH(o.OrderDate) = MONTH('$ReportMonth-01')
;
These sample reports are generated by XLReportGen (Report Generator for Microsoft Excel). The sample reports in Microsoft Excel spreadsheet format can be download for your report templates, and changed to adapt to your own needs. It is free. Download the report samples in Microsoft Excel spreadsheet format XLS (301KB)
|
Copyright © 2004 - 2006 LJZsoft Corporation. All rights reserved.