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.

Three SQL cells have been created for you in the workbook, please write SQL queries in each of these cells to answer the following:

What is the number of distinct countries present in the database? The output should be single row and column aliased as total_distinct_countries. Save the query as num_distinct_countries. What country has the highest amount of debt? Your output should contain two columns: country_name and total_debt and one row. Save the query as highest_debt_country. What country has the lowest amount of principal repayments (indicated by the "DT.AMT.DLXF.CD" indicator code)? The output table should contain three columns: country_name, indicator_name, and lowest_repayment and one row, saved in the query lowest_principal_repayment. Note: Creating new cells in the workbook will rename the DataFrames. Make sure that your final solution uses the names provided above

Spinner
DataFrameas
df
variable
SELECT *
FROM international_debt;
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;

¿Qué país tiene la mayor cantidad de deuda? Tu, salida debe contener dos columnas : country_name y total_debt,y una sola fila. Guarda la consulta como highest_debt_country.

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 total_debt DESC
	LIMIT 1;

¿Qué país tiene el menor monto de pagos de principal (indicado por el código de indicador "DT.AMT.DLXF.CD")? La tabla de salida debe contener tres columnas: country_name, indicator_name y lowest_repayment, y una sola fila, guardada en la consulta lowest_principal_repayment.

Spinner
DataFrameas
lowest_principal_repayment
variable
-- lowest_principal_repayment 
-- Write your query here... 
SELECT country_name, indicator_name, MIN(debt) AS lowest_repayment
FROM international_debt
	WHERE indicator_code = 'DT.AMT.DLXF.CD'
GROUP BY country_name, indicator_name
	ORDER BY lowest_repayment ASC
	LIMIT 1;