SELECT
s.date_formatted AS "date",
s.stock_price * 10 AS stock_price,
g.gpu_retail_price,
g.gpu_used_price
FROM (
SELECT
CAST("date" AS DATE) AS date_formatted,
AVG("close") AS stock_price
FROM
@kaggle.samanfatima7_nvidia_stocks_historical_data.nvidia
GROUP BY
date_formatted
) s
INNER JOIN (
SELECT
STRPTIME("date", '%d-%m-%y') AS date_formatted,
AVG("retail_price") AS gpu_retail_price,
AVG("used_price") AS gpu_used_price
FROM
@kaggle.mannacharya_historical_gpu_prices_nvidia_and_amd.gpu_price_history
GROUP BY
date_formatted
) g
ON s.date_formatted = g.date_formatted
ORDER BY
s.date_formatted ASC;