Link to home
Start Free TrialLog in
Avatar of darrgyas
darrgyas

asked on

Compare values from the most recent row to the one just before it

Hi all,

A table has a timestamp t, and some numeric column, n

I need sql statement that would compare n from the row where t is max [max(t)] to:
 the value of n in the row where t is right before max(t)
-- OR --
 the value of n in the row where t is the second before max(t)

To clarify:
t                                           n
2013-01-28 19.00.00           23
2013-01-28 19.00.01           88
2013-01-28 19.00.02           2
2013-01-28 19.00.03           3


I need sql statement that would compare 3 to:
 2
-- OR --
 88

Any help is appreciated
ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darrgyas
darrgyas

ASKER

thank you