Screen Link:
Portion of Answer Key:
country_best_customer AS
(
SELECT
cmp.country,
cmp.max_purchase,
(
SELECT ccp.customer_id
FROM customer_country_purchases ccp
WHERE ccp.country = cmp.country AND cmp.max_purchase = ccp.total_purchases
) customer_id
FROM country_max_purchase cmp
)
Question:
I would like to clarify if this same line of code
SELECT ccp.customer_id
FROM customer_country_purchases ccp
WHERE ccp.country = cmp.country AND cmp.max_purchase = ccp.total_purchases
) customer_id
FROM country_max_purchase cmp
Does this equate to ccp and cmp doing an INNER JOIN on ccp.country = cmp.country AND cmp.max_purchase = ccp.total_purchases? But why didn’t the author do an INNER JOIN instead?
Thanks for the help!