-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSQLQuery_International_debt.sql
More file actions
52 lines (43 loc) · 2.13 KB
/
Copy pathSQLQuery_International_debt.sql
File metadata and controls
52 lines (43 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--SQL-International-Debt-Statistics-Analysis
--This repository houses an analysis of international debt data supplied by The World Bank.
--The dataset includes details about the indebtedness (in USD) of developing countries, classified under various indicators.
--The aim of this analysis is to delve into and address fundamental inquiries concerning international debt.
SELECT TOP (1000) [country_name]
,[country_code]
,[indicator_name]
,[indicator_code]
,[debt]
FROM [PortfolioProject].[dbo].[international_debt]
--Total Debt Analysis:
--1. How many distinct countries are there in the dataset?
SELECT COUNT(DISTINCT country_code) as Total_of_Countries
FROM PortfolioProject.dbo.international_debt
--2. What is the total amount of debt owed by the countries listed in the dataset?
SELECT SUM(debt) as Total_Debt
FROM PortfolioProject.dbo.international_debt
--Maximum Debt Holder:
--3. Which country owns the maximum amount of debt, and what is the corresponding amount?
SELECT TOP 1 country_name, sum(debt) as Total_Debt
FROM PortfolioProject.dbo.international_debt
GROUP BY country_name
ORDER BY Total_Debt DESC
--Average Debt Across Indicators:
--4. What are the distinct debt indicators identified in the dataset?
SELECT DISTINCT indicator_code, indicator_name
FROM PortfolioProject.dbo.international_debt
--5. What is the most frequently encountered debt indicator?
SELECT indicator_code, indicator_name, COUNT(country_name) as num_country_by_indicator
FROM PortfolioProject.dbo.international_debt
GROUP BY indicator_code, indicator_name
ORDER BY num_country_by_indicator DESC
--6. What is the average amount of debt owed by countries, categorized by different debt indicators?
SELECT indicator_code,indicator_name, AVG(debt) as Avg_debt_by_indicator
FROM PortfolioProject.dbo.international_debt
GROUP BY indicator_code, indicator_name
ORDER BY Avg_debt_by_indicator DESC
--Repayments Analysis:
--7. What is the highest number of principal repayments observed in the dataset?
SELECT TOP 1 country_name, indicator_name, debt
FROM PortfolioProject.dbo.international_debt
WHERE indicator_name LIKE '%principal repayment%'
ORDER BY debt DESC