R: Calculations based on frequencies / grouped / aggregate data
I think working with "collapsed" or "summarized" data as opposed to the data itself directly inside the SQL database is counter-intuitive. Also, trying to download the original table for analysis in R is a very bad route if the data is too big to fit in the memory, and given that you already have a tool like SQL, which is designed for that specific purpose. You can calculate the mean, median, quantiles, etc. in SQL; and then pull that into R (even into Excel) and draw box plots.

Even though overkill, here is what you can do:


Calculate the mean, median, quantiles from the frequency chart by coding basic math in R. For example mean of a series is the sum over frequency(i)*value(i)/sum(frequency(i)), where i=1,...,n, and n is the number of distinct values in the frequency chart. Median is the value which is in the mid point of series 1,...,sum(frequency(i)). 
You can recover the original series from summary statistics, but memory is again of concern. Let's say your original series was this:


  mySeries &lt;- c(5,9,4,4,2,5,8,9,9,5,5)



But obviously it sits in the database, and this is what you get from SQL as you described:

&gt; fromSQL &lt;- data.frame(table(mySeries))
&gt; fromSQL
  mySeries Freq
1        2    1
2        4    2
3        5    4
4        8    1
5        9    3


You can just use the rep function to recover the series like so:

&gt; recoveredSeries &lt;- as.integer(as.character(rep(fromSQL$mySeries, fromSQL$Freq)))
&gt; recoveredSeries
 [1] 2 4 4 5 5 5 5 8 9 9 9


Now define a function that returns the summary of this series and gives you what you want:

&gt; multiSummary &lt;- function(x) {
+   c(mean = mean(x), median = median(x))
+ }
&gt; multiSummary(recoveredSeries)
    mean   median 
5.909091 5.000000 


As I said, in my opinion, all of this is overkill. Different tools are tailored for different needs, and trying to do something with a tool that is not really the best for your need will give you less-than-optimal results and cost you a lot of time. My recommendation would be performing SQL operations, or going for MapReduce framework for this kind of purposes, depending on the size of your data.