Subject | SP To Compute Sales Report |
---|---|
Author | Muthu Annamalai |
Post date | 2004-07-08T20:10:48Z |
Dear Friends,
I need help with my SP. I have given my SP below.
----------------------SP------------------------
CREATE PROCEDURE REPORTWEEKSALES
( FROMDATE DATE )
RETURNS
(
SALESDAY DATE,
RECEIPTS INTEGER,
SALES DECIMAL(18,2),
AVERAGESALES DECIMAL(18,2)
)
AS
BEGIN
FOR SELECT CAST(RECEIPTDATE AS DATE),
COUNT(CAST(RECEIPT.RECEIPTNUMBER AS INTEGER)),
SUM(RECEIPT.AMOUNT),
AVG(RECEIPT.AMOUNT)
FROM RECEIPT
WHERE CAST(RECEIPT.RECEIPTDATE AS DATE)
BETWEEN :FROMDATE AND :FROMDATE + 6
GROUP BY RECEIPTDATE
INTO :SALESDAY,:RECEIPTS,:SALES,:AVERAGESALES
DO SUSPEND;
END
---------------------SP end-------------------------
This SP is returning
salesday receipts sales averagesales
18.6.2004 1 50 50
18.6.2004 1 45 45
What I want is
salesday receipts sales averagesales
18.6.2004 2 95 47.5
Need Help
Thanks
Muthu Annamalai
I need help with my SP. I have given my SP below.
----------------------SP------------------------
CREATE PROCEDURE REPORTWEEKSALES
( FROMDATE DATE )
RETURNS
(
SALESDAY DATE,
RECEIPTS INTEGER,
SALES DECIMAL(18,2),
AVERAGESALES DECIMAL(18,2)
)
AS
BEGIN
FOR SELECT CAST(RECEIPTDATE AS DATE),
COUNT(CAST(RECEIPT.RECEIPTNUMBER AS INTEGER)),
SUM(RECEIPT.AMOUNT),
AVG(RECEIPT.AMOUNT)
FROM RECEIPT
WHERE CAST(RECEIPT.RECEIPTDATE AS DATE)
BETWEEN :FROMDATE AND :FROMDATE + 6
GROUP BY RECEIPTDATE
INTO :SALESDAY,:RECEIPTS,:SALES,:AVERAGESALES
DO SUSPEND;
END
---------------------SP end-------------------------
This SP is returning
salesday receipts sales averagesales
18.6.2004 1 50 50
18.6.2004 1 45 45
What I want is
salesday receipts sales averagesales
18.6.2004 2 95 47.5
Need Help
Thanks
Muthu Annamalai