我不知道你是哪个意思(是所有记录最大或是每组中最大按clientid分组)
select max(a.id) from 表1 a ,表2 b where a.clientid=b.clientid
或者
select a.clientid,max(a.id) from 表1 a ,表2 b where a.clientid=b.clientid 
group by a.clientid

解决方案 »

  1.   

    select max(id) from 表1 where clientid in(select clientid from 表2)
      

  2.   

    select max(table1.clientid) from table1 table2 where table1.clientid=table2.clientid不知道是不是你所要求的?
      

  3.   

    select * 
    from 表1 t
    where exists(select 1 from 表2 where ClientID=t.ClientID)
          and
          not exists(select 1 from 表1 where ID>t.ID)
      

  4.   

    select
        a.ClientID,ID = max(b.ID)
    from
        表2 a,
        表1 b
    where
        a.ClientID = b.ClientID
    group by
        a.ClientID
      

  5.   

    ID是否唯一
    若唯一
    select top 1 * from table1,table2 where table1.clientid=table2.clientid
    order by table1.id desc若不唯一select * from table1,table2 where table1.clientid=table2.clientid
    and table1.id =(select max(id) from table1)
      

  6.   

    Select A.ID  A.ClientIDF
    From 表1 A
    Where ID  = ( Select Max(ID) From 表1 Where ClientID  =  A.ClientIDF)