If we also SELECT the id column in this case, and then use GROUP BY 1, isn’t that taking the average price of each id? Meaning, there are two items with the same id, but one is in the order_items table and one is in the order_items_historic table, and we are averaging their price. If that is the intention of the question, then fine, it’s just a little confusing because I interpreted the question as taking the average of ALL the price points on the two tables combined. So I actually wrote the same query as keishamia.
I agree with you 100% it gives a different result. That could be fine, in fact sort of makes sense if you are thinking real live avg of jeans, t-shirts, etc. Instead of avg of the whole thing. But wasn’t that clear specially from the example above that they showed.
I am having trouble with this exercise as well and am totally at a loss as to what to do here is my code SELECT count (*) FROM (
SELECT id, avg(a.sale_price) FROM order_items
SELECT id, avg(a.sale_price) FROM order_items_historic) as a;
it says Error: near line 1: no such column: a.sale_price