Subject | Query Help? |
---|---|
Author | Lee Jenkins |
Post date | 2004-10-31T17:36:44Z |
Hello all,
I have a table with the following relevant fields:
ItemID // Integer
ProductDescription // Varchar
OrderID // Integer
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?
Thanks a bunch,
Lee
I have a table with the following relevant fields:
ItemID // Integer
ProductDescription // Varchar
OrderID // Integer
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?
Thanks a bunch,
Lee