取表中 某累记录的最大5行

 

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值