I have a Problem With Stored proc_ help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mvmashraf
    New Member
    • Oct 2007
    • 36

    I have a Problem With Stored proc_ help needed

    Hi,.. to all..

    I have quierry in stored procecedure. ie:

    select distinct Member_ID,m_dis playname,brand_ name,Brand_ID,p roduct_id,
    count(product_i d) as ImagesCount from dbo.vSMgr_Image Report
    where brand_owner = @MemberID
    group by brand_id, brand_name,prod uct_id,Member_I D,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...

    @shraf
  • deric
    New Member
    • Dec 2007
    • 92

    #2
    Try it like this:
    Code:
    select *, sum(ImagesCount) As SumImagesCount
    from
    (
    select distinct Member_ID,m_displayname,brand_name,Brand_ID,product_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
    )
    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.

    Comment

    Working...