Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Please answer this question as soon as possible within the SQL forums, part of the Databases category; How to find the Nth largest or Nth smallest salary or number in a table?...
|
|||||||
|
|||
|
How to find the Nth largest or Nth smallest salary or number in a table?
|
| The Following User Says Thank You to ketaki.gawde For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
Hi,
below query is to find the Nth max value in a table: SELECT min(empno) FROM(SELECT DISTINCT(empno) FROM employee ORDER BY empno desc) WHERE ROWNUM<= N; below query is to find the Nth max value in a table: SELECT max(empno) FROM(SELECT DISTINCT(empno) FROM employee ORDER BY empno asc) WHERE ROWNUM<= N; |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
Maximum sal
select sal maxsal from (select sal, rn from (select sal, rownum rn from scott.emp order by sal desc) where rn = &rn) or minimum sal select sal minsal from (select sal, rn from (select sal, rownum rn from scott.emp order by sal asc) where rn = &rn)
__________________
sireesha |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
Quote:
within derived table & outside row Select row,Salary from (Select row_number() over(order by Salary) row, Salary from table1) Where row = Nth |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
select max(sal) from emp where sal<
(select max(sal) from emp where sal<(select max(sal) from emp)) Last edited by asad Shaik; 07-03-2009 at 02:56 PM. |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
See ,N largest number and N smallest number means the largest and the smallest
value from the column of the given table This can be fine out by the max and min function. |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
Hi Jitendra,
DBMS is a ordinary system to maintain the data, whereas RDBMS is the specific type, which follows the concepts of set theory i.e entity etc. In DBMS there is no concept of PRIMARY KEY and FOREIGN KEY but it is included in RDBMS. DBMS contains only flat data whereas in RDBMS there will be some relation between the entities. If u want to know more differences here is this... DBMS: 1)In dbms no relationship concept 2)It supports Single User only 3)It treats Data as Files internally 4)It supports 3 rules of E.F.CODD out off 12 rules 5)It requires low Software and Hardware Requirements. 6)FoxPro, IMS are Examples RDBMS: 1)It is used to establish the relationship concept between two database objects, i.e, tables 2)It supports multiple users 3)It treats data as Tables internally 4)It supports minimum 6 rules of E.F.CODD 5)It requires High software and hardware requirements. 6)SQL-Server, Oracle are examples && one thing ... Plz post u r queries starting with a new thread... Thanks & Regards, Riju. |
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
Quote:
select max(col_name),min(col_name) from table_name; |
|
|||
|
Do you know how to create procedure for emp table to extract all the highest salary holder from all the departments....
|
|
|||
|
Re: Please answer this question as soon aaaaaaaaas possi
@rajabose, why need to go for stored procedures, we can achieve this, by sql analytic functions. For ur reference :
Quote:
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to answer this question | sripri | Interviews | 7 | 09-01-2009 02:06 AM |
| please answer my question | madhoo_09 | Java | 2 | 02-26-2009 01:32 AM |
| Please answer this question | desi_guru | Testing Issues | 1 | 01-13-2009 07:21 AM |