日期:2014-05-16 浏览次数:20827 次
update product pa set price = ( select max(price) from product pb where pa.id = pb.id ) where price is null;
------解决方案--------------------
update product pa set price = ( select max(price) from product pb where pa.id = pb.id ) where price is null and year=2012 and month=8;
------解决方案--------------------
如果要更新成最近一个价格不是空的月份的值,
update product p set price = ( select price from (select id, mth, price, row_number() over (partition by id order by year desc, month desc) rn from product where price is not null) prc_list where prc_list.id = p.id and prc_list.rn = 1) where price is null and year=2012 and month=8;