首页 > 数据库技术 > 详细

sql分组获取第一条记录(sql+oracle)

时间:2015-07-03 01:33:53      阅读:322      评论:0      收藏:0      [点我收藏+]

sql版本

select * from
(select t.CloseDate,t.ExpiryDate,t.DataTypeLookupID,
ROW_NUMBER() over(partition by CloseDate,ExpiryDate,DataTypeLookupID order by CloseDate,ExpiryDate,DataTypeLookupID)
as new_index
from dbo.IndexVolatilityMarketData t
) a where a.new_index=1

oracle版本

 

select * from (
select t.as_of_date,t.origination_date,t.maturity_date,
rank()over(partition by t.as_of_date,t.origination_date,t.maturity_date order by t.as_of_date,t.origination_date,t.maturity_date) mm from alm_agreement_deposit t)a
where a.mm=1;

sql分组获取第一条记录(sql+oracle)

原文:http://www.cnblogs.com/kexb/p/4617479.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!