Subject Re: Group By in For Select
Author Adam
--- In firebird-support@yahoogroups.com, "Muthu Annamalai"
<pearlamerica@...> 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

You must include ALL non aggregate fields in your group by.

> GROUP BY 3

The following line should have colons before your variable/parameter

> INTO SALESDATE, RECEIPTDETAILSID, ITEMSTYLEID, SALES

In other words.

INTO :SALESDATE, :RECEIPTDETAILSID, :ITEMSTYLEID, :SALES

Adam