Edits to remove what I have found will not work and try to better explain what I am looking to do.
I have a feature polygon layer that is queried with a buffer. I use StatisticDefinition to sum one field shown in the code below. Using the 4.17 JS API https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html
I would like to return the polygon ID which is a string in this case I am using block groups. The problem is I cant use StatisticDefinition on a string field as it must be a sum, max, min or so on.
When I call console.log(result.features[0].attributes) I see one attribute from the query hh_202006. So this is the summed value for hh_202006 inside the buffer. I would like to add the ID for all block groups.
function queryStatistics() {
const statDefinitions = [
onStatisticField:
"CASE WHEN 202006 > 0 THEN 202006 ELSE 0 END",
outStatisticFieldName: "hh_202006",
statisticType: "sum",
}]
const query = featureLayerView.layer.createQuery()
query.geometry = sketchGeometry;
query.distance = bufferSize;
query.units = 'miles'
query.outStatistics = statDefinitions; //Only seeing results for this
return featureLayerView.queryFeatures(query).then(function (result) {
console.log(result.features[0].attributes)
}
}