Q&A for users, experts, and developers of the Tezos blockchain project
DECLARE @UserId int = ##UserId:int## DECLARE @c BIGINT = (SELECT COUNT(*) FROM Comments WHERE UserId = @UserID) SELECT AVG(1.0 * CommentLength) FROM ( SELECT LEN(Text) as CommentLength FROM Comments WHERE UserId = @UserID ORDER BY LEN(Text) OFFSET (@c - 1) / 2 ROWS FETCH NEXT 1 + (1 - @c % 2) ROWS ONLY ) AS x;