Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Sum function

Author  Topic 

1sabine8
Posting Yak Master

130 Posts

Posted - 2007-10-15 : 02:32:52
hi, i have a report where i need to write an expression to Sum values of Order where order = true i don't wanna sum false values. how can it be done in the report footer?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-15 : 02:36:25
SELECT SUM(CASE WHEN Order = True THEN Value ELSE 0 END) AS MySum.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-15 : 02:36:38
select sum(yourCol)
from yourTable
where order = true

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

1sabine8
Posting Yak Master

130 Posts

Posted - 2007-10-15 : 02:54:55
this is done in Sql querying. I need to do it in expression because i already got the dataset need from the query. Please help me write the expression ( sum where order = true)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-15 : 02:56:56
Are you using Reporting Services?
If so, ask moderator to move your post accordingly.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

1sabine8
Posting Yak Master

130 Posts

Posted - 2007-10-15 : 03:13:13
Yes i'm in Reporting services but how can i ask the moderator to move my post? i'm new to this forum. thx Peso
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-15 : 03:19:11
the mods are ever watchfull

Moved.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

1sabine8
Posting Yak Master

130 Posts

Posted - 2007-10-15 : 03:35:44
:) Any help over here?
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2007-10-15 : 07:25:34
You could create a group within the report, grouping by order.
Then add the textbox = Sum(count(order)) or just sum(order) to the group.
This will sum both true and false. to sum just the true will may have to change your sql as mentioned above.
Go to Top of Page
   

- Advertisement -