Question
PLPGSQL FUNCTION Write a function named player_height_rank that, given the first name and last name of a player, return the rank of that player based
PLPGSQL FUNCTION
Write a function named player_height_rank that, given the first name and last name of a player, return the rank of that player based on his height.
Note that the players table stores height information in feet and inches, thus you have to sort the players by total height instead of h_feet or h_inches to get the rank.
For a player, his rank is defined as one plus the number of players taller than he is. Players with the exact same height should have the same rank, therefore your function should deal with such ties.
Some examples according to the NBA database are: Gheorghe Muresan ranked 1 with a height of 7 feet and 7 inches; Manute Bol ranked 2nd (7 ft. 6 in.); Ming Yao and three others ranked 3rd (7 ft. 5 in.); and five other players with height 7 ft. 4 in. all ranked 7th, etc. If the name given does not match any player in the players table, the function returns 0.
SCHEMA of Players table:
Table "public.players" Column I | Collation | Nullable | Default Type | character varying (30) I I character varying (30) I | not null| ilkid firstname character varying (30) I Lastname position first_season | integer last_season integer h feet h inches weight college birthday ndexes | character varying(1) I | integer | real | real | character varying (100) I | character varying (30) I "players_pkey" PRIMARY KEY, btree (ilkid) Table "public.players" Column I | Collation | Nullable | Default Type | character varying (30) I I character varying (30) I | not null| ilkid firstname character varying (30) I Lastname position first_season | integer last_season integer h feet h inches weight college birthday ndexes | character varying(1) I | integer | real | real | character varying (100) I | character varying (30) I "players_pkey" PRIMARY KEY, btree (ilkid)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started