fnGetNetworkRankingForAccount
Return
Return Type |
---|
int |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@NetAccountID | int | IN | |
@RankingType | int | IN |
Definition
Copy
CREATE FUNCTION [dbo].[fnGetNetworkRankingForAccount]
(
@NetAccountID int,
@RankingType int
)
RETURNS int
AS
BEGIN
DECLARE @Count int
if @RankingType = 1
begin
SELECT @Count = Count(ID) FROM
(
SELECT a.ID
FROM [NetAccountRelation] a
INNER JOIN [NetAccount] na on na.ID = a.RelationAccountID
WHERE
a.NetAccountID = @NetAccountID
AND
(a.BlockedID = 0 OR a.BlockedID IS NULL)
AND
a.Confirmation > 0
AND
na.Deleted = 0
UNION
SELECT b.ID
FROM [NetAccountRelation] b
INNER JOIN [NetAccount] na on na.ID = b.NetAccountID
WHERE
b.RelationAccountID = @NetAccountID
AND
(b.BlockedID = 0 OR b.BlockedID IS NULL)
AND
b.Confirmation > 0
AND
na.Deleted = 0
) AS x
end
return (SELECT top 1 nr.[ID]
FROM [NetworkRanking] nr
WHERE
@Count >= isnull(nr.LowerBound,0) AND
@Count <= isnull(nr.UpperBound,100000) AND
nr.[RankingType] = @RankingType)
END