SQL Server Performance

sum of a count

Discussion in 'SQL Server 2005 Reporting Services' started by makri, Jan 18, 2007.

  1. makri New Member

    Hello guys,

    I have a query that returns me the following:

    PROBLEMNAME PROBLEMCOUNT
    ----------- ------------
    A 5
    B 10
    C 7
    D 9

    I want also to get the sum of my problem counts on each row if possible so that the response looks like this:

    PROBLEMNAME PROBLEMCOUNT SUM
    ----------- ------------ ---
    A 5 31
    B 10 31
    C 7 31
    D 9 31

    31 being the sum of my problemcounts (5 + 10 + 7 + 9 = 31)

    Is there a way to do this?

    Thanks in advance,

    Mike
  2. Babin New Member

    Mike,
    You can use "Sum()" function.
    In SQL reporting, Sum(Fields!PROBLEMCOUNT)
    In SQL Query, Select PROBLEMNAME, PROBLEMCOUNT, Sum(PROBLEMCOUNT) from <Table Name>
  3. Luis Martin Moderator

    Kindly don't duplicate posts.


    Luis Martin
    Moderator
    SQL-Server-Performance.com

    All in Love is Fair
    Stevie Wonder


    All postings are provided “AS IS” with no warranties for accuracy.



Share This Page