Question: Your task in this project is to write the following queries in SQL and make sure they run in the PostgreSQL database. If you make
Your task in this project is to write the following queries in SQL and make sure they run in the PostgreSQL database. If you make any assumptions, clearly state them as comments in your submitted file.
-
Find all the coaches who have coached exactly ONE team. List their first names, last names and cids.
-
Find all the players who played in a Boston team and a Denver team (this does not have to happen in
the same season). List their first names and ilkids.
-
Find those who happened to be a coach and a player in the same team in the same season. List their
first names, last names, the team where this happened, and the year(s) when this happened.
-
Find the average height (in centimeters) of each team in season 2001. Print the team name, the coach
name and the average height value (in centimeters), and sort the results by the average height.
-
Find the coach(es) (first name, last name, and cid) who have coached the largest number of players in
year 1999.
-
Find the coaches who coached in ALL leagues. List their first names, last names and cids.
-
Find those who happened to be a coach and a player in the same season, but in different teams. List
their first names, last names, and the season and the teams this happened. Order the results by
ascending season.
-
Find the players who have scored more points than Michael Jordan did. Print out the first name, last
name, and how many more points they scored than Michael.
-
Find the second most successful coach in regular seasons in history, print his first name and last name.
The level of success of a coach is measured as season_win /(season_win + season_loss). Note that you
have to count in all seasons a coach attended to calculate this value.
-
List the top 3 schools that sent the largest number of drafts to NBA. List the name of each school and the
number of drafts sent. Order the results by number of drafts (hint: use "order by" to sort the results and 'limit xxx' to limit the number of rows returned);
Note that the data is not perfectly formatted for our use. For that, you have to try some other techniques that are not a part of the SQL, but are supported by PostgreSQL. For example, the ID of the same player (e.g., ILKID) can be shown as all upper case in one table (e.g., players) but in a mixture of upper and lower cases in another table (e.g., draft). To find more matches, you can use the 'LOWER' or 'UPPER' function to transform a string to all lower or upper case and then do the match.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
