By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

I have a Problem With Stored proc_ help needed

P: 36
Hi,.. to all..

I have quierry in stored procecedure. ie:

select distinct Member_ID,m_displayname,brand_name,Brand_ID,produc t_id,
count(product_id) as ImagesCount from dbo.vSMgr_ImageReport
where brand_owner = @MemberID
group by brand_id, brand_name,product_id,Member_ID,m_displayname.

In the above quierry ImagesCount is the sum(product_id)...

Now i need sum(ImagesCount) how can i get using that same quierry...

Help shold be thankfull...

Apr 22 '08 #1
Share this Question
Share on Google+
1 Reply

P: 92
Try it like this:
Expand|Select|Wrap|Line Numbers
  1. select *, sum(ImagesCount) As SumImagesCount
  2. from
  3. (
  4. select distinct Member_ID,m_displayname,brand_name,Brand_ID,product_id,
  5. count(product_id) as ImagesCount from dbo.vSMgr_ImageReport          
  6. where brand_owner = @MemberID
  7. group by brand_id, brand_name,product_id,Member_ID,m_displayname
  8. )
If your purpose of getting the sum of all ImagesCount is just for display, you might consider doing it in your front-end application rather than doing it in your query where it causes additional overhead.
Apr 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.