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 How we can find the nth higest number in MSSQL? within the SQL Server forums, part of the Databases category; How we can find the nth higest number in MSSQL?...
|
|||||||
| SQL Server SQL Server is a Database Management System(DBMS) by Microsoft |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
Re: How we can find the nth higest number in MSSQL?
What do you mean by nth higest number . Are you trying to find out nth heighest value from a table . Like 10th heighest salary or 5th elder person. Please specify your requirment clearly.
|
|
|||
|
Re: How we can find the nth higest number in MSSQL?
To fine the N-th highest number you can use the subquery and substitute <N> with the desired number:
SELECT MIN(ColumnName) FROM TableName WHERE ColumnName IN (SELECT TOP <N> ColumnName FROM TableName ORDER BY ColumnName DESC) |
|
|||
|
select * from emp e1 where n=(select count(Distinct e2.sal) from emp e2 where e1.sal<=e2.sal);
in "n" place u can give any no 0k.... it is working... ALL THE BEST |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Fastest algorithm to find the number of bits set in a number? | chandan1008 | C and C++ | 4 | 08-27-2008 08:31 AM |
| Find out the next number | Innila | Brainteasers | 7 | 05-30-2007 07:57 AM |
| Find the next 4 number | Manojks | Brainteasers | 8 | 02-22-2007 02:12 AM |
| Can you find the number | SriramKrishna | Brainteasers | 4 | 10-25-2006 12:56 PM |
| Find the next number | RyanJames | Brainteasers | 2 | 08-16-2006 06:46 AM |