Hello, Is it possible to write the median as an aggregate function using pure tcl.
I did the following: package require sqlite sqlite sql d:/data/yaspo2004bt.sqlite sql function median Median set l [list] proc Median {value} { global l lappend l $value # not absolute exact but just a draft return [lindex [lsort -integer $l] [expr round([llength $l] / 2)]] } sql eval "select median(Size) from tensembl" val {set key [array names val median*] ; puts $val($key)} result: 448 448 448 448 412 412 378 387 378 387 378 387 387 . . . 450 450 is the right result. However I get it at the very end. And this is slow because it computes foreach row the median, I would like only to compute it ones. For the last element! Becuase it is a aggregate. Any hint ? regards, Detlef -- Dr. Detlef Groth Max-Planck-Institut fuer Molekulare Genetik Ihnestr. 63/73 D-14195 Berlin Tel.: + 49 30 - 8413 1235 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]