日期:2014-05-17  浏览次数:20605 次

同步套餐
重新同步套餐功能 把日志中套餐代码相同,实体相同的最高版本号的记录,版本号 -1。

有个日志表 mis_package_syn_log 里面有(code(套餐代码), version(版本号), package_id, orgid(实体), id, scrq)
各位大侠给个思路吧!



------解决方案--------------------
have a try
SQL code
update mis_package_syn_log a set a.version = a.version - 1
 where not exists select 1 from mis_package_syn_log
                   where code = a.code
                     and orgid = a.orgid
                     and version > a.version

------解决方案--------------------
select code, version, package_id, orgid, id, scrq from mis_package_syn_log where id in (select id, max(version) v from mis_package_syn_log
 group by id ) order by id
楼主试试这个语句,看看能用不?前提是ID是唯一的,也就是表主键