summing up of two rows

Asked by At

Input:

A       
-----
 5000      
 4000      
-3000
-2000

Output:

A      FEEDBACK
-----  --------
 9000  POSITIVE
-5000  NEGATIVE

THEY HAVE GIVEN THE INPUT. I NEED TO WRITE A CODE TO BRING THE OUTPUT.

1 Answers

1
The Impaler On

I think this query should do:

select sum(a) as a, 'POSITIVE' as feedback from t where a >= 0 
union
select sum(a) as a, 'NEGATIVE' as feedback from t where a < 0