select id,min(contact_date) from table2
where contact_date>'2002-12-16 00:00:00' and contact_date<'2002-12-18 00:00:00'
group by id
where contact_date>'2002-12-16 00:00:00' and contact_date<'2002-12-18 00:00:00'
group by id
调试欢乐多
select a.id,b.name,min(a.contact_date) from table2 a join table1 b on a.id=b.id
where a.contact_date>'2002-12-16 00:00:00' and a.contact_date<'2002-12-18 00:00:00'
group by a.id,b.name
left join tab1 B on A.id = B.id
where A.contact_date>='2002-12-16 00:00:00'
and A.contact_date<='2002-12-18 00:00:00'
group by B.name