select *,日期=(select min(日期) from 表2 where id=表1.id) from 表1

解决方案 »

  1.   

    select a.*,b.日期 from 表1 a
    inner join 表2 b on a.id=b.id
    where b.日期 = (select top 1 日期 from 表2 where id = b.id)
      

  2.   

    select a.*,(select top 1 日期 from 表2 where id = a.id order by 日期) from 表1 a
      

  3.   

    select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id and not exists(select * from 表2 b where b.id=表2.id and b.日期>表2.日期)
      

  4.   

    select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id where 表2.id in(select top 1 日期 from 表2 order by 日期 asc)
      

  5.   


    不好意思,应该是
    select 表1.*,表2.日期 from 表1 inner join 表2 on 表1.id=表2.id where 表2.日期 in(select top 1 日期 from 表2 order by 日期 asc)
      

  6.   

    select a.*,b.日期 from 表1 a
    inner join 表2 b on a.id=b.id
    where b.日期 = (select top 1 日期 from 表2 where id = b.id)
     就这个可以了.
      

  7.   

    select a.*,b.日期 from 表1 a inner join 表2 b on a.id=b.id and not exists(select * from 表2 c where c.id=b.id and c.日期<b.日期)