ArcObjects Library Reference (Carto)  

IMapServer4.QueryDataStatistics Method

Calculates aggregate statistics for one or more fields on a table or layer.

[Visual Basic .NET]
Public Function QueryDataStatistics ( _
    ByVal MapName As String, _
    ByVal pTableDescription As IMapTableDescription, _
    ByVal pRequest As IStatisticsRequest, _
    ByVal pQueryFilter As IQueryFilter _
) As IRecordSet
[C#]
public IRecordSet QueryDataStatistics (
    string MapName,
    IMapTableDescription pTableDescription,
    IStatisticsRequest pRequest,
    IQueryFilter pQueryFilter
);
[C++]
HRESULT QueryDataStatistics(
  BSTR MapName,
  IMapTableDescription* pTableDescription,
  IStatisticsRequest* pRequest,
  IQueryFilter* pQueryFilter,
  IRecordSet** ppResult
);
[C++]

Parameters

MapName [in]   MapName is a parameter of type BSTR pTableDescription [in]

  pTableDescription is a parameter of type IMapTableDescription

pRequest [in]

  pRequest is a parameter of type IStatisticsRequest

pQueryFilter [in]

  pQueryFilter is a parameter of type IQueryFilter

ppResult [out, retval]

  ppResult is a parameter of type IRecordSet

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

QueryDataStatistics returns a recordset with requested statistics optionally grouped by or/and ordered by field(s) from a layer or a table. Use IStatisticsRequest to define what type of statistical information you would like to get back and how you want result be presented (e.g. sorted differently or result grouped by values from another field).

Please note that you must check IMapTableInfo2::SupportsStatistics before calling this function since not all layer type or source database supports this functionality.

This function honors defintion expression set to the layer or table. If you need to statistics from a set of features/rows that meet a criterion, then you can use IQueryFilter::WhereClause and pass this as a parameter to this function. When QueryFilter parameter is null, all features/rows are used (if defintion expression is not set) to compute statistics.

When IStatisticDescription::ResultFieldName is not specified, an auto-generated field name will be used.

 

Results:

If IStatisticRequest::GroupByFields is specified, statistics will be calculated separately for each unique attribute value. The output record will contain only one record if no GroupByFields is specified. If one is specified, there will be one record for each GroupByFields value.

Limitations:

[C#]

Sample code shows getting maximum value from LANDVAL field


IStatisticDescription pStatDesc = new StatisticDescription()
{
    StatisticType = esriDataStatType.esriDataStatTypeMax,
    StatisticFieldName = "LANDVAL",
    ResultFieldName = "max_landval"
};
IStatisticDescriptions pStatDescs = new StatisticDescriptions();
pStatDescs.Add(pStatDesc);
IStatisticsRequest pStatReq = new StatisticsRequest();
pStatReq.StatisticDescriptions = pStatDescs;

IRecordSet pRS = m_pMapServer.QueryDataStatistics(m_pMapServer.DefaultMapName, pMapTblDesc, pStatReq, null);

See Also

IMapServer4 Interface