ROW_NUMBER() will be used to achieve first two goals as ROW_NUMBER() return sequential row number within a partition of result set. And for last column we will use DENSE_RANK(), which will return rank of rows within the partition of a result set.
--Create temporary table for query testing
CREATE TABLE #TeamPlayer
(
Team VARCHAR(25),
PlayerName VARCHAR(25)
)
GO
-- Insert temporary records
INSERT INTO #TeamPlayer ( Team, PlayerName )
SELECT 'South Zone',
'SZ_Player1'
UNION ALL
SELECT 'South Zone',
'SZ_Player2'
UNION ALL
SELECT 'South Zone',
'SZ_Player3'
UNION ALL
Read more: Connect SQL
--Create temporary table for query testing
CREATE TABLE #TeamPlayer
(
Team VARCHAR(25),
PlayerName VARCHAR(25)
)
GO
-- Insert temporary records
INSERT INTO #TeamPlayer ( Team, PlayerName )
SELECT 'South Zone',
'SZ_Player1'
UNION ALL
SELECT 'South Zone',
'SZ_Player2'
UNION ALL
SELECT 'South Zone',
'SZ_Player3'
UNION ALL
Read more: Connect SQL