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.
Author |
Topic |
jemacc
Starting Member
42 Posts |
Posted - 2008-09-10 : 21:03:13
|
I have column duplicates that I am summing. Some of the columns have a duplicate value, for examplecol1 132col2158col3132Total290I would like to use only one value in my sum if any of the columns have the same value. How can I write this using and expression? |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-10 : 23:16:10
|
You're summing accross columns? Is that for just one row? Post the statement you are using currently to get the 290 total.Be One with the OptimizerTG |
|
|
jemacc
Starting Member
42 Posts |
Posted - 2008-09-11 : 07:05:46
|
I am just running a regular expression=Sum(Fields!ATTENDEES.Value)and hiding the duplicattes for the ATTENDEES.quote: Originally posted by TG You're summing accross columns? Is that for just one row? Post the statement you are using currently to get the 290 total.Be One with the OptimizerTG
|
|
|
Dance Doll
Yak Posting Veteran
54 Posts |
Posted - 2008-09-12 : 15:31:08
|
Using iif(Reportitem.col1=Reportitem.col3,true,false)....Save the expression to col3 property/visiblity.And try it out. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-13 : 14:11:25
|
you can do this at your backend query using SUM(DISTINCT field) |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-14 : 09:18:23
|
quote: Originally posted by Arnold Fribble
quote: Originally posted by visakh16 you can do this at your backend query using SUM(DISTINCT field)
SUM(DISTINCT) is never the right answer to anything. Well, hardly ever.Jeff Smith's piece here does a pretty good job at explaining why:http://www.sqlteam.com/article/how-to-use-group-by-with-distinct-aggregates-and-derived-tables
i know that. but the scenario OP gave sounded as if he needs just sum of distinct figures. |
|
|
jemacc
Starting Member
42 Posts |
Posted - 2008-10-07 : 09:11:18
|
quote: Originally posted by visakh16
quote: Originally posted by Arnold Fribble
quote: Originally posted by visakh16 you can do this at your backend query using SUM(DISTINCT field)
SUM(DISTINCT) is never the right answer to anything. Well, hardly ever.Jeff Smith's piece here does a pretty good job at explaining why:http://www.sqlteam.com/article/how-to-use-group-by-with-distinct-aggregates-and-derived-tables
i know that. but the scenario OP gave sounded as if he needs just sum of distinct figures.
Thank you all, but the distinct value will not give the results I need. I just need to check if there are duplicates, not to calculate on that column duplicate value, hide the duplicated and only sum the the one value |
|
|
|
|
|