<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bending the Rules</title>
	<atom:link href="http://blog.geocortex.com/2008/09/11/bending-the-rules/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.geocortex.com/2008/09/11/bending-the-rules/</link>
	<description>Web-based GIS, software development &#38; various other topics of interest to us.</description>
	<lastBuildDate>Tue, 17 Jan 2012 15:04:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: John</title>
		<link>http://blog.geocortex.com/2008/09/11/bending-the-rules/#comment-6081</link>
		<dc:creator>John</dc:creator>
		<pubDate>Sat, 20 Sep 2008 14:05:25 +0000</pubDate>
		<guid isPermaLink="false">/blogs/geocortex/archive/2008/09/11/bending-the-rules.aspx#comment-6081</guid>
		<description>Sort of...with varying results.

Returning a computed value requires that we &quot;encode&quot; that computed value into an existing field.  I like OBJECTID for that, but it sometimes can give us only rough results depending on what we&#039;re asking.  Some examples, all still using the Geocode Streets layer on the demonstration site:

To get the count of features, we encode the result of COUNT into the OBJECTID:

SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT COUNT(*) FROM CNTY_STREETS_V WHERE R_JURIS=&#039;HUNTERSVILLE&#039;)
 
This gives us the number of street segments inside or bordering (right side only :) ) on HUNTERSVILLE(though there are better ways in ArcIMS to get the feature count, this serves as a decent example).

To get the AVG value, we can do:

SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT FLOOR(AVG(LL_ADD)) FROM CNTY_STREETS_V WHERE R_JURIS=&#039;HUNTERSVILLE&#039;)

Which gives us the average value of lower left address of all street segments in HUNTERSVILLE, to the nearest whole number (starting to lose some precision here).

Now, to get SUM we can do this:

SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT SUM(LL_ADD)/1000 FROM CNTY_STREETS_V WHERE R_JURIS=&#039;HUNTERSVILLE&#039;)

Which gives us the sum of all lower left addresses of all street segments in HUNTERSVILLE.  This loses much precision in this case, but sometimes your queries don&#039;t need much (if any at all) precision loss.

Notice that in all three cases, we&#039;re not *really* getting back what we&#039;ve asked for, but we&#039;re getting back a feature whose OBJECTID is equal to (or close to) what we&#039;ve asked for.  So in essence, we&#039;re &quot;encoding&quot; our value into the OBJECTID.

We needed to divide our SUM by 1000 in the last case because there is no feature with an OBJECTID which is as high as the sum.  This resulted in a lack of precision, since the OBJECTID of my returned feature is 25614, meaning the SUM is 25,614,000 plus or minus 1000.  Sometimes close enough is better than nothing :)

Incidentally, I&#039;ve also discovered that we can use JOIN expressions in our sub-selects - even joining to tables *not* in the current map service.  Certainly underscores the need to restrict access to your tables by the SDE user you are connecting as in the AXL...</description>
		<content:encoded><![CDATA[<p>Sort of&#8230;with varying results.</p>
<p>Returning a computed value requires that we &#8220;encode&#8221; that computed value into an existing field.  I like OBJECTID for that, but it sometimes can give us only rough results depending on what we&#8217;re asking.  Some examples, all still using the Geocode Streets layer on the demonstration site:</p>
<p>To get the count of features, we encode the result of COUNT into the OBJECTID:</p>
<p>SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT COUNT(*) FROM CNTY_STREETS_V WHERE R_JURIS=&#8217;HUNTERSVILLE&#8217;)</p>
<p>This gives us the number of street segments inside or bordering (right side only <img src='http://blog.geocortex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) on HUNTERSVILLE(though there are better ways in ArcIMS to get the feature count, this serves as a decent example).</p>
<p>To get the AVG value, we can do:</p>
<p>SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT FLOOR(AVG(LL_ADD)) FROM CNTY_STREETS_V WHERE R_JURIS=&#8217;HUNTERSVILLE&#8217;)</p>
<p>Which gives us the average value of lower left address of all street segments in HUNTERSVILLE, to the nearest whole number (starting to lose some precision here).</p>
<p>Now, to get SUM we can do this:</p>
<p>SDE_CHAR_VMB.SDE_CHAR_VMB.CNTY_STREETS_V.OBJECTID IN (SELECT SUM(LL_ADD)/1000 FROM CNTY_STREETS_V WHERE R_JURIS=&#8217;HUNTERSVILLE&#8217;)</p>
<p>Which gives us the sum of all lower left addresses of all street segments in HUNTERSVILLE.  This loses much precision in this case, but sometimes your queries don&#8217;t need much (if any at all) precision loss.</p>
<p>Notice that in all three cases, we&#8217;re not *really* getting back what we&#8217;ve asked for, but we&#8217;re getting back a feature whose OBJECTID is equal to (or close to) what we&#8217;ve asked for.  So in essence, we&#8217;re &#8220;encoding&#8221; our value into the OBJECTID.</p>
<p>We needed to divide our SUM by 1000 in the last case because there is no feature with an OBJECTID which is as high as the sum.  This resulted in a lack of precision, since the OBJECTID of my returned feature is 25614, meaning the SUM is 25,614,000 plus or minus 1000.  Sometimes close enough is better than nothing <img src='http://blog.geocortex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Incidentally, I&#8217;ve also discovered that we can use JOIN expressions in our sub-selects &#8211; even joining to tables *not* in the current map service.  Certainly underscores the need to restrict access to your tables by the SDE user you are connecting as in the AXL&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berend Veldkamp</title>
		<link>http://blog.geocortex.com/2008/09/11/bending-the-rules/#comment-6080</link>
		<dc:creator>Berend Veldkamp</dc:creator>
		<pubDate>Mon, 15 Sep 2008 18:46:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/geocortex/archive/2008/09/11/bending-the-rules.aspx#comment-6080</guid>
		<description>That&#039;s pretty clever. 

I was wondering if there&#039;s a trick to get the SUM of (a selection of) features? subfields=&quot;SUM(COUNT)&quot; doesn&#039;t seem to work.</description>
		<content:encoded><![CDATA[<p>That&#8217;s pretty clever. </p>
<p>I was wondering if there&#8217;s a trick to get the SUM of (a selection of) features? subfields=&#8221;SUM(COUNT)&#8221; doesn&#8217;t seem to work.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

