Question: Q 5 ( 1 5 Points ) Using the results, athletes, and teams tables, find the number of times athletes or teams from each country

Q5(15 Points)
Using the results, athletes, and teams tables, find the number of times athletes or teams from each country have finished in the top five on each date.
Specifically:
For each entry in the results table, if the participant is an individual athlete, use the country_code from the athletes table; if the participant is a team, use the country_cod from the teams table.
Only consider participants with a rank of 5 or smaller.
When counting appearances, only consider records from the results table where rank is no null.
e.g., The rank for "Table Tennis" discipline is null. Therefore, you don't need to conside records of Table Tennis.
Exclude days where all rank values are null from the output.
In case of a tie in the number of appearances, select the country that comes first alphabetically. Keep the original format of the date.
Your query should return the following columns:
date (the date of the event)
country_code (the country code associated with each athlete or team)
appearances (the count of top-five placements by athletes or teams from each country on each date)
Sort the results by date ascendingly and country_code alphabetical ascendingly.
Hints:
Ensure that each team is counted only once per event by selecting distinct values from the teams table where necessary.
Example Output:
\table[[date,country_code,appearances],[2024-07-25,CHN,3],[2024-07-25,FRA,2],[2024-07-25,GER,1],[2024-07-25,IND,3],[2024-07-25,KOR,7],[2024-07-25,MEX,1],[2024-07-25,TPE,1],[2024-07-25,TUR,1],[2024-07-25,USA,1],[2024-07-27,AIN,4],[2024-07-27,ALG,1],[2024-07-27,AND,1],[2024-07-27,ANT,1],[2024-07-27,ARG,1]
If theres any more information i need to provide please let me know thank you!
Q 5 ( 1 5 Points ) Using the results, athletes,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!