Results 1 to 3 of 3

Thread: Data Report & SQL

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    2

    Data Report & SQL

    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?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    What database? If SQL Server then you could use the Case statement.

    Code:
    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 ...

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    2
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width