-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tokyo Olympics SQL script.sql
49 lines (43 loc) · 1.13 KB
/
Tokyo Olympics SQL script.sql
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
--No of atheletes from each country
SELECT Country, COUNT(*) AS TotalAthletes
FROM athletes_table
GROUP BY Country
ORDER BY TotalAthletes DESC;
---No of medals won by each country
SELECT
Team_Country,
SUM(Gold) AS Total_Gold,
SUM(Silver)AS Total_Silver,
SUM(Bronze) AS Total_Bronze
FROM medals_table
GROUP BY Team_Country
---Top 10 Countries with the most medals
SELECT TOP(10)Team_Country,
SUM(Gold) AS Total_Gold,
SUM(Silver) AS Total_Silver,
SUM(Bronze) AS Total_Bronze,
SUM(Total) AS Total_Medals
FROM medals_table
GROUP BY Team_Country
ORDER BY SUM(Total) DESC;
---Top 10 Countries with gold medals
SELECT TOP(10)Team_Country,
SUM(Gold) AS Total_Gold,
FROM medals_table
GROUP BY Team_Country
ORDER BY Total_Gold DESC;
--No of Medals won by India
SELECT *
FROM medals_table
WHERE Team_Country in ('India');
--Average number of medals for each discipline for each gender
SELECT Discipline,
AVG(Female) AS Avg_Female,
AVG(Male) AS Avg_Male
FROM entriesgender_table
GROUP BY Discipline;
--Top 5 countries with highest number of coaches
SELECT TOP(5)Country, Count(Name) As TotalCoaches
from coaches_table
GROUP BY Country
ORDER BY TotalCoaches DESC;