1
Reply

Write a single query to calculate the sum of all positive values of x and he sum of all negative values of x.

Rajeev Kumar

Rajeev Kumar

1y
1.6k
0
Reply

suppose here we have a table name Student which has a coulmn grade.
age
31
-22
22
-25
28
35
-23

    select sum(case when x>0 then x else 0 end)sum_pos,sum(case when x<0 then x else 0 end)sum_neg from Test;