语句如下,
update orders_t a
 set (
     status,the_man,the_date
     )
   = (
      select '3',c.the_man,c.the_date
      from order_detail_t c
      where a.id= c.id
     )
where a.id=10因为同一id中的the_man可能有多个不同的值,要怎么样才能取到
select '3',c.the_man,c.the_date
      from order_detail_t c
      where a.id= c.id
中的最后一行呢

解决方案 »

  1.   

    最后一行的the_man值有什么特点?最大?最小?
      

  2.   

    表 order_detail_t 有主键吗?update orders_t a 
    set ( 
        status,the_man,the_date 
        ) 
      = ( 
          select '3',c.the_man,c.the_date 
          from order_detail_t c 
          where a.id= c.id 
            and c.pk = (select max(pk) from order_detail_t d
                             where c.id = d.id)
        ) 
    where a.id=10 
      

  3.   

    按date排的
    select '3',min(c.the_man) keep(dense_rank first order by c.the_date desc),
               min(c.the_date) keep(dense_rank first order by c.the_date desc)
          from order_detail_t c 
          where a.id= c.id 
      

  4.   

    看可不可以group by或者用rownum什么的限制一下返回一行就ok了