JIGYASA
Would you like to react to this message? Create an account in a few clicks or log in to continue.
JIGYASA

An online placement forum.


You are not connected. Please login or register

DBMS Query

3 posters

Go down  Message [Page 1 of 1]

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

maven


Admin

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

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

Incognito



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

3DBMS Query Empty @Incognito Thu Mar 11, 2010 12:54 am

maven


Admin

Can you please post the query?

4DBMS Query Empty Query Thu Mar 11, 2010 10:01 pm

Incognito



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.

5DBMS Query Empty @Incognito Sat Mar 13, 2010 11:28 pm

maven


Admin

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

6DBMS Query Empty @maven Thu Mar 18, 2010 7:24 pm

amit



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.

Sponsored content



Back to top  Message [Page 1 of 1]

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