Timeline for Function to Calculate Median in SQL Server
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 26, 2013 at 20:39 | history | edited | Sir Wobin | CC BY-SA 3.0 |
Included an amended answer following a very good suggestion in the comments.
|
Jul 23, 2013 at 14:31 | comment | added | Robert Cutajar | You could fix the flaw of imprecision by taking max and min of each quartile in a subquery, then AVGing the MAX of the previous and MIN of the next? | |
Oct 30, 2012 at 6:12 | comment | added | Justin Grant | If it's OK to be off by one, then the query above is fine. But if you need the exact median, then you will have trouble. For example, for the sequence (1,3,5,7) the median is 4 but the query above returns 3. For (1,2,3,503,603,703) the median is 258 but the query above returns 503. | |
Oct 6, 2010 at 0:26 | comment | added | Jonathan Beerhalter | This actually works pretty well, and allows for partitioning of the data. | |
Jun 24, 2010 at 11:42 | history | answered | Sir Wobin | CC BY-SA 2.5 |