Skip to content

Humans not only take debts to manage 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 project, you 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. You are going to find the answers to the following questions:

  • What is the number of distinct countries present in the database?
  • What country has the highest amount of debt?
  • What country has the lowest amount of repayments?

Below is a description of the table you will be working with:

international_debt table

ColumnDefinitionData Type
country_nameName of the countryvarchar
country_codeCode representing the countryvarchar
indicator_nameDescription of the debt indicatorvarchar
indicator_codeCode representing the debt indicatorvarchar
debtValue of the debt indicator for the given country (in current US dollars)float

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

Spinner
DataFrameas
num_distinct_countries
variable
-- num_distinct_countries 
-- Write your query here... 

-- Save the query as num_distinct_countries
-- This query calculates the total number of distinct countries in the international_debt table.
SELECT 
    COUNT(DISTINCT country_name) AS total_distinct_countries -- Count the number of unique country names and alias the result as total_distinct_countries
FROM 
    international_debt; -- The table containing debt-related data for various countries



Spinner
DataFrameas
highest_debt_country
variable
-- highest_debt_country 
-- Write your query here... 

-- Save the query as highest_debt_country
-- This query identifies the country with the highest total debt in the international_debt table.

SELECT 
    country_name, -- Select the country name
    SUM(debt) AS total_debt -- Calculate the total debt for each country and alias the result as total_debt
FROM 
    international_debt -- The table containing debt-related data for various countries
GROUP BY 
    country_name -- Group the data by country to calculate the debt total for each country
ORDER BY 
    total_debt DESC -- Order the results in descending order of total debt, so the highest debt is listed first
LIMIT 1; -- Return only the top result (the country with the highest total debt)



Spinner
DataFrameas
lowest_principal_repayment
variable
-- lowest_principal_repayment 
-- Write your query here... 

-- Save the query as lowest_principal_repayment
-- This query identifies the country with the lowest amount of principal repayments 
-- (based on the indicator code 'DT.AMT.DLXF.CD').

SELECT 
    country_name, -- Select the name of the country
    indicator_name, -- Select the description of the debt indicator
    MIN(debt) AS lowest_repayment -- Find the minimum debt value (lowest repayment) and alias it as lowest_repayment
FROM 
    international_debt -- The table containing debt-related data for various countries
WHERE 
    indicator_code = 'DT.AMT.DLXF.CD' -- Filter to include only rows where the indicator represents principal repayments
GROUP BY 
    country_name, -- Group the data by each country
    indicator_name -- Also group by the indicator name (to include it in the SELECT clause)
ORDER BY 
    lowest_repayment ASC -- Sort the results in ascending order to bring the lowest repayment value to the top
LIMIT 1; -- Return only the top result (the country with the lowest repayment value)