Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago