Reputation: 33387
I have the following stored procedure
BEGIN
SELECT kids.*, SUM(point) as `point_sum`
FROM kids
LEFT JOIN tasks
ON kids.id = tasks.kid_id
WHERE kids.user_id = IN_user_id
GROUP BY kids.name;
END
This statement works fine.
My Question: the SUM(point)
for new users are typically NULL because there is no submitted value yet to be summed.
What I want is if SUM(point)
is NULL
then it should return value like 0
but otherwise it should present the sum. I have looked around and not sure how to fix it, any good ideas?
Upvotes: 1
Views: 166