Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To find n th Maximum 1

Status
Not open for further replies.

MadhanaGopal

Programmer
Jul 15, 2002
13
US
In a following Table ,

Table : order
Fields: order Id
value
i want to find the 'n' th maximum value of order using a single query.
Thanx in Advance.

P.Madhana Gopal,
Principal Software Engineer,
LCube Innovative Solns. Pvt. Ltd.,
India.
 
The following query selects the 50th largest value.

Select Min([Value])
From
(Select Top 50 Value
From [Order] Order By [Value] desc) q Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Hi Terry,
your solution is used to acheived my Goal.But is there any possibility to write it in ANSI Standard?B'use Top is SQL Server Specific. P.Madhana Gopal,
Principal Software Engineer,
LCube Innovative Solns. Pvt. Ltd.,
India.
 
That would be rather difficult, though TOP is a very usefull
statement to use in queries, several large database packages implement diffferent variations on it.
( for instance, under Oracle you can achieve the same effect using ROWNUM )
If you want to use a query like this on a different database platform, you probably have to rewrite it for each platform. ( and yes, that is going to give a headache,
I'm currently working on building several java query translators that make sense of object oriented query trees and turn them into SQL statements for the platform they are written for. )
[hammer]

Kris Simonis
OGD Software


Kris Simonis
Topdesk Information Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top