title: To Find Median value of a Data Frame in Apache Spark
body: <p>I'm working on a problem where I have imported a DB table into Apache Spark.</p>
  
  <p>I have converted it into a DataFrame. Then I performed a RegisterTempTable so that I can use Hive Queries on it.</p>
  
  <p>I'm able to perform other mathematical operations like,</p>
  
  <pre><code>sqlContext.sql("select avg(Amount) from Table1001").show
  </code></pre>
  
  <p>However I'm unable to find the median for a field called <code>Amount</code>. Is there any way to find the median on this DataFrame?</p>
  
  <p>Kindly provide a suitable solution.</p>