Josh, > At the end of this message is some code I used to find medians. > It's kind of a hack, but approximately works, and is intended as a > somewhat awkward stopgap for people who need to use medians. It > illustrates the limitations of the current aggregate function setup, > which works so nicely for avg() and stddev().
Actually, finding the median is one of the classic SQL problems. You can't do it without 2 passes through the data set, disallowing the use of traditional aggregate functions. Joe Celko has half a chapter devoted to various methods of finding the median. Can I talk you into submitting your code to Techdocs? I'd love to have it somewhere where it won't get buried in the mailing list archives. -- -Josh Berkus ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org
