Monday, 26 August 2013

List changes of options by week

List changes of options by week

We have a database table that lists option changes this way:
date | option | value
01/07/08 | optionA | value_a
01/07/08 | optionB | value_b
02/07/08 | optionA | value_a2
We assume that before the first date that has an option (primary key is
date and option) there's no option set. We have to make it so for every
day, each option overrides previous changes afterwards, but not backwards.
I would like to know how can I join this table so I can get, for each
week, the full set of values latest values per option. Something like the
following:
date | option | value
01/07/08 | optionA | value_a
01/07/08 | optionB | value_b
02/07/08 | optionA | value_a2
02/07/08 | optionB | value_b

No comments:

Post a Comment