求一个更新操作

cfsss99 2010-05-21 10:19:29
有这样一张表
name score
a 2
b 3.2
c 2.3
d 4.1

需要根据score的小数位,由大到小,将score+1
且只更新 2 条记录

结果即
name score
a 2
b 4.2
c 3.3
d 4.1

11g
请各位大虾指点
...全文
79 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
boyyth 2010-05-21
  • 打赏
  • 举报
回复
不考虑整数的情况

update 表
set score = score + 1
where rowid in (select aid
from (select rowid aid, substr(a.score, 3) sc
from 表 a
where instr(a.score, '.') > 0
order by sc desc) b
where rownum <= 2)


小灰狼W 2010-05-21
  • 打赏
  • 举报
回复
查询
select name,
score+case when rownum<3 then 1 else 0 end new_score from(
select *
from table1
order by mod(score,1) desc
);
更新
update table1 t set score=score+1
where (select count(1) from table1 where mod(score,1)>mod(t.score,1))<2
刘痕 2010-05-21
  • 打赏
  • 举报
回复
select substr(4.3,InStr(4.3,'.')+1) from dual;
这样取出小数点后的数字,剩下的自己来吧!

17,090

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧