SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mike13
Posting Yak Master

Netherlands
214 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
214 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  
 New 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.09 seconds. Powered By: Snitz Forums 2000