SQL: Table Transformation - Union All


#1


https://www.codecademy.com/courses/sql-table-transformation/lessons/set-operations/exercises/union-all?action=lesson_resume&link_content_target=interstitial_lesson


The answer to the chapter is as shown below, can someone explain me how does the "a.sale_price part" works? Thanks in advance!

SELECT id, avg(a.sale_price) FROM (
SELECT id, sale_price FROM order_items
UNION ALL
SELECT id, sale_price FROM order_items_historic) AS a
GROUP BY 1;



Replace this line with your code.


#2

SELECT id, avg(a.sale_price) FROM (
SELECT id, sale_price FROM order_items
UNION ALL
SELECT id, sale_price FROM order_items_historic) AS a
GROUP BY 1;


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.