select a.* from 
(
select fa_order ma, fl_id from  t_Flowaudit where us_id=98 
) as a,
(
select max(fa_order) ma,fl_id  from t_Flowaudit group by fl_id
) as b
where a.ma=b.ma and a.fl_id=b.fl_id

解决方案 »

  1.   

    select a.ma,a.f1_id from (select max(fa_order) ma,fl_id  from t_Flowaudit group by fl_id ) a ,t_Flowaudit b where a.ma=b.fa_order and a.fl_id =b.fl_id and b.us_id=98 
      

  2.   

    exists:select * from 
    (
    select fa_order ma, fl_id from  t_Flowaudit where us_id=98 
    ) as a
    where exists (
    select 1 from 
    (
    select max(fa_order) ma,fl_id  from t_Flowaudit group by fl_id
    ) as b
    where a.ma=b.ma and a.fl_id=b.fl_id
    )
      

  3.   

    这样不行吗
    select fa_order ma, fl_id from  t_Flowaudit where us_id=98 and exists (
    select max(fa_order) ma,fl_id from t_Flowaudit t1 where t1.ma = t_Flowaudit.ma and t1.fl_id = t_Flowaudit.flid group by fl_id )