Tiger Data interview question

Implement a user-defined aggregate to compute the median.