<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS 10.1 - query outStatistics with database views? in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476335#M2276</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like query layers are not supported by summary statistics in server 10.1. I also have a service based on a view and I notice that the layer has an attribute that is called "Supports Statistics" and is set to False. I have not been successfully in finding much documentation about supported layer types. I only found in the REst Server API that Layers and Tables are supported. I hope that there is either a feasible workaround or this will be enhanced in a future update.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 May 2013 19:21:19 GMT</pubDate>
    <dc:creator>BrianLeroux</dc:creator>
    <dc:date>2013-05-01T19:21:19Z</dc:date>
    <item>
      <title>ArcGIS 10.1 - query outStatistics with database views?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476334#M2275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm currently setting up some map services on a server running the 10.1 prerelease, and I'm running into a couple issues when using database views as layers in a map.&amp;nbsp; I've tried this with both SQL Express and PostgreSQL database backends, and while I can create a mapserver service that contains layers based on database views, I don't seem to be able to run statistics on these.&amp;nbsp; I can run a normal query with a where statement (e.g., where For example, in SQL Express, I might create a view named "test" that joins two tables (a feature layer named 'points', and some other table named 'joined_table') - the query looks something like (the column produces a unique ID):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;select 
 cast((row_number() over (order by [points].[objectid], [joined_table].[objectid])) as int) as objectid,
 [points].[objectid] as [point_oid],
 [points].[shape],
 [points].[join_id],
 [points].[category],
 [joined_table].[joined_attribute]
from points left join joined_table on [points].[join_id]=[joined_table].[join_id];&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I create this view in the database, it seems to look fine - I can add it to a map in ArcMap (when I'm prompted to select a unique ID).&amp;nbsp; I can then export that to a *.sd file, and publish that as a MapService (if I try FeatureService, I get warned that it's not supported).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, I try to query one of these layers via the REST api using the following outStatistics parameter:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
[
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "statisticType": "count",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "onStatisticField": "*",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "outStatisticFieldName": "Total"
&amp;nbsp; }
]
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use this on any layer that is based on a normal feature class table in the database, I get valid statistics reported...and I can group the output by specifying the groupByFieldsForStatistics parameter as appropriate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However...if I try this on a layer based on a view (as described above), the JSON response for the query request looks like the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
{
 "error": {
&amp;nbsp; "code": 400,
&amp;nbsp; "message": "Unable to complete operation.",
&amp;nbsp; "details": [
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ]
 }
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After a bit more testing, I have determined that the REST API will successfully calculate stats for a view served in a MapServer services, as long as the view just contains normal values and does not include a [shape] column...as soon as the view contains a shape (and is therefore treated as a Layer instead of a Table in the MapServer service), the stats can no longer be calculated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone suggest whether what I'm trying to do should be possible, and/or is there an alternative?&amp;nbsp; I'd like to keep the shapes in the views if possible, although I can work around it if needed using views without shapes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 14:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476334#M2275</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-04-19T14:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 - query outStatistics with database views?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476335#M2276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like query layers are not supported by summary statistics in server 10.1. I also have a service based on a view and I notice that the layer has an attribute that is called "Supports Statistics" and is set to False. I have not been successfully in finding much documentation about supported layer types. I only found in the REst Server API that Layers and Tables are supported. I hope that there is either a feasible workaround or this will be enhanced in a future update.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 19:21:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476335#M2276</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2013-05-01T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 - query outStatistics with database views?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476336#M2277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;After a bit more testing, I have determined that the REST API will successfully calculate stats for a view served in a MapServer services, as long as the view just contains normal values and does not include a [shape] column...as soon as the view contains a shape (and is therefore treated as a Layer instead of a Table in the MapServer service), the stats can no longer be calculated.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My views show as tables in my MapServer services without any shape column and I am not able to calculate statistics on them. The layer property shows "Supports Statistics: true". You can see a thread I started here: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/78141-Problems-with-Statistics"&gt;http://forums.arcgis.com/threads/78141-Problems-with-Statistics&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 May 2013 16:52:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/arcgis-10-1-query-outstatistics-with-database/m-p/476336#M2277</guid>
      <dc:creator>RobChouinard</dc:creator>
      <dc:date>2013-05-29T16:52:39Z</dc:date>
    </item>
  </channel>
</rss>

