user3688929
user3688929

Reputation: 23

getting a specific row over a partitioned sql query

I know i can get first_value() and last_value() over partitioned sql query which is ordered by a column I know, but let's say I want the second value, or the third... Is there a function to do so? Thanks in advance.

Upvotes: 0

Views: 47

Answers (1)

Bura Chuhadar
Bura Chuhadar

Reputation: 3751

As far as I know, there is no specific function for that. However you can select the second row like this:

with row_numbers AS(select row_number() over(order by yourColumn) as 'row', * 
                from table)
select * from row_numbers
where row=2

Upvotes: 1

Related Questions