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

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

By Rajeev Kumar in .NET on Jul 07 2023
  • Rajeev Kumar
    Jul, 2023 10

    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;

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS