How Many Olympics Games Have Been Held

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1. How many olympics games have been held?

SELECT count(distinct games) as total_olympic_games


FROM olympic.history

2. List down all Olympics games held so far.


SELECT distinct games, city
FROM olympic.history
3. Mention the total no of nations who participated in each olympics game?
select distinct games, count(distinct noc) as total_countries
from olympic.history
group by games
4. Which year saw the highest and lowest no of countries participating in olympics?
5. Which nation has participated in all of the olympic games?
6. Identify the sport which was played in all summer olympics.
First, identify how many Summer olypics games held
Then, find total summer olympic games held for each sport
Compare 1 and 2
with t1 as
(select count(distinct games) as total_summer_games
from olympic.history
where season = "Summer"),

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

7. Which Sports were just played only once in the olympics?


with t1 as
(select sport, count (distinct games) as no_of_games
from olympic.history
group by 1
having no_of_games = 1),
t2 as
(select sport, games
from olympic.history
group by 1,2
having count(distinct games) = 1)

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.

You might also like