Subject Re: [firebird-support] Query Help?
Author Arno Brinkman
Hi,

> This is the current statement that I use:
>
> SELECT
> Count(ITEMS.PRODUCTDESCRIPTION) AS CountItems,
> Sum(ITEMS.ITEMPRICE) AS TotalItems,
> ITEMS.ORDERID, ITEMS.PRODUCTDESCRIPTION,
> FROM ITEMS
> GROUP BY
> ITEMS.ORDERID,
> ITEMS.PRODUCTDESCRIPTION,
> HAVING ITEMS.ORDERID = :OrdID;
>
> What I need to do is pull both pull the records out as they were entered
> into the database, but also group them by productdescription which forces
a
> sort on the productdescription. I can't use ItemID to ORDER BY (which is
> the record id for a particular orderID) because I am forced to use to use
it
> in the GROUP BY and since the value is unique per record....
>
> Any suggestions on a work around I might try?

SELECT
Count(ITEMS.PRODUCTDESCRIPTION) AS CountItems,
Sum(ITEMS.ITEMPRICE) AS TotalItems,
ITEMS.ORDERID,
ITEMS.PRODUCTDESCRIPTION,
Min(ITEMS.ItemID)
FROM
ITEMS
GROUP BY
ITEMS.ORDERID,
ITEMS.PRODUCTDESCRIPTION,
HAVING
ITEMS.ORDERID = :OrdID
ORDER BY
5;

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://80.126.130.81