给定表定义:
create table mytable (
id integer,
mydate datetime,
myvalue integer )
我想通过一个 SQL 查询得到以下答案:
id date_actual value_actual date_previous value_previous
在哪里:
date_previous is the maximum of all the dates preceeding date_actual
for each id and values correspond with the two dates
{max(date_previous) < date_actual ?}
我怎样才能做到这一点?
感谢您的提示