SQL PRT Solutions 2
SQL PRT Solutions 2
Q1)For each team, calculate the total prize money won and list the teams that have won
more than $500,000 in prize money.
SELECT Team,
SUM(CAST(REPLACE([Prize], ',', '') AS INT)) AS Total_Prize
FROM [dbo].[valorant_la]
GROUP BY Team
HAVING SUM(CAST(REPLACE([Prize], ',', '') AS INT)) > 500000;
Q2)Find the player with the highest kill contribution per round (total kills divided by
rounds played). Display the player's name, kill contribution, and team.
Q3)Identify the nationality that has the most players in the top 10 based on KAST (%) and
display the nationality and the count of players.
WITH Top10_KAST AS (
SELECT TOP 10 Nationality
FROM [dbo].[valorant_la]
ORDER BY [KAST] DESC
)
SELECT Nationality, COUNT(Nationality) AS Player_Count
FROM Top10_KAST
GROUP BY Nationality
ORDER BY Player_Count DESC;
-- Example usage:
SELECT * FROM dbo.fn_TopPlayersByKAST(5);
Q5)Write a stored procedure named sp_UpdatePlayerRole that takes a player's name and
a new role as input, and updates the player's role in the valorant_la table.
-- Example usage:
EXEC sp_UpdatePlayerRole 'Demon1', 'Support';
Q6)Write a stored procedure named sp_GetTeamStats that takes a team name as input
and returns the total kills, total deaths, and average K/D ratio for the team.
-- Example usage:
EXEC sp_GetTeamStats 'Evil Geniuses';