當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


JavaScript ArcGIS Query.having用法及代碼示例


基本信息

以下是所在類或對象的基本信息。

AMD: require(["esri/rest/support/Query"], (Query) => { /* code goes here */ });

ESM: import Query from "@arcgis/core/rest/support/Query";

類: esri/rest/support/Query

繼承: Query > Accessor

自從:用於 JavaScript 4.20 的 ArcGIS API

用法說明

Query.having函數(或屬性)的定義如下:

having String


與 outStatistics 和 groupByFieldsForStatistics 一起使用的條件,用於將查詢結果限製為滿足聚合函數的組。

此子句支持以下聚合函數:MIN | MAX | AVG | SUM | STDDEV | COUNT | VAR

having 中使用的聚合函數也必須包含在outStatistics 中。有關其工作原理的示例,請參見下麵的代碼段。

對於基於服務的圖層查詢,僅當圖層的 supportsHavingClause 屬性為 true 時,此參數才適用。所有LayerView 查詢都支持此屬性。

例子:

query.outStatistics = [{
  onStatisticField: "CUSTOMERS",
  outStatisticFieldName: "avg_customers",
  statisticType: "avg"
}, {
  onStatisticField: "RATING",
  outStatisticFieldName: "min_rating",
  statisticType: "min"
}, {
  onStatisticField: "1=1",
  outStatisticFieldName: "total_businesses",
  statisticType: "count"
}];
query.groupByFieldsForStatistics = [ "region" ];
query.having = "AVG(CUSTOMERS) >= 1,000 AND MIN(RATING) >= 3";

// query the above stats for all regions where
// the average number of daily customers per business is
// greater than 1,000 and the minimum customer rating
// for a business within the region is 3
layer.queryFeatures(query).then(displayResults);

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 Query.having。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。