|
| 1 | +<h1>Statistical Query Group And Sort</h1> |
| 2 | + |
| 3 | +<p>Demonstrates how to query a feature table for statistics grouping and sorting by different fields.</p> |
| 4 | + |
| 5 | +<p><img src="StatisticalQueryGroupAndSort.png"></p> |
| 6 | + |
| 7 | +<h2>How to use the sample</h2> |
| 8 | + |
| 9 | +<p>The sample will start with some default options selected. You can immediately click the "Get Statistics" button to |
| 10 | + see the results for these options.</p> |
| 11 | + |
| 12 | +<p>To change the statistic definitions, you can add statistic definitions to the top-left table using the combo boxes |
| 13 | +and "Add button". Select a table row and click "Remove" to remove the statistic definition.</p> |
| 14 | + |
| 15 | +<p>To change the group-by fields, check the box by the field you want to group by in the bottom-left list view.</p> |
| 16 | + |
| 17 | +<p>To change the order-by fields, select a group by field (it must be checked) and click the ">>" button to add it to |
| 18 | + the Order By table. To remove a field from the Order by table, select it and click the "<<" button. To change the |
| 19 | + sort order of the order-by field, click on a cell in the Sort Order column to edit it using a ComboBox.</p> |
| 20 | + |
| 21 | + <h2>How it works</h2> |
| 22 | + |
| 23 | + <p>To query statistics from a feature table:</p> |
| 24 | + |
| 25 | + <ol> |
| 26 | + <li>Create and load a <code>ServiceFeatureTable</code>.</li> |
| 27 | + <li>Get the feature tables field names list with <code>featureTable.getFields()</code>.</li> |
| 28 | + <li>Create <code>StatisticDefinition</code>s specifying the field to compute statistics on and the |
| 29 | + <code>StatisticType</code> to compute.</li> |
| 30 | + <li>Create <code>StatisticsQueryParameters</code> passing in the list of statistic definitions.</li> |
| 31 | + <li>To have the results grouped by fields, add the field names to the query parameters' |
| 32 | + <code>groupByFieldNames</code> collection.</li> |
| 33 | + <li>To have the results ordered by fields, create <code>OrderBy</code>s, specifying the field name and |
| 34 | + <code>SortOrder</code>. Pass these <code>OrderBy</code>s to the parameters' <code>orderByFields</code> |
| 35 | + collection.</li> |
| 36 | + <li>To execute the query, call <code>featureTable.queryStatisticsAsync(queryParameters)</code></li> |
| 37 | + <li>Get the <code>StatisticQueryResult</code>. From this, you can get an iterator of |
| 38 | + <code>StatisticRecord</code>s to loop through and display.</li> |
| 39 | + </ol> |
| 40 | + |
| 41 | + <h2>Features</h2> |
| 42 | + |
| 43 | + <ul> |
| 44 | + <li>Field</li> |
| 45 | + <li>QueryParameters</li> |
| 46 | + <li>ServiceFeatureTable</li> |
| 47 | + <li>StatisticDefinition</li> |
| 48 | + <li>StatisticRecord</li> |
| 49 | + <li>StatisticType</li> |
| 50 | + <li>StatisticsQueryParameters</li> |
| 51 | + <li>StatisticsQueryResult</li> |
| 52 | + </ul> |
0 commit comments