Subject Re: [firebird-support] Group By in For Select
Author Ann W. Harrison
Muthu Annamalai wrote:
> I have this following Stored Procedure and I need to group by a
> column but I am getting Invalid expression in Select List error
>
> FOR SELECT RECEIPTDATE, RECEIPTDETAILS.ID, ITEMSTYLEID,
> SUM(RECEIPTDETAILS.QUANTITY * RECEIPTDETAILS.PRICE)
> FROM RECEIPT, RECEIPTDETAILS
> WHERE RECEIPT.ID = RECEIPTDETAILS.RECEIPTID AND
> RECEIPT.RECEIPTDATE BETWEEN :FROMDATE AND :TODATE
> GROUP BY 3
> INTO SALESDATE, RECEIPTDETAILSID, ITEMSTYLEID, SALES
> DO
> BEGIN
> /* Code removed for simplicity */
> SUSPEND;
> END
>

You're grouping by ItemStyleID, but reference ReceiptDate
in the select list without aggregating it.

Try either GROUP BY 1, 3 or SELECT MAX(ReceiptDate) ...


Regards,


Ann