Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CREATE VIEW NJITID _ Player _ History AS WITH player _ career AS ( SELECT playerID, COUNT ( DISTINCT yearID ) AS num _ years,
CREATE VIEW NJITIDPlayerHistory AS
WITH playercareer AS
SELECT
playerID,
COUNTDISTINCT yearID AS numyears,
COUNTDISTINCT teamID AS numteams,
SUMHR AS runs,
ROUNDSUMH NULLIFSUMAB AS careerba
SUMsalary AS totsal,
AVGsalary AS avgsal,
MINsalary AS minSalary,
MAXsalary AS maxsalary,
ROUNDMAXsalary MINsalary NULLIFMINsalary AS perctincr,
COUNTDISTINCT CASE WHEN lgID MLB THEN yearID ELSE NULL END AS maxappear,
MAXCASE WHEN lgID MLB THEN yearID ELSE NULL END AS maxcol
FROM
Batting
LEFT JOIN Salaries USING playerID yearID
GROUP BY
playerID
playerinfo AS
SELECT
playerID,
nameGiven AS fullname,
SUMk AS TotalK
MAXCASE WHEN lgID MLB THEN yearID ELSE NULL END AS lastyearplayed
FROM
People
LEFT JOIN Fielding USING playerID
GROUP BY
playerID, fullname
playercollege AS
SELECT
playerID,
COUNTDISTINCT schoolID AS Numschools,
MAXyearID AS maxcol
FROM
CollegePlaying
GROUP BY
playerID
playerpitching AS
SELECT
playerID,
SUMW AS totwin,
SUMSO AS totso
ROUNDSUMSO SUMBB NULLIFSUMIPouts AS carpfr
FROM
Pitching
GROUP BY
playerID
playerawards AS
SELECT
playerID,
COUNT AS totawardplay
FROM
AwardsPlayer
GROUP BY
playerID
managerawards AS
SELECT
playerID,
COUNT AS totawardman
FROM
AwardsManager
GROUP BY
playerID
halloffame AS
SELECT
playerID,
MAXCASE WHEN inducted Y THEN yearid ELSE NULL END AS iyear,
COUNT AS nomcount,
MAXinducted AS inducted
FROM
HallOfFame
GROUP BY
playerID
SELECT
playerinfo.playerID,
playerinfo.fullname,
playerinfo.TotalK
playercareer.numyears,
playercareer.numteams,
playercareer.runs,
playercareer.careerba
playercareer.totsal,
playercareer.avgsal,
playercareer.minSalary,
playercareer.maxsalary,
playercareer.perctincr,
playercollege.Numschools,
playercollege.maxcol,
playercareer.lastyearplayed,
playerpitching.totwin,
playerpitching.totso
playerpitching.carw
playerpitching.carl
playerpitching.carera,
playerpitching.carwhip,
playerpitching.carsopernine
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