数据如下:
occurred name wId
2006-09-08 14:45:19 和 88
2006-09-08 14:44:08 黄六 88
2006-09-08 14:45:31 李四 88
2006-09-08 17:26:58 王五 88
2006-09-08 14:45:19 张三 88
2006-09-08 15:55:42 和 1001
2006-09-08 17:26:57 黄六 1001
2006-09-08 17:26:57 李四 1001
2006-09-08 14:44:14 王五 1001
2006-09-08 17:26:58 张三 1001现在要找出时间最大的记录,结果如下: occurred name wId
2006-09-08 15:55:42 和 1001
2006-09-08 17:26:57 黄六 1001
2006-09-08 17:26:58 王五 88
2006-09-08 17:26:57 李四 1001
2006-09-08 17:26:58 张三 1001
thx!
occurred name wId
2006-09-08 14:45:19 和 88
2006-09-08 14:44:08 黄六 88
2006-09-08 14:45:31 李四 88
2006-09-08 17:26:58 王五 88
2006-09-08 14:45:19 张三 88
2006-09-08 15:55:42 和 1001
2006-09-08 17:26:57 黄六 1001
2006-09-08 17:26:57 李四 1001
2006-09-08 14:44:14 王五 1001
2006-09-08 17:26:58 张三 1001现在要找出时间最大的记录,结果如下: occurred name wId
2006-09-08 15:55:42 和 1001
2006-09-08 17:26:57 黄六 1001
2006-09-08 17:26:58 王五 88
2006-09-08 17:26:57 李四 1001
2006-09-08 17:26:58 张三 1001
thx!
解决方案 »
- 自建全文索引,请教如何提高写库效率
- 3核CPU安装SQL SERVER 2005 Developer Edition 出错问题的再次提问,已付错误原因,懂的说下,谢谢
- 成绩>80能否用一条语句实现
- 指点下写个查询的存储过程,谢谢。
- 由于回复较多,贴子已结,但还是不解,故发贴再问。
- 求帮助
- 试了好几次,报错误的一条语句..关于if()..关联两个表..在线等结贴
- 帮忙看一个存储过程的排序问题,实在不知道如何修改
- 存储过程:全文目录填充的问题!?
- 如何在SQLServer中实现等同于ORACLE中的minus功能?
- 如何取得,一个库中,哪些表没有key。
- 如何从一个表中读取出数据,并将其插入另一张表中???
where not exists(select 1 from table where name = a.name and occurred > a.occurred)
where not exists(select * from tb where name=a.name and occurred>a.occurred)
不知道可不可以,没试
select * from table a
inner join
(select name,max(occurred) as occurred from table group by name) b
on a.name = b.name and a.occurred = b.occurred