2

Possible Duplicate:
Simple way to calculate median with MySQL

I need find the median of each corresponding id value in mysql. Means i need to get like median of 1=3 and median of 2=5 and median of 3=7.Can any one help me..? Thanks in advance.

id | val
--------
 1    4
 3    7
 1    2
 2    2
 3    9
 2    8
 3    3
Community
  • 1
  • 1
Pramod
  • 951
  • 2
  • 11
  • 26
  • @Scorpi0: In the example he is calculating the median per group. His calculations are correct. – Mark Byers Aug 07 '12 at 12:08
  • 1
    You can find many [answers][1] here. [1]: http://stackoverflow.com/questions/1291152/simple-way-to-calculate-median-with-mysql – oleg Aug 07 '12 at 12:08
  • 1
    See this link: http://stackoverflow.com/questions/1342898/function-to-calculate-median-in-sql-server – Uri Goren Aug 07 '12 at 12:13
  • There is no aggregate method in MYSQL for finding median value.You have to calculate manually. This question is already solved .see this link:- http://stackoverflow.com/questions/1342898/function-to-calculate-median-in-sql-server – JDGuide Aug 07 '12 at 13:19

0 Answers0