我有两个表,字段如下:  
id      name      sex      birthday    
001    张三      男        1976-09-15  
002    李四      男        1978-05-15  
 
 
autoid        id        date              area  
1                  001      1980-76-09  15  
2                  001      1990-01-01  20  
 
其中表二中的id和表一中的id关联,date字段是一个逐年增大的字段,我如何得到表一中的一行关联表二中date字段年份最大的一行,如:  
id    name    sex    birthday      date              area  
001  张三    男      1976-09-15  1990-01-01  20    
 
高手给个sql查询语句  
我在paradox下,  
select  top  1  test.id,  test1.dt  from  test,  test1  where  test1.id  =  '0001'  and  test.id  =  test1.id  order  by  test1.dt  desc  
 
报错,不认  top  1  
如何实现??????  
 
select  test.id,  test1.dt  from  test,  test1  where  test1.id  =  '0001'  and  test.id  =  test1.id  order  by  test1.dt  desc  
不报错,但不是我要得结果

解决方案 »

  1.   

    试试下面的语句
    select  test.id,  max(test1.dt)  
    from  test inner join test1 on test.id = test1.id  
    where  test1.id  =  '0001'  
    group by  test.id   
      

  2.   

    你用Query检索出来,只处理第一条不就行了吗?好像有个BufferSize的属性来着...
      

  3.   

    select a.id,a.name,a.sex,a.birthday,b.date
    form test a,(select id,max(date) as date from test1 group by id) b
    where a.id=b.id and a.id='0001'
      

  4.   

    select a.id,a.name,a.sex,a.birthday,b.date
    form  表一 a, 表二 b
    where a.id in (select top 1 id from 表二 order by date desc)就可以了
      

  5.   

    select a.id,a.name,a.sex,a.birthday,b.date,b.area
    form  表一 a, 表二 b
    where a.id in (select top 1 id from 表二 order by date desc)就可以了