Click to See Complete Forum and Search --> : Data Report & SQL
SSB
Feb 5th, 2003, 09:46 AM
I have a problem where I have to produce a report from a transaction file with a total of all negative values in one column and a total of all positive values in another. I have been hitting my head against a brick wall trying to find an SQL expression that will do it.
Can anyone help?
brucevde
Feb 5th, 2003, 11:20 AM
What database? If SQL Server then you could use the Case statement.
Select
Sum(Case When qty < 0 Then qty Else 0 End) as NegSum,
Sum(Case When qty > 0 Then qty Else 0 End) as PosSum
From ...
SSB
Feb 6th, 2003, 03:55 AM
I am using the Jet database. Tried using Case but it wasn't recognised. Have tried again using IIf() and seems to work. Many thanks - i'd spent many hours on that one!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.