Select to view content in your preferred language

Order QueryTask results?

4187
9
04-16-2010 01:48 PM
TimLowrimore
Occasional Contributor
Is there a way to order QueryTask results?

I have a query and query tasks setup to return a featureset of polylines and I'd like to have them ordered by shape.len.  Is that possible?

Thanks.
0 Kudos
9 Replies
ReneeMaxwell
Regular Contributor
I have the same questions. I'd also like to limit the query results to the first 10. I can't find any documentation on this. I tried using normal SQL query syntax but that failed.
0 Kudos
PeteVitt
Frequent Contributor
Was it ever determined if the ordering could be achieved?
0 Kudos
MarkSmith
Occasional Contributor
Hi,

The only way I found to do this was to insert the query results into a javascript multidimensional array.  You can then sort the array on a column and access the rows in the array if that helps.
0 Kudos
HemingZhu
Frequent Contributor
Is there a way to order QueryTask results?

I have a query and query tasks setup to return a featureset of polylines and I'd like to have them ordered by shape.len.  Is that possible?

Thanks.


Try this: query.where = " your where clause.. ORDER BY SHAPE.LEN"; Note: only work on 9.3.1 above
0 Kudos
DerekLoi
Regular Contributor
Try this: query.where = " your where clause.. ORDER BY SHAPE.LEN"; Note: only work on 9.3.1 above


So has anyone confirmed that this works?  I'm trying this and it doesn't seem to work.
0 Kudos
HemingZhu
Frequent Contributor
So has anyone confirmed that this works?  I'm trying this and it doesn't seem to work.


I used ORDER BY in you code a couple of times and I have no problem with it. It is an added feature on 9.3.1. I don't see why it would not work on 10...
0 Kudos
DerekLoi
Regular Contributor
I used ORDER BY in you code a couple of times and I have no problem with it. It is an added feature on 9.3.1. I don't see why it would not work on 10...


so can you show an example of your code?  i'm not so sure if the problem lies with ver 9.3.1 or ver 10.. the problem lies with the version of the API...  I'm using v2.2 of the Javascript API ....
here's my code and it just dies at the "query.where" line...
if i take out the ".. ORDER BY" and just use query.where = "ACTIVE = 'Y'" then it works without a hitch

        var queryTask = new esri.tasks.QueryTask(serviceURL + "/" + index);
        var query = new esri.tasks.Query();
        query.returnGeometry = false;
        query.outFields = ["INDEX", "ADDRESS", "ZIP"];
 query.where = "ACTIVE = 'Y'.. ORDER BY INDEX";
 queryTask.execute(query,queryResults);
0 Kudos
HemingZhu
Frequent Contributor
so can you show an example of your code?  i'm not so sure if the problem lies with ver 9.3.1 or ver 10.. the problem lies with the version of the API...  I'm using v2.2 of the Javascript API ....
here's my code and it just dies at the "query.where" line...
if i take out the ".. ORDER BY" and just use query.where = "ACTIVE = 'Y'" then it works without a hitch

        var queryTask = new esri.tasks.QueryTask(serviceURL + "/" + index);
        var query = new esri.tasks.Query();
        query.returnGeometry = false;
        query.outFields = ["INDEX", "ADDRESS", "ZIP"];
 query.where = "ACTIVE = 'Y'.. ORDER BY INDEX";
 queryTask.execute(query,queryResults);


what is the two dots for in your code ".. ORDER BY INDEX"?
0 Kudos
DerekLoi
Regular Contributor
what is the two dots for in your code ".. ORDER BY INDEX"?

ah crap... (i think i need to take a break from coding for a bit)
thanks for your help
0 Kudos