Hello to all:
I have been searching the web for examples on how to determine a median
value in a mySQL table. I have reviewed the article at
http://mysql.progen.com.tr/doc/en/Gr...functions.html. I am an
experienced VB programmer that has recently moved to PHP/mySQL. My employer
has a text file outputted from a vendor specific software with data.
However it cannot be manipulated because it is text. I created a web that
reads the text file on client, converts it to usable data, inputs to mySQL
table and then reflects HTML pages with desired report. One report
subtracts two times and then my employer wishes a median grouped by another
field. I used the AVG function, but of course this is mean, not Median. My
query is:
$mSql = "SELECT AdmitDoc,
Count(AdmitDoc) as Number_Admits,
sec_to_time(AVG (unix_timestamp (Outdt) -
unix_timestamp( Decdt))) as AVG_Doc_To_Admi t,
sec_to_time(AVG (unix_timestamp (Outdt) -
unix_timestamp( Indt))) as AVG_Total_Stay
from tadmits GROUP BY AdmitDoc";
This query subtracts several wait times in an emergency department and
groups by admitting physician. I would like to have median rather than
mean. AdmitDoc is text field, Outdt, Decdt, Indt are all date/time fields.
Any thoughts?
Thanks,
Ross
I have been searching the web for examples on how to determine a median
value in a mySQL table. I have reviewed the article at
http://mysql.progen.com.tr/doc/en/Gr...functions.html. I am an
experienced VB programmer that has recently moved to PHP/mySQL. My employer
has a text file outputted from a vendor specific software with data.
However it cannot be manipulated because it is text. I created a web that
reads the text file on client, converts it to usable data, inputs to mySQL
table and then reflects HTML pages with desired report. One report
subtracts two times and then my employer wishes a median grouped by another
field. I used the AVG function, but of course this is mean, not Median. My
query is:
$mSql = "SELECT AdmitDoc,
Count(AdmitDoc) as Number_Admits,
sec_to_time(AVG (unix_timestamp (Outdt) -
unix_timestamp( Decdt))) as AVG_Doc_To_Admi t,
sec_to_time(AVG (unix_timestamp (Outdt) -
unix_timestamp( Indt))) as AVG_Total_Stay
from tadmits GROUP BY AdmitDoc";
This query subtracts several wait times in an emergency department and
groups by admitting physician. I would like to have median rather than
mean. AdmitDoc is text field, Outdt, Decdt, Indt are all date/time fields.
Any thoughts?
Thanks,
Ross
Comment