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.

There are 124 distinct countries present in the table.

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

SELECT COUNT(DISTINCT(country_name)) AS total_distinct_countries
FROM international_debt;

To identify the country with the highest debt, follow these steps:

  1. Create a Table: Include all country names and the total sum of debt owed by each country.

  2. Group by Country: Group the data by country name to aggregate the debt totals.

  3. Order by Debt: Sort the results by the total debt in descending order. The country with the highest debt is China.

  4. Limit Output: Limit the output to one row to identify the country with the highest debt.

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

SELECT country_name, SUM(debt) AS total_debt
FROM international_debt
GROUP BY country_name
ORDER BY SUM(debt) DESC
LIMIT 1;

To identify the country with the lowest principal repayment amount, follow these steps:

  1. Select Data: Choose the country names, the indicator name, and the principal debt amount for each country.
  2. Filter Data: Use the WHERE clause to include only rows where the indicator name is ‘Principal repayments’.
  3. Order Results: Sort the data from lowest to highest principal repayment amount.
  4. Limit Output: Limit the output to one row to identify the country with the lowest principal repayment amount.
Spinner
DataFrameas
lowest_principal_repayment
variable
-- lowest_principal_repayment 
-- Write your query here... 

SELECT country_name, indicator_name, debt AS lowest_repayment
FROM international_debt 
WHERE indicator_name = 'Principal repayments on external debt, long-term (AMT, current US$)'
ORDER BY debt
LIMIT 1;