SELECT @AllPlayersCount = COUNT([AP].[PlayerGUID]) FROM [dbo].[func_GetAllPlayers](@PollID) AS [AP]
CREATE FUNCTION [dbo].[func_GetAllPlayers]
(
@PollID INT
)
RETURNS TABLE
AS
RETURN
(
SELECT
DISTINCT [MR].[PlayerGUID]
FROM
[MatchupResults] AS [MR]
INNER JOIN [MatchupItems] AS [MI] ON [MI].[ID] = [MR].[SelectedID]
WHERE
[MI].[PollID] = @PollID
)