By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,958 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,958 IT Pros & Developers. It's quick & easy.

SQL SUM Questions

P: n/a
I am using the follwoing SQL query:

SELECT RECID, PATNUMBER, Sum(amount) As Amount
FROM PAT_Transactions
Group By recid, patnumber
Having patnumber = 374757 AND recid = 'C'
Order By patnumber

My problem is that there are rows that have a a negative amount. I want to
add only the positive amount rows together. This query adds all the rows for
each patient number positive and negitive to give me the total.

How do I tell SQL to add only the positive row amounts together?

Thanks in advance!!

Mike
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jj
Hi Mike

Put in Where amount > 0

SELECT RECID, PATNUMBER, Sum(amount) As Amount
FROM PAT_Transactions
WHERE Amount>0
Group By recid, patnumber
Having patnumber = 374757 AND recid = 'C'
Order By patnumber

/JJ

"Mike" <no***@forgetit.com> skrev i en meddelelse
news:k7****************@newssvr24.news.prodigy.net ...
I am using the follwoing SQL query:

SELECT RECID, PATNUMBER, Sum(amount) As Amount
FROM PAT_Transactions
Group By recid, patnumber
Having patnumber = 374757 AND recid = 'C'
Order By patnumber

My problem is that there are rows that have a a negative amount. I want to
add only the positive amount rows together. This query adds all the rows
for each patient number positive and negitive to give me the total.

How do I tell SQL to add only the positive row amounts together?

Thanks in advance!!

Mike

Nov 13 '05 #2

P: n/a
where amount > 0 ?

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.