I have problem with GROUP BY statement.
I have a table TEST:

And I want to execute following select statement:
select sum(a)
from TEST
group by a+b
Here is the result:
SUM(A)
3
1
3
It works, but I have no idea why. What expression a+b does with GROUP BY statement?
Thanks.
//edit, sorry for that huge image. I will change it
Try this…
SELECT 2 + NULLand see what you get.The answer isn’t
2, it’sNULL.So, using your example data…
The sum of
AwhereA+BisNULLis…3The sum of
AwhereA+Bis1is……1The sum of
AwhereA+Bis5is……3You can circumvent this using
COALESCE(a, 0) + COALESCE(b, 0)