Query using a sum

That was my assumption, it did seem strange that OP would need to group results by id when the original query limits the results to a single id, but I’m not an SQL expert by any means. Would GROUP BY still be required when there are multiple rows with the same id? The sample I looked at just now on a tutorial suggests not. I assume there must be multiple rows with the same ID, otherwise the SUM() is redundant.

That’s what I was driving at above, when I was talking about the column names in the associative array. But the OP might be accessing the result with the numeric index.