I have this data:
Id Name amount Comments
-------------------------------
1 n1 421762 Hello
2 n2 421 Bye
3 n2 262 null
4 n2 5127 ''
Each name may or may not have extra rows with null or empty comments.
How can I group by name and sum(amount) such that it ignores/absorbs the null or empty comments in the grouping and shows me only 2 groups.
Output I want:
Id Name sum(amount) Comments
------------------------------------
1 n1 421762 Hello
2 n2 5180 Bye
I can't figure this out.
I hoped that would ignore the null/empty values but I always end up with 4 groups
select id, name, sum(amount), comments
from table
group by id, name, comments