select m.* 
from 
(select t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 
from  fpd52 t  
where f2 in ('1#rd','2#rd')  
and f1=(select max(f1) 
from ( select  t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 from fpd52 t where f2 in ('1#rd','2#rd'))p 
where t.f3d01=p.f3d01 and t.f4d01=p.f4d01) 
)m  
where f6=(SELECT  MAX(F6) FROM m WHERE F1=m.F1 AND F3D01=m.F3D01 AND F4D01=m.F4D01) -->这里边FROM m 有问题,m是一个表吗?
order by f1 desc,f2 desc 

解决方案 »

  1.   

    把where里的m改为(select t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 
    from  fpd52 t  
    where f2 in ('1#rd','2#rd')  
    and f1=(select max(f1) 
    from ( select  t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 from fpd52 t where f2 in ('1#rd','2#rd'))p 
    where t.f3d01=p.f3d01 and t.f4d01=p.f4d01) 
    )m
      

  2.   

    建议先把select t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 from  fpd52 t  where f2 in ('1#rd','2#rd') 结果先放到一个临时表中。select t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 into # from  fpd52 t  where f2 in ('1#rd','2#rd')
      

  3.   


    你语法不对。。
    表表达式语法:select * from 
    (select * from) m a
    where  not exists  (select 1 from (select * from ) m b where b.字段=a.字段)
      

  4.   

    select t.f1,t.f2,t.f3d01,t.f4d01,f3d02,f4d02,f6,f7 into # from  fpd52 t  where f2 in ('1#rd','2#rd')select * from
    (select * from # p where fi=(select max(f1) from fpd52 t where  t.f3d01=p.f3d01 and t.f4d01=p.f4d01 
     and f6=(SELECT  MAX(F6) FROM fpd52 t WHERE t.F1=p.F1 AND t.F3D01=p.F3D01 AND t.F4D01=p.F4D01) 
    )
    ?