International Debt Statistics – SQL Project (DataCamp Practice)

Summary:


This project was completed as a practice exercise through DataCamp's virtual environment. Using the international_debt table, Queries include COUNT(DISTINCT), SUM( ), and ORDER BY to analyze debt by country.

🔍 Project Overview:



The goal was to explore:

  • The number of countries listed in the database.
  • Which country has the highest amount of debt.
  • The country with the lowest repayments.

Photo by xb100 on Freepik



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.

Table Overview: international_debt

ColumnDescriptionType
country_nameName of the countryVARCHAR
country_codeCode representing the countryVARCHAR
indicator_nameDebt indicator descriptionVARCHAR
indicator_codeDebt indicator codeVARCHAR
debtValue of the debt indicator (USD)FLOAT

SQL Queries:


                        -- Number of distinct countries
                        SELECT COUNT(DISTINCT country_name) AS total_distinct_countries
                        FROM international_debt;
                    

This SQL query calculates the number of unique countries present in the international_debt table. It uses COUNT(DISTINCT country_name) to count the distinct values in the country_name column, giving a single result representing the total number of countries listed in the dataset.


                        -- Country with the highest debt
                        SELECT country_name, SUM(debt) AS total_debt
                        FROM international_debt
                        GROUP BY country_name
                        ORDER BY total_debt DESC
                        LIMIT 1;
                    

This query identifies the country with the highest total debt in the international_debt dataset. It groups the data by country_name and calculates the total debt using SUM(debt). The results are sorted in descending order by total debt and limited to the top row using LIMIT 1, returning the single country with the highest total debt.


                        -- Country with the lowest repayments
                        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;
                    

This query finds the country with the lowest principal repayments based on the debt indicator DT.AMT.DLXF.CD. It filters the dataset using WHERE indicator_code = 'DT.AMT.DLXF.CD', then groups by country_name and indicator_name. The query returns the minimum repayment value using MIN(debt) and limits the result to one row showing the lowest repayment.

Key Finding:

  • The database contains 124 countries, highlighting the wide scope of developing nations included and offering a strong foundation for debt analysis across regions.
  • The country with the highest total debt holds a significantly larger amount compared to others. This may indicate a higher need for infrastructure investment, economic support, or reliance on international borrowing.
  • The lowest principal repayment (based on the DT.AMT.DLXF.CD indicator) may reflect debt forgiveness, early repayment, or overall lower debt obligations, offering insights into each country’s repayment strategies or financial relief status.

Thanks to DataCamp for providing the dataset and learning environment for this SQL project.