worldbank_gdp_per_capita.country_iso_alpha3 = worldbank_fertility_rate_total.country_iso_alpha3 + year · one GDP-per-capita observation to one fertility observation for each country and year
04 / ANALYST GUIDE
Guide
Analysis requirements
เชื่อม worldbank_gdp_per_capita กับ worldbank_fertility_rate_total ด้วยทั้ง country_iso_alpha3 และ year
เริ่มจากปีล่าสุดของแต่ละประเทศที่ข้อมูลทั้งสองชุดมีค่า แสดง year ไว้ด้วย เพราะแต่ละประเทศอาจได้คนละปี หากต้องการเทียบปีเดียวกัน ให้กรองปีแล้วระบุจำนวนประเทศที่เหลือ
ใช้แผนภาพการกระจาย (scatter plot) ดูความสัมพันธ์และหากรณียกเว้น อาจใช้สเกลลอการิทึมกับ GDP ต่อหัว
อัตราเจริญพันธุ์รวมคือจำนวนบุตรโดยประมาณที่สตรีหนึ่งคนจะมี ภายใต้อัตราเจริญพันธุ์รายอายุของปีนั้น ไม่ใช่จำนวนเด็กในแต่ละครอบครัว GDP ต่อหัวก็ไม่ใช่รายได้ครัวเรือน และความสัมพันธ์ที่พบไม่ได้พิสูจน์ว่าสิ่งหนึ่งเป็นสาเหตุของอีกสิ่ง
Suggested query
Expand suggested query
SQL / STARTER QUERY
WITH paired AS (
SELECT g.country_iso_alpha3, g.country_name, g.year,
g.gdp_per_capita_current_usd, f.fertility_rate_births_per_woman,
ROW_NUMBER() OVER (PARTITION BY g.country_iso_alpha3 ORDER BY g.year DESC) AS recency
FROM worldbank_gdp_per_capita AS g
JOIN worldbank_fertility_rate_total AS f
ON g.country_iso_alpha3 = f.country_iso_alpha3
AND g.year = f.year
WHERE g.gdp_per_capita_current_usd IS NOT NULL
AND f.fertility_rate_births_per_woman IS NOT NULL
)
SELECT country_iso_alpha3, country_name, year, gdp_per_capita_current_usd, fertility_rate_births_per_woman
FROM paired
WHERE recency = 1
ORDER BY gdp_per_capita_current_usd DESC;