group by in queryTask(equal to group by in sql)

1524
2
07-25-2012 09:34 PM
JanJeske
New Contributor III
Hey,

I search for a solution to group queryTask results. In my query:
        queryTask = new esri.tasks.QueryTask("url");
 query = new esri.tasks.Query();
 query.returnGeometry = false;
 query.outFields = ["tabellenspalte"];
 query.where = "tabellenspalte2= 'bedingung'"    
 query.orderByFields = ["ABS(tabellenspalte)"];
 queryTask.execute(query,functionweiter);


The Output is like

tabellenspalte:1
tabellenspalte:1
tabellenspalte:1
tabellenspalte:2
tabellenspalte:2
tabellenspalte:3
tabellenspalte:4
tabellenspalte:4

But i want only


tabellenspalte:1
tabellenspalte:2
tabellenspalte:3
tabellenspalte:4

Any suggestions?
0 Kudos
2 Replies
StephenLead
Regular Contributor III
The output of the queryTask is a featureSet, which you could iterate through and summarise manually. Stub code:

function functionweiter(featureSet){ var features = featureSet.features;
 for(var i=0, il=features.length; i++) {
  var feature = features;
  //summarise
 });
});  
0 Kudos
JanJeske
New Contributor III
Thanks for the reply.

Yeah thats right thanks i did it like this in previous projects but i get more than 30000 datasets back. Wich are grouped only ca. 1000. So its to much overhead to group in an array. Cause the whole datasets must be tranfered first 😞

My sollution now is to get the grouped datasets via ajax from a PHP file in json format.


@esri How would be a group by sollution in furter Versions of the API it should no be such hard to realize or? its extends just the select queries by a group by 🙂