Playground

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow Meta en español

Preguntas y respuestas sobre el sitio para programadores y profesionales de la informática

declare @n BIGINT = (select COUNT(*) from Posts where PostTypeId = 1 and ClosedDate is null);
 
SELECT AVG(1.0 * ViewCount)
FROM (
    SELECT ViewCount FROM Posts
    where PostTypeId = 1 and ClosedDate is null
     ORDER BY ViewCount
     OFFSET (@n - 1) / 2 ROWS
     FETCH NEXT 1 + (1 - @n % 2) ROWS ONLY
) as p;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results