Skip to content
Project: Analyze International Debt Statistics
  • AI Chat
  • Code
  • Report
  • It's not that we humans only take debts to manage our necessities. A country may also take debt to manage its economy. For example, infrastructure spending is one costly ingredient required for a country's citizens to lead comfortable lives. The World Bank is the organization that provides debt to countries.

    In this notebook, we are going to analyze international debt data collected by The World Bank. The dataset contains information about the amount of debt (in USD) owed by developing countries across several categories. We are going to find the answers to questions like:

    • What is the total amount of debt that is owed by the countries listed in the dataset?
    • Which country owes the maximum amount of debt and what does that amount look like?
    • What is the average amount of debt owed by countries across different debt indicators?

    Below is a snapshot of the database you will be working with:

    country_namecountry_codeindicator_nameindicator_codedebt
    AfghanistanAFG"Disbursements on external debt, long-term (DIS, current US$)"DT.DIS.DLXF.CD72894453.7
    AfghanistanAFG"Interest payments on external debt, long-term (INT, current US$)"DT.INT.DLXF.CD53239440.1
    AfghanistanAFG"PPG, bilateral (AMT, current US$)"DT.AMT.BLAT.CD61739336.9
    AfghanistanAFG"PPG, bilateral (DIS, current US$)"DT.DIS.BLAT.CD49114729.4
    AfghanistanAFG"PPG, bilateral (INT, current US$)"DT.INT.BLAT.CD39903620.1
    AfghanistanAFG"PPG, multilateral (AMT, current US$)"DT.AMT.MLAT.CD39107845
    AfghanistanAFG"PPG, multilateral (DIS, current US$)"DT.DIS.MLAT.CD23779724.3
    AfghanistanAFG"PPG, multilateral (INT, current US$)"DT.INT.MLAT.CD13335820
    AfghanistanAFG"PPG, official creditors (AMT, current US$)"DT.AMT.OFFT.CD100847181.9
    AfghanistanAFG"PPG, official creditors (DIS, current US$)"DT.DIS.OFFT.CD72894453.7

    You will execute SQL queries to answer six questions, as listed in the instructions.

    Unknown integration
    DataFrameavailable as
    num_distinct_countries
    variable
    --num_distinct_countries
    WITH num_distinct_countries AS (
    	SELECT COUNT(DISTINCT country_name) AS total_distinct_countries
    	FROM international_debt)
    
    SELECT *
    FROM num_distinct_countries; 
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    distinct_debt_indicators
    variable
    --distinct_debt_indicators
    WITH distinct_debt_indicators AS (
    	SELECT DISTINCT indicator_name AS distinct_debt_indicators
    	FROM public.international_debt
    	ORDER BY distinct_debt_indicators)
    	
    SELECT *
    FROM distinct_debt_indicators; 
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    total_debt
    variable
    --total_debt
    WITH total_debt AS (
    	SELECT ROUND(SUM(debt)*0.000001,2) AS total_debt
    	FROM international_debt)
    	
    SELECT * 
    FROM total_debt;
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    highest_debt_country
    variable
    --highest_debt_country
    WITH highest_debt_country AS (
    	SELECT country_name, SUM(debt) AS total_debt
    	FROM international_debt
    	GROUP BY country_name
    	ORDER BY total_debt DESC
    	LIMIT 1)
    	
    SELECT *
    FROM highest_debt_country;
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    avg_debt_per_indicator
    variable
    --avg_debt_per_indicator
    WITH avg_debt_per_indicator AS (
    	SELECT 
    	   indicator_code AS debt_indicator, 
    	   indicator_name, 
    	   AVG(debt) AS average_debt
    	FROM international_debt 
    	GROUP BY indicator_code, indicator_name
        ORDER BY average_debt DESC
        LIMIT 10)
    	
    SELECT *
    FROM avg_debt_per_indicator; 
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    highest_principal_repayment
    variable
    --highest_principal_repayment
    WITH highest_principal_repayment AS(
    	SELECT country_name, indicator_name
    	FROM international_debt 
    	WHERE indicator_code IN ('DT.AMT.DLXF.CD')
    	ORDER BY debt DESC
    	LIMIT 1)
    	
    SELECT *
    FROM highest_principal_repayment;
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.