select * from tablename a
where age=(select max(age) from tablename where id=a.id)

解决方案 »

  1.   

    select * from tablename ta
    where not exits(select 1 from tablename where ta.name=name and ta.age<age)
      

  2.   

    select * from tablename ta
    where not exits(select 1 from tablename where ta.id=id and ta.age<age)
      

  3.   

    select * from table1 A where
    age = (select max(age) from table1 where id = A.id)
      

  4.   

    select id,name,age from table1 a group by id having age=(select max(age) from table1 where id=a.id)
      

  5.   

    select * from 表 tem where name=(select top 1 name from 表 where id=temid)
      

  6.   

    alter table add id1 int identity(1,1)
     select * from table where id1 in(select id1,max(age) from table group by id)
    alter table drop id1
      

  7.   

    select * from 表 tem where name=(select top 1 name from 表 where id=tem.id)
      

  8.   

    age可能不唯一,select * from 表 tem where name=(select top 1 name from 表 where id=tem.id order by age desc)
      

  9.   

    首先建立函数:
    CREATE FUNCTION uf_getmax(@id %type) /*%type为某一种类型*/
    RETURNS %type AS  
    BEGIN 
    declare  @v_name %type
    select  @v_name=max(name) from 表名 where id=@idreturn @v_name
    ENDselect id,dbo.uf_getmax(id) from 表名 group by id
      

  10.   

    select * from tablename a
    where name=(select top 1 from tablename where id=a.id desc)
      

  11.   

    如果不考虑max(age)不唯一的情况:
    SELECT * FROM TableName a 
    WHERE a.age = (SELECT  MAX(b.age) FROM TableName b GROUP BY b.id HAVING b.id = a.id)否则用Rewiah(乘长风)第2次发的就对了。