首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Access >

单一记录的查询有关问题

2013-09-11 
单一记录的查询问题wage表,用来记录所有员工的所有历史工资和最新工资记录(包括先前所有旧的和现在新的),

单一记录的查询问题
wage表,用来记录所有员工的所有历史工资和最新工资记录(包括先前所有旧的和现在新的),现在要查询一条关于某个员工的最新工资记录(只要一条记录),该如何实现

如wage表中有记录
ID工号姓名职称类别岗位工资任职年限套改年限薪级薪级工资工资标志年度
1101AAA副高级9308333276716972007
258101AAA副高级9309343379917292008
259101AAA副高级93010353483417642009

现在只要能select出
259101AAA副高级93010353483417642009
这一条记录,怎么办?(ID是自动编码,到底是多少,我不知道的)

[解决办法]
1
select * from tt a where id=(select top 1 id from tt
where a.工号=工号 order by id desc)
2
select a.* from tt a inner join
(select 工号,max(id) as ma from tt group by 工号) b
on a.id=id

[解决办法]
3.

Select * From wage Where ID In (Select Max(ID) From wage Group By 工号)

4.

Select * From wage A Where Not Exists(Select ID From wage Where 工号 = A.工号 And ID > A.ID)


我的异常网推荐解决方案:软件开发者薪资,http://www.myexception.cn/other/1391128.html

热点排行