SQL:
SELECT
CASE
WHEN (Grouping(CategoryName)=1) THEN 'MainTotal'
ELSE CategoryName
END AS CategoryName,
CASE
WHEN (Grouping(ProductName)=1) THEN 'SubTotal'
ELSE Productname
END AS ProductName,
Sum(UnitPrice) as UnitPrice,
Sum(UnitsinStock) as UnitsInStock
FROM Products
INNER JOIN Categories On
Products.CategoryID = Categories.CategoryID
GROUP BY CategoryName, ProductName WITH ROLLUP
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
...
GROUP BY categoryname, subcategoryname, productname WITH ROLLUP
If this doesn't answer your question please post DDL for this table, post
INSERT statements to generate a few rows of sample data and show your
required result.
--
David Portas
------------
Please reply only to the newsgroup
--