I've got a lot of ActiveRecord queries that find a percentage using the average of an expression, for example:
def self.undergraduate_degree_percentage
self.average("undergrad_college_name != ''")
end
These were built for sqlite3 (the development database) but break down in postgres (the production database) because pg handles booleans differently. The error generated is something like ERROR: function avg(boolean) does not exist at character 8
. Is there an elegant way to make this type of query work for both sqlite3 and PG?