DamonYo0o 2017-09-16 02:17 采纳率: 100%
浏览 2281
已采纳

怎么能做到oracle批量修改数据?????

现在有一张表,数据量有十万,有一个字段是空的,现在要按数据量比例给这个字段设置三个不同的值,比如百分之三十的数据设置成1,百分之三十设置成2,剩下的百分之四十设置成3。比例无所谓不固定。
有没有大神教一下啊。。。

  • 写回答

2条回答

  • XianRenShan 2017-09-16 02:28
    关注

    --建表
    create table t (a number);
    --插入两条测试数据
    insert into t values(0);
    insert into t values(0);
    --测试语句
    select case
    when (select count(1) from t where t.a = 0) =
    (select count(1) from t) then
    '01'
    when (select count(1) from t where t.a = 0) <>
    (select count(1) from t) then
    '02'
    when (select count(1) from t where t.a = 2) <>
    (select count(1) from t) then
    '03'
    when (select count(1) from t where t.a = 2) = 0 then
    '04'
    else
    null
    end as b
    from dual;

    参考:http://bbs.csdn.net/topics/330059135
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导