all groups > sql server misc > december 2003 >
You're in the

sql server misc

group:

sum



sum stermic NO[at]SPAM gw.co.jackson.mo.us
12/4/2003 7:59:29 AM
sql server misc: i'm trying to run a crystal report with a sum of a certain column of
dollar amounts. the problem is that there are certain instances where
some of the records are duplicated and unfortunately the duplicated
dollar amount is added into the total at the end. i'd like to know how
Re: sum John Bell
12/5/2003 2:55:28 PM
Hi

You don't say if this is a report function or a SQL function.
If you should not return duplicate rows then the would remove the added
value. If you can determine the rows to be included then you can use a CASE
statement to conditionally add up the appropriate values.

e.g

SELECT
SUM(CASE WHEN Col2 = 'Value' THEN Col1 ELSE 0 END) As ConditionalTotal
FROM MyTable

John


[quoted text, click to view]

Re: sum qazwsx
12/18/2003 10:17:41 PM
On 4 Dec 2003 07:59:29 -0800, stermic@gw.co.jackson.mo.us (Michael
[quoted text, click to view]

You don't say why the duplicates exist, but if you create a union, the
duplicate rows are by default excluded. Just repoint the report to the
new view.
AddThis Social Bookmark Button