stored procedures - MySQL - Keep getting records if last record is higher than previous -


i don't know if concept possible -- maybe in stored procedure?

consider 2 row table:

`id` (int) | `value` (int) | `date` (datetime) 

lets these rows exist:

1 | 3  | 2011-02-18 2 | 5  | 2011-02-19 3 | 12 | 2011-02-20 4 | 7  | 2011-02-21 5 | 8  | 2011-02-22 6 | 10 | 2011-02-23 

i trying find trends, rather obvious human eye recognize last 3 values going each day: 7 -> 8 -> 10. possible rows remain in pattern?

i'm thinking stored procedure might able read through rows sequentially , find first pattern (10 > 8), continue checking until no longer matches concept: ( 8 > 7 ), not ( 7 > 12 ) stop.

any advice in right direction helpful.

set @was:=null;   select id  (   select      id,      @was was,      value now,      (@was:=value)      the_table order date ) trends  not null , now<=was limit 1; 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -