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
)
试一试,可能有错
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
)
试一试,可能有错
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
)
应该是没问题的
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
)
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
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