如何写一个PL/SQL 程序块以提升两个资格最老的"职员"为 "高级职员"?

解决方案 »

  1.   

    update  table a
    set 职位='高级职员'
    where exist
    select 1
    from (
    select 职员编号 
    from table 
    where 职位='职员'
    order by 入职日期) b
    where rownum<=2 and a.职员编号=b.职员编号)
      

  2.   

    上面的SQL不正确,应该这样写:update  table a
    set 职位='高级职员'
    where 职员编号 in (
    select *
    from (
    select 职员编号
    from table
    where 职位='职员'
    order by 入职日期)
    where rownum <=2 )