select a.*,b.full_name
from a tab1,b 
where a.doc_type = b.doc_type 
      and doc_date=
                    (select min(doc_date) from a tab2
                     where tab1.doc_name = tab2.doc_name
                    )
试一试,可能有错

解决方案 »

  1.   

    select a.id,b.full_name,a.doc_name,a.doc_date
    from a,b
    where a.doc_name+convert(char(8),doc_date) in(
                       select doc_name+convert(char(8),max(doc_date))
                       from a
                       group by doc_name
                                                  )
    应该是没问题的
      

  2.   

    select a.id,b.full_name,a.doc_name,a.doc_date
    from a,b
    where  a.doc_type = b.doctype and
           a.doc_name+convert(char(8),doc_date) in(
                       select doc_name+convert(char(8),max(doc_date))
                       from a
                       group by doc_name
                                                  )
      

  3.   

    select a.id,b.full_name,a.doc_name,max(doc_date)
    from a,b where a.doc_type=b.doc_type
    group by a.id,a.doc_type,a.doc_name,b.full_name,b.doc_type
      

  4.   

    select distinct id,doc_name,doc_date,(select full_name from b where a.doc_type=b.doc_type ) as fullname from a
      

  5.   

    select 
    min(id) as id,
    min(full_name) as full_name,
    min(doc_name) as doc_name,
    max(doc_date) as doc_date 
    from tableA,tableB 
    where a.doc_type=b.doc_type group by a.doc_type