Subject | Monthly Report Stored Procedure |
---|---|
Author | Muthu Annamalai |
Post date | 2005-12-09T17:42:58Z |
I am trying to create a stored procedure for a report which provides
monthly total sales.
The report I am trying to generate is to get total sales for each
month for last 12 months. I have values in my Receipt Table.
The incomplete stored procedure is as follows
----Stored Procedure------
CREATE PROCEDURE REPORT_MONTHLY_SALES
RETURNS (
JAN NUMERIC(15,2),
FEB NUMERIC(15,2),
MAR NUMERIC(15,2),
APR NUMERIC(15,2),
MAY NUMERIC(15,2),
JUN NUMERIC(15,2),
JUL NUMERIC(15,2),
AUG NUMERIC(15,2),
SEP NUMERIC(15,2),
OCT NUMERIC(15,2),
NOV NUMERIC(15,2),
DCR NUMERIC(15,2))
AS
BEGIN
SELECT SUM(AMOUNT)
FROM RECEIPT
WHERE CAST(RECEIPT.RECEIPTDATE AS MONTH) = 'JANUARY'
INTO :JAN;
/** the procedure continues for each month like this **/
SUSPEND;
END
----code end----
Any suggestions help is highly appreciated
Muthu Annamalai
www.pearlpos.com
monthly total sales.
The report I am trying to generate is to get total sales for each
month for last 12 months. I have values in my Receipt Table.
The incomplete stored procedure is as follows
----Stored Procedure------
CREATE PROCEDURE REPORT_MONTHLY_SALES
RETURNS (
JAN NUMERIC(15,2),
FEB NUMERIC(15,2),
MAR NUMERIC(15,2),
APR NUMERIC(15,2),
MAY NUMERIC(15,2),
JUN NUMERIC(15,2),
JUL NUMERIC(15,2),
AUG NUMERIC(15,2),
SEP NUMERIC(15,2),
OCT NUMERIC(15,2),
NOV NUMERIC(15,2),
DCR NUMERIC(15,2))
AS
BEGIN
SELECT SUM(AMOUNT)
FROM RECEIPT
WHERE CAST(RECEIPT.RECEIPTDATE AS MONTH) = 'JANUARY'
INTO :JAN;
/** the procedure continues for each month like this **/
SUSPEND;
END
----code end----
Any suggestions help is highly appreciated
Muthu Annamalai
www.pearlpos.com