Answers for "get the median in sql"

SQL
1

how to find median of a column sql

SET @rowindex := -1;
 
SELECT
   AVG(g.grade)
FROM
   (SELECT @rowindex:=@rowindex + 1 AS rowindex,
           grades.grade AS grade
    FROM grades
    ORDER BY grades.grade) AS g
WHERE
g.rowindex IN (FLOOR(@rowindex / 2) , CEIL(@rowindex / 2));
Posted by: Guest on November-10-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language