Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 easy group by question

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2013-05-04 : 06:37:59
Hi All,

I got this SP
SELECT   @count(dbo.T_Product_Option.PackID),@packid= dbo.T_Product_Option.PackID
FROM dbo.T_Order_Main INNER JOIN
dbo.T_Order_Detail ON dbo.T_Order_Main.ORDERID = dbo.T_Order_Detail.OrderID INNER JOIN
dbo.T_Product_Option ON dbo.T_Order_Detail.OptionID = dbo.T_Product_Option.id
WHERE (dbo.T_Order_Main.ORDERID = @orderid) AND (NOT (dbo.T_Product_Option.id IN
(SELECT optionid
FROM dbo.T_Product_Free)))
GROUP BY dbo.T_Product_Option.PackID


This has 3 records with the group by it only returns 1
But the count still returns 3
How can i get the count after the group by?

Thanks a lot

mike13
Posting Yak Master

219 Posts

Posted - 2013-05-04 : 06:56:44
found it @@rowcount duuh ;-)
Go to Top of Page
   

- Advertisement -