select * from person where birthday = (select max(birthday) from person)

解决方案 »

  1.   

    语句:
    select name from person
    where birthday = (select min(birthday) from person
    go
      

  2.   

    谢谢,还有个复杂点的情况,表中另有字段:level decimal not null,
    如果要列出每个不同level中,年龄最小那些人的记录呢?
      

  3.   

    select name from person where birthday in (select max(birthday) from person goup by level)
    不过 in 的效率好像不太高
    你可以用临时表
    select max(birthday) as birthday into #temp from person group by level
    select name from person inner join #temp  on person.birthday=#temp.birthday
    drop table #temp 
      

  4.   

    select * from person 
    where birthday = (select distinct level,min(birthday) from person group by level) 
      

  5.   

    这样有个问题,如果有三个人:
    A: level = 1, birthday = 1979-01-01 00:00:00
    B: level = 2, birthday = 1979-01-01 00:00:00
    C: level = 2, birthday = 1980-01-01 00:00:00
    结果应该是A、C,但是上面两位的结果大概会是A、B、C吧?
      

  6.   

    to seafo:
    select max(birthday) as birthday into #temp from person group by level
    select name from person inner join #temp  on person.birthday=#temp.birthday
    第二句是不是应该再加一个连接?你看这样对吗?
    如:select name from person,#temp where person.birthday=#temp.birthday and
    person.level=#temp.level
      

  7.   

    select *from where brithday in(select  min(birthday) from person group by level )
      

  8.   

    level为sql server数据库关键字,将level改为aa :
     select name from person a,
    (select  aa,min(birthday) as birthday from person group by aa) b
    where a.aa=b.aa and a.birthday=b.birthday