Results 1 to 4 of 4

Thread: Sum in Report

  1. #1
    Join Date
    Sep 2006
    Location
    East Coast Of America
    Posts
    15

    Sum in Report

    How can I list every items in the report but not calculate them in the group aggregation function?
    For example:

    col1 col2 col3 col4 col5
    2 5 1 3
    1 4 7 9 N
    6 3 1 6

    Sum like:
    8 8 2 9

    The row with "N" will not be calculated in Sum function.

    Thank you for the help!

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    how can you get sum without using SUM()?

  3. #3
    Join Date
    Dec 2004
    Posts
    502
    I'm not sure what your data could look like, but how about something like this?

    SELECT
    SUM(CASE WHEN col5 <> 'N' THEN col1 ELSE 0 END) AS col1,
    SUM(CASE WHEN col5 <> 'N' THEN col2 ELSE 0 END) AS col2,
    SUM(CASE WHEN col5 <> 'N' THEN col3 ELSE 0 END) AS col3,
    SUM(CASE WHEN col5 <> 'N' THEN col4 ELSE 0 END) AS col4,
    SUM(CASE WHEN col5 <> 'N' THEN col5 ELSE 0 END) AS col5
    FROM YourTable

  4. #4
    Join Date
    Sep 2006
    Location
    East Coast Of America
    Posts
    15
    I am talking about Reporting Services here.
    How can I exclude certain row(s) from the aggregation group?
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •