Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Hive

New Contributor

Hi Sir,

 
 
could you please help me with my simple code,
 
I will be very appreciative,
 
I have this question:  Show the top 5 game Disciplines for the countries who got more than 10 gold medals.
 
my code is:  select distinct t.discipline, m.team from teams t join medals m  on (t.noc=m.team and m.numbergold>10)  order by  m.team;
 
cloud you please help me with this code to show the top 5 game?
 
Thanks 
3 REPLIES 3

Super Collaborator

hi @Raed_Faly 

 

You need discipline with > 10 gold medals

 

Please use below query and check:

select distinct t.discipline, m.team from teams t join medals m  on (t.noc=m.team and m.numbergold>10)  order by  m.team asc limit 5;

 

select distinct t.discipline, m.team from teams t join medals m  on (t.noc=m.team and m.numbergold>10)  order by  m.team desc limit 5;

Please "Accept As Solution", if your queries are answered.

New Contributor
Hi Asish,

Thanks for your replay

I need top 5 game for each country,
as you know limit 5 gives 5 rows only, but I need 5 for each country.

this is the question: (Show the top 5 game Disciplines for the countries
who got more than 10 gold medals)
Thanks

Super Collaborator

Hi @Raed_Faly  Could you please share the DDL's for the tables, based on that I can update.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.