Hello,
I am new to SQL server. I need to calculate the median of the time stamp values in my table,
Table1:
_TimeStamp
2009-12-20 11:59:56.0
2009-12-20 11:59:56.5
2009-12-20 11:59:56.3
2009-12-20 11:59:56.4
2009-12-20 11:59:56.4
2009-12-20 11:59:56.9
There is a nice solution to calculating medians here, http://stackoverflow.com/questions/1342898/function-to-calculate-median-in-sql-server
For coding simplicity, I would love to implement this as a function in SQL, similar to SELECT AVG(_TimeStamp) FROM Table1
but implemented like SELECT MEDIAN(_TimeStamp) FROM Table1
Is it possible to save a series of SQL operations as a function that accepts an argument (_TimeStamp) and returns a value (the median)?