Is there a way to do a median calc in a Rails 4 app that uses the default SQLite3 database?
I've built the app already but would like to add a median function, and I see that the active_median gem only works with PostgreSQL for now:
Is there a way to do a median calc in a Rails 4 app that uses the default SQLite3 database?
I've built the app already but would like to add a median function, and I see that the active_median gem only works with PostgreSQL for now:
Try this to calculate median
def median(array)
sorted = array.sort
len = sorted.length
return (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
end