我有两个表,字段如下:
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
不报错,但不是我要得结果
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
不报错,但不是我要得结果
解决方案 »
- ???请问如何在界面添加 小方格并显示相关信息 ???
- 青岛的朋友请进来一下
- 怎么判断EDIT中的字符被选中,就是说用鼠标按住不放以后的那种选中 ?
- 我想做象QQ那样的,一个头像一个标签的列表。初步决定用ListView做。但是如何作到一行不管多宽都只显示一个图标和一个标签。
- Delphi分不分Debug和Release?
- 如何在“市场”下面增加节点?
- **********一个有关时间的查询*效率*问题~~~~~高分********
- dbgrid格式化显示逻辑字段
- 怎么做加密,解密啊
- 有没有动态计算表达式的控件或DELPHI函数或函数?一定给分!
- Table1.TableName:='student.db'这样赋值不可以,应该怎样做呢?
- 如何在install shield for d4 中运行其它的程序?
select test.id, max(test1.dt)
from test inner join test1 on test.id = test1.id
where test1.id = '0001'
group by test.id
form test a,(select id,max(date) as date from test1 group by id) b
where a.id=b.id and a.id='0001'
form 表一 a, 表二 b
where a.id in (select top 1 id from 表二 order by date desc)就可以了
form 表一 a, 表二 b
where a.id in (select top 1 id from 表二 order by date desc)就可以了