Hi Richard, Take a look at this post that I found on tek-tips: http://www.tek-tips.com/faqs.cfm?fid=4751
Cheers, Kris > Hi, i am using ms sql server and need to implement get the median of a set of > values. i have looked all over the web and cant find a simple explanation. > > i would appreciate it if anyone can provide me with a very simple > explanation. i understand how it works in terms of having to first order the > values ascending and then pick the middle value in the list if there is an > odd number of rows, or take the 2 middle values and get the average value of > these 2 values if there is an even number of rows. however i have no idea on > how to implement this into my query > > The following is the sql statement that i need to adapt, i need to get the > median value of the srtot value within the query. > > select pat_demid, pat_lastname, meas_gendate, meas_id, test_gendate, > avg(srtot)as meansrtot, avg(sreff)as meansreff, avg(BFRaw)as BF_Rawmean, > avg(BFTGV)as BF_TGVmean, > ((stdev(srtot)/avg(srtot))*100) as srtotcv, ((stdev(sreff)/avg(sreff))*100) > as sreffcv, ((stdev(BFRaw)/avg(BFRaw))*100) as BF_Rawcv, > ((stdev(BFTGV)/avg(BFTGV))*100) as BF_TGVcv, > count(srtot)as countsrtot, count(sreff)as countsreff > from bodyparametersf > where (srtot is not null) OR (sreff is not null) > group by pat_demid, pat_lastname, meas_gendate, meas_id, test_gendate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272354 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

