Calculating the Financial Median in MySQL
by Roland Bouman
(Please do post your comments to this blog to correct me on that should I be wrong so I have a chance to rectify.)
The method I'm describing is a one-pass, pure SQL method. It does not require subqueries, cursors or user variables. However, it does rely on the MySQL specific functions
I'll be maintaining a snippet for this method at MySQL Forge.
If you want to know what the median is, and how my snippet works, read on.
|At first I thought that to work correctly, you would have to format the numbers so they each have the same number of leading zeros: then I realized you were splitting the string based on commas, as opposed to taking the center of the string.|
You may wanna check out Prism at http://www.sisense.com