← ALL CHALLENGES
CHALLENGE / BEGINNER / READY TO QUERY

GDP ต่อหัวกับประชากร บอก GDP รวมได้ไหม?

ฝึก JOIN ข้อมูล GDP ต่อหัวกับจำนวนประชากรตามประเทศและปี แล้วคำนวณ GDP รวมโดยประมาณ

01 / THE QUESTION

Question

สำหรับประเทศและปีหนึ่ง ๆ หากนำ GDP ต่อหัวคูณด้วยจำนวนประชากร จะได้ค่าประมาณ GDP รวมเป็นดอลลาร์สหรัฐ ณ ราคาปัจจุบันเท่าไร? ลองเปรียบเทียบผลระหว่างปีหรือประเทศ

02 / SOURCE TABLES

Tables to use

03 / RELATIONSHIP

ER diagram

ONE TO ONE RELATIONSHIP
worldbank_gdp_per_capitacountry_iso_alpha3Key fieldyearKey fieldgdp_per_capita_current_usd
worldbank_population_totalcountry_iso_alpha3Join fieldyearJoin fieldpopulation_total

worldbank_gdp_per_capita.country_iso_alpha3 = worldbank_population_total.country_iso_alpha3 + year · one GDP-per-capita observation to one population observation for each country and year

04 / ANALYST GUIDE

Guide

Analysis requirements

  • เชื่อม worldbank_gdp_per_capita กับ worldbank_population_total ด้วย ทั้ง country_iso_alpha3 และ year เพื่อไม่ให้ข้อมูลข้ามปีจับคู่กัน
  • แสดงประเทศและปีพร้อมค่าต้นทางสองค่า เพื่อให้ตรวจสอบผลคูณในแต่ละแถวได้
  • คูณ gdp_per_capita_current_usd กับ population_total และตัดแถวที่ค่าใดค่าหนึ่งเป็น null ออกจากการคำนวณ
  • เริ่มจากช่วงปีสั้น ๆ และตรวจจำนวนแถวหลัง JOIN ว่าไม่มีคู่ประเทศ–ปีซ้ำกัน
  • ผลลัพธ์เป็นค่าประมาณ GDP ณ ราคาปัจจุบัน ซึ่งยังไม่ได้ขจัดผลของเงินเฟ้อ เนื่องจาก GDP ต่อหัวเป็นตัวชี้วัดที่คำนวณและปัดเศษมาแล้ว เมื่อคูณกับจำนวนประชากรที่เผยแพร่แยกกัน ผลอาจไม่ตรงกับ GDP รวมที่เผยแพร่อย่างเป็นทางการ

Suggested query

Expand suggested query
SQL / STARTER QUERY
SELECT g.country_iso_alpha3, g.country_name, g.year,
       g.gdp_per_capita_current_usd,
       p.population_total,
       g.gdp_per_capita_current_usd * p.population_total AS estimated_gdp_current_usd
FROM worldbank_gdp_per_capita AS g
JOIN worldbank_population_total AS p
  ON g.country_iso_alpha3 = p.country_iso_alpha3
 AND g.year = p.year
WHERE g.gdp_per_capita_current_usd IS NOT NULL
  AND p.population_total IS NOT NULL
  AND g.year BETWEEN 2020 AND 2024
ORDER BY g.country_iso_alpha3, g.year;