Select to view content in your preferred language

QueryTask + Query with TOP Values

2260
3
Jump to solution
02-17-2014 11:25 AM
EvelynHernandez
Frequent Contributor
Hello me again.
Im trying to find any info about making queries with the TOP (n)  relation as its in SQL or another kind of DB languages.
Is it possible to do it with flex?

The only things that i have found its something about using StatisticDefinition parameters, but it doesnt allow to use TOP.
Thanks for ur help (:
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AndreasRuloffs1
Occasional Contributor
Hello,
what you can do is to do a subselect in the WHERE Clause, like that:
OBJECTID IN (SELECT TOP 20 OBJECTID FROM [SAME_TABLE])

The inner Select selects the first 20 OBJECTIDs from the Table, the Layer gets its data from.
The outer select limits then the query to the results you want.
Be careful, the innerselect may be a problem, if your featureclass is versioned.
Hope this will help you,
Andreas Ruloffs

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Evelyn,

   Using SQL functions like TOP would mean that you have to have access to the whole select statement and that is not possible on ArcGIS Server. You only have access to the Where clause portion of the select statement.
0 Kudos
AndreasRuloffs1
Occasional Contributor
Hello,
what you can do is to do a subselect in the WHERE Clause, like that:
OBJECTID IN (SELECT TOP 20 OBJECTID FROM [SAME_TABLE])

The inner Select selects the first 20 OBJECTIDs from the Table, the Layer gets its data from.
The outer select limits then the query to the results you want.
Be careful, the innerselect may be a problem, if your featureclass is versioned.
Hope this will help you,
Andreas Ruloffs
0 Kudos
EvelynHernandez
Frequent Contributor
Oh ok.
Thanks for all ur help guys i really appreciate it (:
0 Kudos