View Single Post
Old 10-24-2006, 07:31 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
if you're grouping by date, i don't think you should use 'distinct(date)'. i can't give you a great answer though without trial and error queries against your data.

i did lookup the calculation for median and it looks like you may be missing 1 thing. this page says to add 1 to the count of the array before dividing it by 2.

example for the array would be this:
PHP Code:
<?
$array 
= array(2233445566778899);

// array count + 1 then divided by 2 and rounded down.
// then subtract 1 to use with a zero based array
$array_key floor((count($array)+1)/2)-1;

$median $array[$array_key];
?>
that's how i understood it anyway. i don't think i could be much more help on the query though.
__________________
Mike
sde is offline   Reply With Quote