Re: How do I get the median instead of average?
Something like this will get you the median value:
CREATE TEMPORARY TABLE t (
seq INT UNSIGNED AUTO_INCREMENT,
PRIMARY KEY (seq)
)
SELECT val
FROM your_table
ORDER BY val;
SELECT @half := FLOOR(COUNT(*)/2)
FROM t;
SELECT @median := val
FROM t
WHERE seq = @half;
Subject
Written By
Posted
Re: How do I get the median instead of average?
June 29, 2010 07:16PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.