从详细信息表中获取第二条记录

时间:2011-12-24 19:49:50

标签: sql-server

我有一个详细信息表(AppID,SSN)。我想只获得记录重复的第二个。 enter image description here

我用红色指出了我想得到的价值。请告诉我MS SQL中的查询。

1 个答案:

答案 0 :(得分:1)

修改

select AppID, SSN ,rn from (
select AppID, SSN , row_number() over(partition by AppID order by  AppID) as rn from Table
)T where rn=2
相关问题