Professional Documents
Culture Documents
How Many Olympics Games Have Been Held
How Many Olympics Games Have Been Held
How Many Olympics Games Have Been Held
t2 as
(select sport, count (distinct games) as total_sports
from olympic.history
where season ="Summer"
group by 1
order by 2 desc)
select *
from t2
join t1 on t1.total_summer_games = t2.total_sports
select * from t1
left join t2 on t2.sport = t1.sport
8. Fetch
the
total
no of
sports
played in each olympic games.
select games, count (distinct sport) as total_sports
from olympics_history
group by games
order by count (distinct sport) desc, games
9. Fetch details of the oldest athletes to win a gold medal.
with t1 as
(select *, dense_rank() over(order by age desc) as row_no
from olympic.history
where age <> "NA" and medal = "Gold" )
select * from t1
where row_no = 1
10. Find the Ratio of male and female athletes participated in all olympic games.
11. Fetch the top 5 athletes who have won the most gold medals.
with t1 as(
select name, team, count(medal), dense_rank() over(order by count(medal) desc) as row_no
from olympic.history
where medal = "Gold"
group by 1,2
order by count(medal) desc)
select *
from t1
where row_no <= 5
12. Fetch the top 5 athletes who have won the most medals (gold/silver/bronze).
with t1 as(
select name, team, count(medal), dense_rank() over(order by count(medal) desc) as row_no
from olympic.history
where medal <> "NA"
group by 1,2
order by count(medal) desc)
select *
from t1
where row_no <= 5
13. Fetch the top 5 most successful countries in olympics. Success is defined by no of medals
won.
with t1 as(
select history.noc, region as country, count(medal) AS total_medals, dense_rank() over(order by count(medal) desc) as row_no
from olympic.history
join olympic.regions on history.noc = regions.noc
where medal <> "NA"
group by 1,2
order by count(medal) desc)
select *
from t1
where row_no <= 5
14. List down total gold, silver and broze medals won by each country.
15. List down total gold, silver and broze medals won by each country corresponding to each
olympic games.
16. Identify which country won the most gold, most silver and most bronze medals in each
olympic games.
17. Identify which country won the most gold, most silver, most bronze medals and the most
medals in each olympic games.
18. Which countries have never won gold medal but have won silver/bronze medals?
19. In which Sport/event, India has won highest medals.
20. Break down all olympic games where india won medal for Hockey and how many
medals in each olympic games.