An online placement forum.

You are not connected. Please login or register

DBMS Query

Go down  Message [Page 1 of 1]

1 DBMS Query on Wed Mar 10, 2010 1:10 am


how to get the 4th largest record from the table.

View user profile

2 Re: DBMS Query on Thu Mar 11, 2010 12:26 am

We can use Row_number function(In SQL SERVER) to get the 4th highest.

View user profile

3 @Incognito on Thu Mar 11, 2010 12:54 am


Can you please post the query?

View user profile

4 Query on Thu Mar 11, 2010 10:01 pm

select * from
(select *,Row_number() over (order by Amount desc) as RowNumber
from FactFinance) A
where RowNumber =4

In the above mentioned query FactFinance is the table.
Amount is one of the column and I am trying to get the 4th highest amount in this table.
For doing so in the inner query you include the row_number function and in the outer query you can use the RowNumber column to get the 4th highest value.
If you still have any doubt please let me know.

View user profile

5 @Incognito on Sat Mar 13, 2010 11:28 pm


Is Row_number function availabe to Oracle/DB2/MySql database also.?

View user profile

6 @maven on Thu Mar 18, 2010 7:24 pm

for oracle you can use below query:-
select emp_id from (select rank() over (order by emp_id desc) r , emp_id from emp)
where r=4

Here table name is emp and column name is emp_id.It will give the 4th largest emp_id.

View user profile

Sponsored content

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum