有这样一张表:t_abcf_id gpid price f_day2 2089 5.2 2012-07-09
50 2089 5.6 2012-07-10
102 2089 5.2 2012-07-11
203 2089 5.8 2012-07-12就是让第二天的price写到前一天去。
我想得到的结果为:
f_id gpid price f_day2 2089 5.6 2012-07-09
50 2089 5.2 2012-07-10
102 2089 5.8 2012-07-11
203 2089 null 2012-07-12
最后一天的price可以为null或者为0;我是想不出来,请问下高手应该如何写sql语句????
50 2089 5.6 2012-07-10
102 2089 5.2 2012-07-11
203 2089 5.8 2012-07-12就是让第二天的price写到前一天去。
我想得到的结果为:
f_id gpid price f_day2 2089 5.6 2012-07-09
50 2089 5.2 2012-07-10
102 2089 5.8 2012-07-11
203 2089 null 2012-07-12
最后一天的price可以为null或者为0;我是想不出来,请问下高手应该如何写sql语句????
set a.price= b.price
SET a.price=b.price
LEFT JOIN t_abc b
ON a.gpid=b.gpid AND a.f_day=b.f_day-interval-1 day;