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:

PLPGSQL FUNCTION Write a function named player_height_rank that, given the first name

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

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 Databases Questions!