Skip to content
Advertisement

SQL how do I sum up a has many relationship

So I have the following table, I managed to join users and membership tables just fine with a left join however I’ve been unsuccessful at summing up the individual customers’ total.

Here’s my code, the one-to-one associations seem to be doing fine however the summing up of the total seems to not display, what am I doing wrong? is there a different way of summing up a one-to-many association?

Tables

Desired output:

Advertisement

Answer

You need to group by user.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement