title: How to calculate median in AWS Redshift?
body: <p>Most databases have a built in function for calculating the median but I don't see anything for median in Amazon Redshift.</p>
  
  <p>You could calculate the median using a combination of the nth_value() and count() analytic functions but that seems janky. I would be very surprised if an analytics db didn't have a built in method for computing median so I'm assuming I'm missing something.</p>
  
  <p><a href="http://docs.aws.amazon.com/redshift/latest/dg/r_Examples_of_NTH_WF.html">http://docs.aws.amazon.com/redshift/latest/dg/r_Examples_of_NTH_WF.html</a>
  <a href="http://docs.aws.amazon.com/redshift/latest/dg/c_Window_functions.html">http://docs.aws.amazon.com/redshift/latest/dg/c_Window_functions.html</a></p>