Skip to content
Advertisement

Find average SQL statement multiple tables

Trying to get the average with a amount of times a user has purchases brocolli and then with the price at that time. A 0 if the user has not purchased any. This is working and saying it can’t see the Name column. What am I missing?

EDIT

verag

I also tried simplifying to just use the purchasers table and get wrong results but maybe I can tweek this as it runs.

To be honest this was in part this issue with the compiler I was using as it was browser site compiler so even when I had it working on my machine it was giving different results on the site. I ended using an inner join on the two tables. Update This ran correctly for the answer. Thank you.

Advertisement

Answer

You need a LEFT JOIN of USERS to PURCHASES and GROUP BY user:

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