取表中 某累记录的最大5行
来源:互联网 发布:招聘网络推广专员 编辑:程序博客网 时间:2024/06/11 22:35
declare @tb table (dt datetime,stockid char(6),fvol numeric(20,5))
insert into @tb select '2008-3-11','000800',289928.4375
insert into @tb select '2008-2-22','000800',503016.1875
insert into @tb select '2008-2-25','000800',-10095.21582
insert into @tb select '2008-2-26','000800',-36981.878906
insert into @tb select '2008-2-27','000800',644.995361
insert into @tb select '2008-2-28','000800',2198.187988
insert into @tb select '2008-2-29','000800',5654.983398
insert into @tb select '2008-3-3','000800', 5546.563965
insert into @tb select '2008-3-2','600000',-24493.21875
insert into @tb select '2008-2-22','600000',550059.6875
insert into @tb select '2008-2-25','600000',-18295.4375
insert into @tb select '2008-2-26','600000', -81992.4375
insert into @tb select '2008-2-27','600000',84372.671875
insert into @tb select '2008-2-28','600000',-10039.753906
insert into @tb select '2008-2-29','600000',-715.375
insert into @tb select '2008-3-3','600000',26328.328125
select * From
(
select top 10 stockid, (dt) ,fvol
from
@tb
group by stockid ,dt ,fvol
order by max(dt) desc
)c
order by stockid ,dt
insert into @tb select '2008-3-11','000800',289928.4375
insert into @tb select '2008-2-22','000800',503016.1875
insert into @tb select '2008-2-25','000800',-10095.21582
insert into @tb select '2008-2-26','000800',-36981.878906
insert into @tb select '2008-2-27','000800',644.995361
insert into @tb select '2008-2-28','000800',2198.187988
insert into @tb select '2008-2-29','000800',5654.983398
insert into @tb select '2008-3-3','000800', 5546.563965
insert into @tb select '2008-3-2','600000',-24493.21875
insert into @tb select '2008-2-22','600000',550059.6875
insert into @tb select '2008-2-25','600000',-18295.4375
insert into @tb select '2008-2-26','600000', -81992.4375
insert into @tb select '2008-2-27','600000',84372.671875
insert into @tb select '2008-2-28','600000',-10039.753906
insert into @tb select '2008-2-29','600000',-715.375
insert into @tb select '2008-3-3','600000',26328.328125
select * From
(
select top 10 stockid, (dt) ,fvol
from
@tb
group by stockid ,dt ,fvol
order by max(dt) desc
)c
order by stockid ,dt
- 取表中 某累记录的最大5行
- 查找相同记录的最大日期的行
- 获取ID最大的记录的信息
- 求oracle最大的十条记录.
- 得到数据库中id最大的记录
- 取重复记录最大的id列表
- mysql求id最大的数据记录
- 分组查询最大最小记录的方法
- 取时间最大的一条记录
- SQL_多条记录中取最大日期的记录
- mysql查询ID相同的某字段最大那条记录
- sql表中如何获得最大时间的记录
- 用 AutoHotkey分析日志文件得到耗时最大的记录
- [记录]修改MYSQL最大连接数的方法分享
- mysql 分组 排序 取时间最大的一条记录
- sql 查询相同记录下日期最大的 一条
- 按照某个字段分组,取出最大的一条记录
- 分组查询取最大时间记录的多种方式
- C#中判断字符是否为中文
- 篆书印章文字 谁能识别是什么字?
- 获取数据库信息
- [转]CSocket 和CAsyncSocket类介绍
- 交往, 帮助他人, 知识积累, 心理素质, 大胆去做
- 取表中 某累记录的最大5行
- 函数指针&回调函数&linux中的signal函数
- [转]INTERNET编程之CSOCKET编程续 - 章志强 - CSDNBlog
- 如何得到字符的UNICODE编码
- SQL语句性能调整原则
- 购买数码相机前最需要知道的参数
- Windows下NTFS无损转换FAT32格式
- JSP Tag
- Visual C#程序设计技巧小结