Trying to perform group by operation where records should be grouped only when percentage is less then 100, if 100 or more it should be kept as is.
Sample Data:
Expected Output:
Group by query I am trying is:
SELECT ID,SUM(Percentage),SUM(Value)
From table
GROUP BY ID
Select data with <100 and >=100 independently, and the use UNION BY
:
SELECT ID, SUM(Percentage), SUM(Value)
From table
where Percentage < 100
GROUP BY ID
UNION ALL
SELECT ID, Percentage, Value
From table
where Percentage>=100