|
Posted by Erland Sommarskog on 01/14/06 00:43
(pipe.jack@gmail.com) writes:
> Another one for you:
> How many orders included a product. If the quantity of the product in a
> single order is more then 1 then it should still count as 1 since I'm
> interested in the number of orders.
SELCET COUNT(DISTINCT OrderID), ProductName
FROM OrderDetails
GROUP BY ProductName
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|