Question: Provide SQL Server Query with same exact functionality without using FORMAT(): Question: As with any job, players are given raises each year, write a query

Provide SQL Server Query with same exact functionality without using FORMAT():

Question:

As with any job, players are given raises each year, write a query that calculates the increase each player received and calculate the % increase that raise makes. You will only need to use the SALARIES table. You answer should include the columns below. Include the players full name and sort your results by playerID and yearID.

Query with FORMAT():

SELECT People.playerID, (People.nameGiven + ' (' + People.nameFirst + ') ' + People.nameLast) as "Full Name", Salaries.yearID,

FORMAT(Salaries.salary, 'C') as "Present_Salary",

FORMAT((LAG(Salaries.salary, 1) OVER (PARTITION BY Salaries.playerID ORDER BY Salaries.playerID)), 'C') as "Prior_Salary",

FORMAT((Salaries.salary - LAG(salary, 1) OVER (PARTITION BY Salaries.playerID ORDER BY Salaries.playerID)), 'C') AS "Salary_Difference",

FORMAT((Salaries.salary - LAG(Salaries.salary, 1) OVER (PARTITION BY Salaries.playerID ORDER BY Salaries.playerID)) / (LAG(Salaries.salary, 1) OVER (PARTITION BY Salaries.playerID ORDER BY Salaries.playerID)), 'P') as "Increment_Percentage"

FROM People, Salaries WHERE People.playerID = Salaries.playerID ORDER BY Salaries.playerID, Salaries.yearID;

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!