Skip to content
Advertisement

Get aggregated average values joining three tables and display them next to each value in first table

I have three tables which you can also find in the SQL fiddle:

The first table contains the Sales for each product.
The second table contains details about each product.
The third table contains categories.


Now, I want to display all products and the average_sales_price_per_category next to each product.
The result should look like this:

I tried to go with the solution from this question but I get an Error:

Error

What do I need to change in my code to get the expected result?

Advertisement

Answer

You s table is not visible in inner subquery for avoid the where condition in inner subquery you could use a join on the grouped aggreated subquery

SQL Fiddle

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