大家好  我想实现的是有个表a
字段 state createdate里面有很多数据  我想修改按照createdate 排序的前100条记录的 state
update table a set state='1' wherr rownum<100 order by createdate这条肯定通不过的  该怎么实现?  请教ing  先谢大家了

解决方案 »

  1.   

    order by 只对最后的结果操作--试下
    update (select * from table where rownum<100 order by createdate) tt set tt.state='1'
      

  2.   

    update 語句不能與order by 語句一起使用
    前100條記錄用語句 
    update table a set state='1' wherr rownum <100
    已經足夠
      

  3.   

    update emp
    set deptno=10
    where empno in(select empno from(select empno,row_number()over(order by empno)rn from emp)where rn<5);
    行不行回个话.
      

  4.   


    /--try it:update table a set state='1' where  rownum in (select 1 from (select rownum  r from a  order by createdate) t where t.r<100); 
      

  5.   

    支持三楼
    update table a set state='1' 
    where Rowid in(select Rowid from(select Rowid,row_number()over(order by createdate )rn from table)where rn <101); 
      

  6.   

    order by createdate 加上沒有意義
      

  7.   

    order by 是放在最后处理的,所以这么写不对
      

  8.   

    update table a set state='1' wherr rownum<100
      

  9.   

    update 为什么要order by 
      

  10.   

    实测数据:CREATE TABLE T35
    (
        State VARCHAR2(2),
        CreateTime DATE
    );INSERT INTO T35 VALUES('0', to_date('2011-12-09 03:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    INSERT INTO T35 VALUES('0', to_date('2011-12-09 02:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    INSERT INTO T35 VALUES('0', to_date('2011-12-09 01:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    INSERT INTO T35 VALUES('0', to_date('2011-12-09 04:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    实测结果: