Hey all,
While it is possible to doc cumulative sum by month in mysql using MONTH
and COUNT statements, I'm trying to figure out if the same kind of
statement is available in ruby, something like a substitute for the
month value I put below:
def cumulative_sum
values = [:passed_on, :failed_on, :incompleted_on]
sum = 0
case values
when :passed_on
month.each do |state|
while state > '2010-03-00'
@passed_on = state.map{ |x| sum += x}
end
end
when :failed_on
month.each do |state|
while state > '2010-03-00'
@failed_on = state.map{ |x| sum += x}
end
end
when :incompleted_on
month.each do |state|
while state > '2010-03-00'
@incompleted_on = state.map{ |x| sum += x}
end
end
end
end
Note that the passed_on, failed_on and incompleted_on fields of students
table are data typed as date.
Thanks for any response.
···
--
Posted via http://www.ruby-forum.com/.