4 ms·
No, it is the other way, Python is translated to SQL, not vice versa ;) According to SQL standard, aggregate functions must skip NULL values. The problem is wi
by kozlovsky 13y ago
No, it is the other way, Python is translated to SQL, not vice versa ;)
According to SQL standard, aggregate functions must skip NULL values. The problem is with queries which return no rows. In this case, intuitive expected result of SUM aggregate function is zero, but, because of some quirk in SQL standard, SUM must return NULL if no rows were found.
Without coalesce function, result of SUM will be returned as None if no rows were found. Coalesce replaces this surprising None with zero.
- aleyan 13y agoDuh, of course. This is what happens when I don't read the explanation and just grab on to the first pieces of code I see. Thanks.