>>(It is fairly complicated.)
I agree with fluteplr. The reason that calculating the median is more difficult than we might otherwise suspect, is because it is based on a notion of physical ordering (...being 50% of values are above and 50% are below).
But SQL is a set-based language, where there is no inherent sense of any kind of particular sequence or order. (Yes, we can force a sequence on a query resultset, but not on the underlying records themselves.) I recently saw it described like this: Think of all the water molecules in a drop of water. There is no 'first' molecule or 'last' molecule.
The mode is easier to calculate than the median because the mode, as fluteplr points out, is the most frequently-occuring value, regardless of the 'order'. i.e it makes no difference if the most frequent values are the 'first' values or the 'last' values.
I'm not really adding to fluteplr's advice here, just adding some background stuff that likely none of us are interested in.)