suppose here we have a table name Student which has a coulmn grade.
age
31
-22
22
-25
28
35
-23
Interviews1 answer
Write a single query to calculate the sum of all positive values of x and he sum of all negative values of x.
1 Answer
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;
Rajeev KumarPosted Jul 10, 2023, 5:33 AM EDT
