This is an interesting question that a couple of us have. There is a calculation called zScoring that the retail business we support uses a lot. We are interested in creating a UDF that would allow this calculation to be done straight from SQL, however we are not even sure if it is possible. Here is a link that explains the formula:
It would have to return a result for each row however it needs to also run calculations on the whole database of values. I haven't really found anything like this so I'm not sure it's even possible. If anyone has any inspiration, direction, or advise it would be greatly appreciated.