SQL median function of multiple columns ignoring nans