How do i sum the 'No. of Negative Cases', 'No. of Positive Cases' as well as 'No. of

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • winnie12
    New Member
    • Sep 2013
    • 1

    #1

    How do i sum the 'No. of Negative Cases', 'No. of Positive Cases' as well as 'No. of

    Code:
    select case when  adjAmount < 0 then 'No. of Negative Cases'
    			when  adjAmount > 0 then 'No. of Positive Cases'
    			else 'No. of Null Cases'
    			end as Report,procEndDate,
    			count(adjAmount)
    from dbo.tblProductivity_HIS_DEV8 
    
    where procEndDate between '2013-04' and '2014-04' and procstatus = 'Complete' and inventory = 'N'
    and (reportingBucketCategory = 'Audit' or
    (reportingBucketCategory = 'Services' and (adjAmount = 0.00 or adjAmount is null)) or
    (reportingBucketCategory is null and (adjAmount = 0 or adjAmount is null or adjAmount > 0)))
    
    group by  case when  adjAmount < 0 then 'No. of Negative Cases'
    			when  adjAmount > 0 then 'No. of Positive Cases'
    			else 'No. of Null Cases'
    			end,procEndDate
    order by procEndDate
    Last edited by Rabbit; Sep 19 '13, 03:27 PM. Reason: Please use code tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Looks like you already have the SQL to do that. What problem are you having with it?

    Comment

    Working...