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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 easy group by question
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mike13
Posting Yak Master

Netherlands
219 Posts

Posted - 05/04/2013 :  06:37:59  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
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

Netherlands
219 Posts

Posted - 05/04/2013 :  06:56:44  Show Profile  Click to see mike13's MSN Messenger address  Reply with Quote
found it @@rowcount duuh ;-)
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000