AnsweredAssumed Answered

Can a SQL expression be created to select the five ( 5 ) greatest and five ( 5 ) least values of a parameter?

Question asked by msg5 on Oct 23, 2014
Latest reply on Oct 24, 2014 by tkowal

I wish to select only the five ( 5 ) greatest and five ( 5 ) least values of a parameter ( elevation ) for several sets of over 1000 points. Batch selecting requires that SQL expressions for the desired greatest and least unique values be identified manually, which is very time consuming.




Five ( 5 ) greatest and least elevation values should be selected from a very large set of elevation points. Setting-up a batch selection with SQL expressions conforming to unique point elevation values consumes much time, slowing data.




A SQL expression or tool that allows points with the specified attributes to be selected and exported to a new shapefile. Conceptually, the process might be considered according to the following steps.


1. Sort point elevations, ascending or descending values


2. Identify the greatest and least elevation values


3. Select the greatest, and second-fifth greatest, and the least through fifth-least elevations


4. Export the selected points to a new point shapefile


Logically, the query could be expressed in the following way.


1. The greatest point elevation is greater than all other point elevation values


2. The second greatest point elevation value is less than the point identified in 1, above, but greater than all other values, and so on.