Solved

Performing SUM on GROUP in SQL 2005 Reporting Services

Posted on 2007-04-10
5
6,217 Views
Last Modified: 2010-03-15
I am using SQL 2005 reporting services accessing a SQL 2000 server (I'm going to migrate the data over later).

The program I am having is that I am grouping on a field but when I try and sum on another field, it adds up all of the items instead of those just being displayed.

For example, this would be a collection of records:
partnumber;note;price
part1,note1,5.0
part1,note2,5.0
part1,note3,5.0
part2,note1,3.0
part2,note2,3.0

Well I want it to just sum up the 5 and 3 once and give me 8, instead it give me 21.

I'm looking to just perform a SUM on the items that are actually displayed on the screen.  I have searched all over and found others with similar problems, but no solution.

I have been able to do a SUM just on the ReportItems!textbox.Value, but the problem with that is I can only place the results on header or footer.
0
Comment
Question by:ritetrack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18885501


do you mean?
select a.partnumber,a.note,sum(case when a.note=b.minnote then a.price else null end) as totalprice
from yourtable as a
inner join (select partnumber,min(note) as minnote from yourtable group by partnumber) as b
 on a.partnumber=b.partnumber
group by a.partnumber,a.note
order by 1,2
0
 

Author Comment

by:ritetrack
ID: 18886439
No, this really needs to be done in the reporting services rather than the SQL statement.  The reason is that in some cases your SQL statement might work, I have other cases that I would group on the item number and only want to grab the value once, but I would want to show the comments in the details.  For example, the results of the report from the original dataset I put might look like:
------------------------------------
part1 - $5
 - note1
 - note2
 - note3

part2 - $3
 - note1
 - note2

Total of parts: $8
------------------------------------
Where this can come more into play is when I have multiple groups (i.e. group by region, then by customer, then show the detail for a customer)
0
 
LVL 2

Accepted Solution

by:
itstheride earned 250 total points
ID: 21345356
not sure if this is what your after...

sum(columnName, "grp_Customer") where "grp_Customer"  is the name of your group. do this on the group footer.


0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question