当前位置:Gxlcms > 数据库问题 > sql分组获取第一条记录(sql+oracle)

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

时间:2021-07-01 10:21:17 帮助过:3人阅读

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)

标签:

人气教程排行