Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Forked from cameroncox/gist:2567952
Created May 1, 2012 13:51
Show Gist options
  • Save dannymcc/2568053 to your computer and use it in GitHub Desktop.
Save dannymcc/2568053 to your computer and use it in GitHub Desktop.
class Clinical < ActiveRecord::Base
# ... snip rest of model...
def self.income_by_month
select( 'YEAR(transactiondate) as year, MONTH(transactiondate) as month, SUM(LineBalance) as income' )
.where(:payment => 0 )
.where('LineBalance <> 0' )
.where('analysiscode <> 213' )
.group(:monthyear)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment