Hi-
I have a situation where I would like to get the difference of the
last 2 records in each column in my DB.
So, lets say I have col1 and col2, with values below.
col1 = 1, 2
col2 = 3, 4
What I would like to do is iterate through each column name (col1,
col2) and get the difference of the last 2 records in each. Since it
doesn’t look like there is a .diff command for active record, I’d like
to just store them in a variable and take the difference manually.
I have tried this, but it doesn’t work, what am I doing wrong here?
Give me the last 2 rows from col1?
result = Object.find(:all,:limit => 2, :select col1, :order =>
‘enterdate DESC’)
diffof_rows = result[0] - result[1]
Thanks!